changeset 707:c17f8bffc9e5

Account for new Django admin model.
author Bryan O'Sullivan <bos@serpentine.com>
date Tue, 31 Mar 2009 09:04:23 -0700
parents 0e33dd5d8288
children c82ff69f0935 c44d5854620b
files web/hgbook/admin.py web/hgbook/comments/models.py
diffstat 2 files changed, 23 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/hgbook/admin.py	Tue Mar 31 09:04:23 2009 -0700
@@ -0,0 +1,23 @@
+from django.contrib import admin
+from hgbook.comments.models import Comment, Element
+
+class CommentAdmin(admin.ModelAdmin):
+    list_display = ['element', 'submitter_name', 'comment', 'reviewed',
+                    'hidden', 'date']
+    search_fields = ['comment']
+    date_hierarchy = 'date'
+    list_filter = ['date', 'submitter_name']
+    search_fields = ['title', 'submitter_name', 'submitter_url']
+    fields = (
+        (None, {'fields': ('submitter_name', 'element', 'comment')}),
+        ('Review and presentation state',
+         {'fields': ('reviewed', 'hidden')}),
+        ('Other info', {'fields': ('date', 'submitter_url', 'ip')}),
+        )
+
+class ElementAdmin(admin.ModelAdmin):
+    search_fields = ['id', 'chapter']
+    list_filter = ['chapter', 'title']
+
+admin.site.register(Comment, CommentAdmin)
+admin.site.register(Element, ElementAdmin)
--- a/web/hgbook/comments/models.py	Tue Mar 31 08:58:45 2009 -0700
+++ b/web/hgbook/comments/models.py	Tue Mar 31 09:04:23 2009 -0700
@@ -4,10 +4,6 @@
 mutable = True
 
 class Element(models.Model):
-    class Admin:
-        search_fields = ['id', 'chapter']
-        list_filter = ['chapter', 'title']
-
     id = models.CharField('ID attribute', max_length=64, editable=False,
                           primary_key=True)
     chapter = models.CharField('Chapter ID', max_length=64, editable=False,
@@ -18,20 +14,6 @@
         return self.id
     
 class Comment(models.Model):
-    class Admin:
-        list_display = ['element', 'submitter_name', 'comment', 'reviewed',
-                        'hidden', 'date']
-        search_fields = ['comment']
-        date_hierarchy = 'date'
-        list_filter = ['date', 'submitter_name']
-        search_fields = ['title', 'submitter_name', 'submitter_url']
-        fields = (
-            (None, {'fields': ('submitter_name', 'element', 'comment')}),
-            ('Review and presentation state',
-             {'fields': ('reviewed', 'hidden')}),
-            ('Other info', {'fields': ('date', 'submitter_url', 'ip')}),
-            )
-            
     element = models.ForeignKey(Element,
         help_text='ID of paragraph that was commented on')
     comment = models.TextField(editable=mutable,