Mercurial > public > sg101
comparison 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 |
comparison
equal
deleted
inserted
replaced
150:b43e1288ff80 | 151:e1d1a70d312d |
---|---|
4 from django.contrib import admin | 4 from django.contrib import admin |
5 from shoutbox.models import Shout | 5 from shoutbox.models import Shout |
6 from shoutbox.models import ShoutFlag | 6 from shoutbox.models import ShoutFlag |
7 | 7 |
8 class ShoutAdmin(admin.ModelAdmin): | 8 class ShoutAdmin(admin.ModelAdmin): |
9 list_display = ('shout_date', '__unicode__') | 9 list_display = ('__unicode__', 'user', 'shout_date') |
10 raw_id_fields = ('user', ) | 10 raw_id_fields = ('user', ) |
11 date_hierarchy = 'shout_date' | |
12 exclude = ('html', ) | |
13 search_fields = ('shout', 'user__username') | |
14 list_filter = ('shout_date', ) | |
15 | |
11 | 16 |
12 class ShoutFlagAdmin(admin.ModelAdmin): | 17 class ShoutFlagAdmin(admin.ModelAdmin): |
13 list_display = ('__unicode__', 'flag_date', 'get_shout_url') | 18 list_display = ('__unicode__', 'flag_date', 'shout', 'get_shout_url') |
19 actions = ('delete_shouts', ) | |
20 | |
21 def delete_shouts(self, request, qs): | |
22 """ | |
23 Admin action function to delete the shouts associated with the shout | |
24 flags. | |
25 """ | |
26 for flag in qs: | |
27 flag.shout.delete() # will delete the flag too | |
28 | |
29 delete_shouts.short_description = "Delete selected flags & shouts" | |
14 | 30 |
15 | 31 |
16 admin.site.register(Shout, ShoutAdmin) | 32 admin.site.register(Shout, ShoutAdmin) |
17 admin.site.register(ShoutFlag, ShoutFlagAdmin) | 33 admin.site.register(ShoutFlag, ShoutFlagAdmin) |
18 | 34 |
19 # vim: ts=4 sw=4 |