diff 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
line wrap: on
line diff
--- a/gpp/forums/admin.py	Wed Apr 28 03:00:31 2010 +0000
+++ b/gpp/forums/admin.py	Sat May 01 21:53:59 2010 +0000
@@ -9,6 +9,7 @@
 from forums.models import Post
 from forums.models import FlaggedPost
 from forums.models import TopicLastVisit
+import bio.badges
 
 
 class CategoryAdmin(admin.ModelAdmin):
@@ -47,6 +48,17 @@
 
 class FlaggedPostAdmin(admin.ModelAdmin):
     list_display = ('__unicode__', 'flag_date', 'get_post_url')
+    actions = ('accept_flags', )
+
+    def accept_flags(self, request, qs):
+        """This admin action awards a security pin to the user who reported
+        the post and then deletes the flagged post object.
+        """
+        for flag in qs:
+            bio.badges.award_badge(bio.badges.SECURITY_PIN, flag.user)
+            flag.delete()
+
+    accept_flags.short_description = "Accept selected flagged posts"
 
 
 class TopicLastVisitAdmin(admin.ModelAdmin):