summaryrefslogtreecommitdiff
path: root/devel/views.py
diff options
context:
space:
mode:
authorAngel Velasquez <angvp@archlinux.org>2010-09-17 17:35:24 -0300
committerDan McGee <dan@archlinux.org>2010-10-05 15:11:50 -0500
commitd6d9a08e63f2e8bfcd997eab396c65dc3b7a2918 (patch)
tree3ac7692af8757ec52d9fd159217b801ef8e3c948 /devel/views.py
parentd66d0e4300052933a6bfaa016114dc6a68708905 (diff)
Adding changing of user profile details
The idea of this patch is allow to the developers who have an account, to change their data without asking some admin to do it for them. Dan: put private email address field back as it is used for a different purpose; add some help text and field names as appropriate. Signed-off-by: Angel Velasquez <angvp@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'devel/views.py')
-rw-r--r--devel/views.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/devel/views.py b/devel/views.py
index 577a00c4..381b4a4a 100644
--- a/devel/views.py
+++ b/devel/views.py
@@ -52,7 +52,8 @@ def change_notify(request):
return HttpResponseRedirect('/devel/')
class ProfileForm(forms.Form):
- email = forms.EmailField(label='E-mail Address')
+ email = forms.EmailField(label='Private email (not shown publicly):',
+ help_text="Used for out of date notifications, etc.")
passwd1 = forms.CharField(label='New Password', required=False,
widget=forms.PasswordInput)
passwd2 = forms.CharField(label='Confirm Password', required=False,
@@ -63,20 +64,29 @@ class ProfileForm(forms.Form):
raise forms.ValidationError('Passwords do not match.')
return self.cleaned_data
+class UserProfileForm(forms.ModelForm):
+ class Meta:
+ model = UserProfile
+ exclude = ['allowed_repos', 'user']
+
@login_required
@never_cache
def change_profile(request):
if request.POST:
form = ProfileForm(request.POST)
- if form.is_valid():
+ profile_form = UserProfileForm(data=request.POST, instance=request.user.get_profile())
+ if form.is_valid() and profile_form.is_valid():
request.user.email = form.cleaned_data['email']
if form.cleaned_data['passwd1']:
request.user.set_password(form.cleaned_data['passwd1'])
request.user.save()
+ profile_form.save()
return HttpResponseRedirect('/devel/')
else:
form = ProfileForm(initial={'email': request.user.email})
- return direct_to_template(request, 'devel/profile.html', {'form': form})
+ profile_form = UserProfileForm(instance=request.user.get_profile())
+ return direct_to_template(request, 'devel/profile.html',
+ {'form': form, 'profile_form': profile_form})
class NewUserForm(forms.ModelForm):
class Meta: