|
0
|
1 |
from django.contrib import admin |
|
|
2 |
from django.contrib.comments.models import Comment |
|
|
3 |
from django.utils.translation import ugettext_lazy as _ |
|
|
4 |
from django.contrib.comments import get_model |
|
|
5 |
|
|
|
6 |
class CommentsAdmin(admin.ModelAdmin): |
|
|
7 |
fieldsets = ( |
|
|
8 |
(None, |
|
|
9 |
{'fields': ('content_type', 'object_pk', 'site')} |
|
|
10 |
), |
|
|
11 |
(_('Content'), |
|
|
12 |
{'fields': ('user', 'user_name', 'user_email', 'user_url', 'comment')} |
|
|
13 |
), |
|
|
14 |
(_('Metadata'), |
|
|
15 |
{'fields': ('submit_date', 'ip_address', 'is_public', 'is_removed')} |
|
|
16 |
), |
|
|
17 |
) |
|
|
18 |
|
|
|
19 |
list_display = ('name', 'content_type', 'object_pk', 'ip_address', 'submit_date', 'is_public', 'is_removed') |
|
|
20 |
list_filter = ('submit_date', 'site', 'is_public', 'is_removed') |
|
|
21 |
date_hierarchy = 'submit_date' |
|
|
22 |
ordering = ('-submit_date',) |
|
|
23 |
raw_id_fields = ('user',) |
|
|
24 |
search_fields = ('comment', 'user__username', 'user_name', 'user_email', 'user_url', 'ip_address') |
|
|
25 |
|
|
|
26 |
# Only register the default admin if the model is the built-in comment model |
|
|
27 |
# (this won't be true if there's a custom comment app). |
|
|
28 |
if get_model() is Comment: |
|
|
29 |
admin.site.register(Comment, CommentsAdmin) |