diff gpp/bio/views.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 d51743322bb2
children 7ddd60164245
line wrap: on
line diff
--- a/gpp/bio/views.py	Wed Apr 28 03:00:31 2010 +0000
+++ b/gpp/bio/views.py	Sat May 01 21:53:59 2010 +0000
@@ -21,6 +21,7 @@
 
 from bio.models import UserProfile
 from bio.models import UserProfileFlag
+from bio.models import BadgeOwnership
 from bio.forms import UploadAvatarForm
 from bio.forms import EditUserForm
 from bio.forms import EditUserProfileForm
@@ -70,12 +71,15 @@
 @login_required
 def my_profile(request):
     profile = request.user.get_profile()
+    badge_collection = BadgeOwnership.objects.filter(
+            profile=profile).select_related("badge")
 
     return render_to_response('bio/view_profile.html', {
         'subject': request.user, 
         'profile': profile, 
         'hide_email': False,
         'this_is_me': True,
+        'badge_collection': badge_collection,
         }, 
         context_instance = RequestContext(request))
 
@@ -89,15 +93,17 @@
         return HttpResponseRedirect(reverse('bio.views.my_profile'))
 
     profile = user.get_profile()
+    hide_email = profile.hide_email
 
-    # work around MySQL's handling of Boolean
-    hide_email = bool(profile.hide_email)
+    badge_collection = BadgeOwnership.objects.filter(
+            profile=profile).select_related("badge")
     
     return render_to_response('bio/view_profile.html', {
         'subject': user, 
         'profile': profile, 
         'hide_email': hide_email,
         'this_is_me': False,
+        'badge_collection': badge_collection,
         }, 
         context_instance = RequestContext(request))