Mercurial > public > sg101
comparison shoutbox/admin.py @ 581:ee87ea74d46b
For Django 1.4, rearranged project structure for new manage.py.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 05 May 2012 17:10:48 -0500 |
parents | gpp/shoutbox/admin.py@e1d1a70d312d |
children |
comparison
equal
deleted
inserted
replaced
580:c525f3e0b5d0 | 581:ee87ea74d46b |
---|---|
1 """ | |
2 This file contains the automatic admin site definitions for the shoutbox models. | |
3 """ | |
4 from django.contrib import admin | |
5 from shoutbox.models import Shout | |
6 from shoutbox.models import ShoutFlag | |
7 | |
8 class ShoutAdmin(admin.ModelAdmin): | |
9 list_display = ('__unicode__', 'user', 'shout_date') | |
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 | |
16 | |
17 class ShoutFlagAdmin(admin.ModelAdmin): | |
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" | |
30 | |
31 | |
32 admin.site.register(Shout, ShoutAdmin) | |
33 admin.site.register(ShoutFlag, ShoutFlagAdmin) | |
34 |