comparison 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
comparison
equal deleted inserted replaced
203:40e5903903e1 204:b4305e18d3af
19 from elsewhere.models import InstantMessengerForm 19 from elsewhere.models import InstantMessengerForm
20 from elsewhere.models import WebsiteForm 20 from elsewhere.models import WebsiteForm
21 21
22 from bio.models import UserProfile 22 from bio.models import UserProfile
23 from bio.models import UserProfileFlag 23 from bio.models import UserProfileFlag
24 from bio.models import BadgeOwnership
24 from bio.forms import UploadAvatarForm 25 from bio.forms import UploadAvatarForm
25 from bio.forms import EditUserForm 26 from bio.forms import EditUserForm
26 from bio.forms import EditUserProfileForm 27 from bio.forms import EditUserProfileForm
27 from bio.forms import SearchUsersForm 28 from bio.forms import SearchUsersForm
28 from core.paginator import DiggPaginator 29 from core.paginator import DiggPaginator
68 ####################################################################### 69 #######################################################################
69 70
70 @login_required 71 @login_required
71 def my_profile(request): 72 def my_profile(request):
72 profile = request.user.get_profile() 73 profile = request.user.get_profile()
74 badge_collection = BadgeOwnership.objects.filter(
75 profile=profile).select_related("badge")
73 76
74 return render_to_response('bio/view_profile.html', { 77 return render_to_response('bio/view_profile.html', {
75 'subject': request.user, 78 'subject': request.user,
76 'profile': profile, 79 'profile': profile,
77 'hide_email': False, 80 'hide_email': False,
78 'this_is_me': True, 81 'this_is_me': True,
82 'badge_collection': badge_collection,
79 }, 83 },
80 context_instance = RequestContext(request)) 84 context_instance = RequestContext(request))
81 85
82 ####################################################################### 86 #######################################################################
83 87
87 user = get_object_or_404(auth.models.User, username = username) 91 user = get_object_or_404(auth.models.User, username = username)
88 if user == request.user: 92 if user == request.user:
89 return HttpResponseRedirect(reverse('bio.views.my_profile')) 93 return HttpResponseRedirect(reverse('bio.views.my_profile'))
90 94
91 profile = user.get_profile() 95 profile = user.get_profile()
92 96 hide_email = profile.hide_email
93 # work around MySQL's handling of Boolean 97
94 hide_email = bool(profile.hide_email) 98 badge_collection = BadgeOwnership.objects.filter(
99 profile=profile).select_related("badge")
95 100
96 return render_to_response('bio/view_profile.html', { 101 return render_to_response('bio/view_profile.html', {
97 'subject': user, 102 'subject': user,
98 'profile': profile, 103 'profile': profile,
99 'hide_email': hide_email, 104 'hide_email': hide_email,
100 'this_is_me': False, 105 'this_is_me': False,
106 'badge_collection': badge_collection,
101 }, 107 },
102 context_instance = RequestContext(request)) 108 context_instance = RequestContext(request))
103 109
104 ####################################################################### 110 #######################################################################
105 111