29 lines
1.1 KiB
Python
29 lines
1.1 KiB
Python
from django.contrib import admin
|
|
from django.contrib.comments.models import Comment
|
|
from django.utils.translation import ugettext_lazy as _
|
|
from django.contrib.comments import get_model
|
|
|
|
class CommentsAdmin(admin.ModelAdmin):
|
|
fieldsets = (
|
|
(None,
|
|
{'fields': ('content_type', 'object_pk', 'site')}
|
|
),
|
|
(_('Content'),
|
|
{'fields': ('user', 'user_name', 'user_email', 'user_url', 'comment')}
|
|
),
|
|
(_('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')
|
|
date_hierarchy = 'submit_date'
|
|
ordering = ('-submit_date',)
|
|
search_fields = ('comment', 'user__username', 'user_name', 'user_email', 'user_url', 'ip_address')
|
|
|
|
# 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)
|