gremmie@1: """ gremmie@1: This file contains the automatic admin site definitions for the shoutbox models. gremmie@1: """ gremmie@1: from django.contrib import admin gremmie@1: from shoutbox.models import Shout bgneal@13: from shoutbox.models import ShoutFlag gremmie@1: gremmie@1: class ShoutAdmin(admin.ModelAdmin): bgneal@151: list_display = ('__unicode__', 'user', 'shout_date') bgneal@13: raw_id_fields = ('user', ) bgneal@151: date_hierarchy = 'shout_date' bgneal@151: exclude = ('html', ) bgneal@151: search_fields = ('shout', 'user__username') bgneal@151: list_filter = ('shout_date', ) bgneal@151: bgneal@13: bgneal@13: class ShoutFlagAdmin(admin.ModelAdmin): bgneal@151: list_display = ('__unicode__', 'flag_date', 'shout', 'get_shout_url') bgneal@151: actions = ('delete_shouts', ) bgneal@151: bgneal@151: def delete_shouts(self, request, qs): bgneal@151: """ bgneal@151: Admin action function to delete the shouts associated with the shout bgneal@151: flags. bgneal@151: """ bgneal@151: for flag in qs: bgneal@151: flag.shout.delete() # will delete the flag too bgneal@151: bgneal@151: delete_shouts.short_description = "Delete selected flags & shouts" bgneal@13: gremmie@1: gremmie@1: admin.site.register(Shout, ShoutAdmin) bgneal@13: admin.site.register(ShoutFlag, ShoutFlagAdmin) bgneal@13: