diff options
author | luxagraf <sng@luxagraf.net> | 2017-09-26 17:49:20 -0600 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2017-09-26 17:49:20 -0600 |
commit | e9eb2c612156894e87b9fa6584c1f8d05f932fe7 (patch) | |
tree | dc9ee22c618eade87186086d1b09b82bd54ffcbe /app/lib/django_comments/admin.py | |
parent | a5f1c0580091f21fa4fd8817b41c55fa2ff6d0dc (diff) |
updated comments app to work with 1.11
Diffstat (limited to 'app/lib/django_comments/admin.py')
-rw-r--r-- | app/lib/django_comments/admin.py | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/app/lib/django_comments/admin.py b/app/lib/django_comments/admin.py index 8a5c063..d4af2d9 100644 --- a/app/lib/django_comments/admin.py +++ b/app/lib/django_comments/admin.py @@ -4,7 +4,6 @@ from django.contrib import admin from django.contrib.auth import get_user_model from django.utils.translation import ugettext_lazy as _, ungettext -from django_comments.models import Comment from django_comments import get_model from django_comments.views.moderation import perform_flag, perform_approve, perform_delete @@ -14,22 +13,26 @@ class UsernameSearch(object): a mechanism for issuing the equivalent of a .filter(user__username=...) search in CommentAdmin. """ + def __str__(self): return 'user__%s' % get_user_model().USERNAME_FIELD class CommentsAdmin(admin.ModelAdmin): fieldsets = ( - (None, - {'fields': ('content_type', 'object_pk', 'site')} + ( + None, + {'fields': ('content_type', 'object_pk', 'site')} ), - (_('Content'), - {'fields': ('user', 'user_name', 'user_email', 'user_url', 'comment')} + ( + _('Content'), + {'fields': ('user', 'user_name', 'user_email', 'user_url', 'comment')} ), - (_('Metadata'), - {'fields': ('submit_date', 'ip_address', 'is_public', 'is_removed')} + ( + _('Metadata'), + {'fields': ('submit_date', 'ip_address', 'is_public', 'is_removed')} ), - ) + ) list_display = ('name', 'content_type', 'object_pk', 'ip_address', 'submit_date', 'is_public', 'is_removed') list_filter = ('submit_date', 'site', 'is_public', 'is_removed') @@ -54,16 +57,19 @@ class CommentsAdmin(admin.ModelAdmin): def flag_comments(self, request, queryset): self._bulk_flag(request, queryset, perform_flag, lambda n: ungettext('flagged', 'flagged', n)) + flag_comments.short_description = _("Flag selected comments") def approve_comments(self, request, queryset): self._bulk_flag(request, queryset, perform_approve, lambda n: ungettext('approved', 'approved', n)) + approve_comments.short_description = _("Approve selected comments") def remove_comments(self, request, queryset): self._bulk_flag(request, queryset, perform_delete, lambda n: ungettext('removed', 'removed', n)) + remove_comments.short_description = _("Remove selected comments") def _bulk_flag(self, request, queryset, action, done_message): @@ -76,12 +82,13 @@ class CommentsAdmin(admin.ModelAdmin): action(request, comment) n_comments += 1 - msg = ungettext('1 comment was successfully %(action)s.', + msg = ungettext('%(count)s comment was successfully %(action)s.', '%(count)s comments were successfully %(action)s.', n_comments) self.message_user(request, msg % {'count': n_comments, 'action': done_message(n_comments)}) # Only register the default admin if the model is the built-in comment model # (this won't be true if there's a custom comment app). -if get_model() is Comment: - admin.site.register(Comment, CommentsAdmin) +Klass = get_model() +if Klass._meta.app_label == "django_comments": + admin.site.register(Klass, CommentsAdmin) |