diff gpp/shoutbox/admin.py @ 151:e1d1a70d312d

Implement #43, various shoutbox improvements.
author Brian Neal <bgneal@gmail.com>
date Fri, 18 Dec 2009 04:30:49 +0000
parents 777451a98f9d
children
line wrap: on
line diff
--- a/gpp/shoutbox/admin.py	Thu Dec 17 04:14:16 2009 +0000
+++ b/gpp/shoutbox/admin.py	Fri Dec 18 04:30:49 2009 +0000
@@ -6,14 +6,29 @@
 from shoutbox.models import ShoutFlag
 
 class ShoutAdmin(admin.ModelAdmin):
-    list_display = ('shout_date', '__unicode__')
+    list_display = ('__unicode__', 'user', 'shout_date')
     raw_id_fields = ('user', )
+    date_hierarchy = 'shout_date'
+    exclude = ('html', )
+    search_fields = ('shout', 'user__username')
+    list_filter = ('shout_date', )
+
 
 class ShoutFlagAdmin(admin.ModelAdmin):
-    list_display = ('__unicode__', 'flag_date', 'get_shout_url')
+    list_display = ('__unicode__', 'flag_date', 'shout', 'get_shout_url')
+    actions = ('delete_shouts', )
+
+    def delete_shouts(self, request, qs):
+        """
+        Admin action function to delete the shouts associated with the shout
+        flags.
+        """
+        for flag in qs:
+            flag.shout.delete()     # will delete the flag too
+
+    delete_shouts.short_description = "Delete selected flags & shouts"
 
 
 admin.site.register(Shout, ShoutAdmin)
 admin.site.register(ShoutFlag, ShoutFlagAdmin)
 
-# vim: ts=4 sw=4