diff gpp/bio/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 152d77265da6
children 8bbefaa3e408
line wrap: on
line diff
--- a/gpp/bio/admin.py	Wed Apr 28 03:00:31 2010 +0000
+++ b/gpp/bio/admin.py	Sat May 01 21:53:59 2010 +0000
@@ -4,13 +4,17 @@
 import datetime
 
 from django.contrib import admin
-from bio.models import UserProfile
-from bio.models import UserProfileFlag
+
 import bio.models
 from comments.models import Comment
 from forums.tools import delete_user_posts
 
 
+class BadgeOwnerInline(admin.TabularInline):
+    model = bio.models.BadgeOwnership
+    extra = 1
+
+
 class UserProfileAdmin(admin.ModelAdmin):
     search_fields = ('user__username', 'user__first_name', 'user__last_name',
             'user__email')
@@ -18,6 +22,7 @@
     list_display = ('__unicode__', 'get_status_display', 'status_date')
     list_filter = ('status', )
     date_hierarchy = 'status_date'
+    inlines = (BadgeOwnerInline, )
     actions = (
         'mark_active', 
         'mark_resigned',
@@ -93,5 +98,11 @@
     list_display = ('__unicode__', 'flag_date', 'get_profile_url')
 
 
-admin.site.register(UserProfile, UserProfileAdmin)
-admin.site.register(UserProfileFlag, UserProfileFlagAdmin)
+class BadgeAdmin(admin.ModelAdmin):
+    list_display = ('name', 'html', 'order', 'numeric_id', 'description')
+    list_editable = ('order', 'numeric_id')
+
+
+admin.site.register(bio.models.UserProfile, UserProfileAdmin)
+admin.site.register(bio.models.UserProfileFlag, UserProfileFlagAdmin)
+admin.site.register(bio.models.Badge, BadgeAdmin)