2008-07-19 07:54:34 +08:00
|
|
|
from django.contrib import admin
|
2008-08-26 06:14:22 +08:00
|
|
|
from django.contrib.comments.models import Comment
|
|
|
|
from django.utils.translation import ugettext_lazy as _
|
2009-02-24 06:16:26 +08:00
|
|
|
from django.contrib.comments import get_model
|
2008-07-19 07:54:34 +08:00
|
|
|
|
2008-08-26 06:14:22 +08:00
|
|
|
class CommentsAdmin(admin.ModelAdmin):
|
2008-07-19 07:54:34 +08:00
|
|
|
fieldsets = (
|
2008-08-26 06:14:22 +08:00
|
|
|
(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')}
|
|
|
|
),
|
|
|
|
)
|
2008-07-19 07:54:34 +08:00
|
|
|
|
2008-09-16 08:25:21 +08:00
|
|
|
list_display = ('name', 'content_type', 'object_pk', 'ip_address', 'submit_date', 'is_public', 'is_removed')
|
2008-08-26 06:14:22 +08:00
|
|
|
list_filter = ('submit_date', 'site', 'is_public', 'is_removed')
|
2008-07-19 07:54:34 +08:00
|
|
|
date_hierarchy = 'submit_date'
|
2008-09-16 08:25:21 +08:00
|
|
|
ordering = ('-submit_date',)
|
2009-10-08 21:30:31 +08:00
|
|
|
raw_id_fields = ('user',)
|
2008-08-26 06:14:22 +08:00
|
|
|
search_fields = ('comment', 'user__username', 'user_name', 'user_email', 'user_url', 'ip_address')
|
2008-07-19 07:54:34 +08:00
|
|
|
|
2009-02-24 06:16:26 +08:00
|
|
|
# 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)
|