summaryrefslogtreecommitdiff
path: root/app/lib/django_comments/admin.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/lib/django_comments/admin.py')
-rw-r--r--app/lib/django_comments/admin.py29
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)