Mercurial > public > sg101
comparison bio/views.py @ 766:22d158ef2217
More bio unit tests.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 19 Jan 2014 21:26:42 -0600 |
parents | ee87ea74d46b |
children | cd3343abca9d |
comparison
equal
deleted
inserted
replaced
765:f01bc9500aef | 766:22d158ef2217 |
---|---|
93 @login_required | 93 @login_required |
94 def view_profile(request, username): | 94 def view_profile(request, username): |
95 | 95 |
96 user = get_object_or_404(User, username=username) | 96 user = get_object_or_404(User, username=username) |
97 if user == request.user: | 97 if user == request.user: |
98 return HttpResponseRedirect(reverse('bio.views.my_profile')) | 98 return HttpResponseRedirect(reverse('bio-me')) |
99 | 99 |
100 profile = user.get_profile() | 100 profile = user.get_profile() |
101 hide_email = profile.hide_email | 101 hide_email = profile.hide_email |
102 | 102 |
103 badge_collection = BadgeOwnership.objects.filter( | 103 badge_collection = BadgeOwnership.objects.filter( |
116 | 116 |
117 @login_required | 117 @login_required |
118 def edit_profile(request): | 118 def edit_profile(request): |
119 if request.method == 'POST': | 119 if request.method == 'POST': |
120 if request.POST.get('submit_button', 'Cancel') == 'Cancel': | 120 if request.POST.get('submit_button', 'Cancel') == 'Cancel': |
121 return HttpResponseRedirect(reverse('bio.views.my_profile')) | 121 return HttpResponseRedirect(reverse('bio-me')) |
122 profile = request.user.get_profile() | 122 profile = request.user.get_profile() |
123 user_form = EditUserForm(request.POST, instance=request.user) | 123 user_form = EditUserForm(request.POST, instance=request.user) |
124 profile_form = EditUserProfileForm(request.POST, instance=profile) | 124 profile_form = EditUserProfileForm(request.POST, instance=profile) |
125 if user_form.is_valid() and profile_form.is_valid(): | 125 if user_form.is_valid() and profile_form.is_valid(): |
126 user_form.save() | 126 user_form.save() |
127 profile = profile_form.save(commit=False) | 127 profile = profile_form.save(commit=False) |
128 profile.user = request.user | 128 profile.user = request.user |
129 profile.save() | 129 profile.save() |
130 return HttpResponseRedirect(reverse('bio.views.my_profile')) | 130 return HttpResponseRedirect(reverse('bio-me')) |
131 else: | 131 else: |
132 profile = request.user.get_profile() | 132 profile = request.user.get_profile() |
133 user_form = EditUserForm(instance=request.user) | 133 user_form = EditUserForm(instance=request.user) |
134 profile_form = EditUserProfileForm(instance=profile) | 134 profile_form = EditUserProfileForm(instance=profile) |
135 | 135 |