comparison gpp/forums/admin.py @ 204:b4305e18d3af

Resolve ticket #74. Add user badges. Some extra credit was done here: also refactored how pending news, links, and downloads are handled.
author Brian Neal <bgneal@gmail.com>
date Sat, 01 May 2010 21:53:59 +0000
parents 500e5875a306
children 272d3a8c98e8
comparison
equal deleted inserted replaced
203:40e5903903e1 204:b4305e18d3af
7 from forums.models import Forum 7 from forums.models import Forum
8 from forums.models import Topic 8 from forums.models import Topic
9 from forums.models import Post 9 from forums.models import Post
10 from forums.models import FlaggedPost 10 from forums.models import FlaggedPost
11 from forums.models import TopicLastVisit 11 from forums.models import TopicLastVisit
12 import bio.badges
12 13
13 14
14 class CategoryAdmin(admin.ModelAdmin): 15 class CategoryAdmin(admin.ModelAdmin):
15 list_display = ('name', 'position', ) 16 list_display = ('name', 'position', )
16 prepopulated_fields = { 'slug': ('name', ) } 17 prepopulated_fields = { 'slug': ('name', ) }
45 save_on_top = True 46 save_on_top = True
46 47
47 48
48 class FlaggedPostAdmin(admin.ModelAdmin): 49 class FlaggedPostAdmin(admin.ModelAdmin):
49 list_display = ('__unicode__', 'flag_date', 'get_post_url') 50 list_display = ('__unicode__', 'flag_date', 'get_post_url')
51 actions = ('accept_flags', )
52
53 def accept_flags(self, request, qs):
54 """This admin action awards a security pin to the user who reported
55 the post and then deletes the flagged post object.
56 """
57 for flag in qs:
58 bio.badges.award_badge(bio.badges.SECURITY_PIN, flag.user)
59 flag.delete()
60
61 accept_flags.short_description = "Accept selected flagged posts"
50 62
51 63
52 class TopicLastVisitAdmin(admin.ModelAdmin): 64 class TopicLastVisitAdmin(admin.ModelAdmin):
53 raw_id_fields = ('user', 'topic') 65 raw_id_fields = ('user', 'topic')
54 list_display = ('user', 'topic', 'last_visit') 66 list_display = ('user', 'topic', 'last_visit')