summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--devel/views.py16
-rw-r--r--main/models.py5
-rw-r--r--templates/devel/profile.html9
3 files changed, 24 insertions, 6 deletions
diff --git a/devel/views.py b/devel/views.py
index 577a00c..381b4a4 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:
diff --git a/main/models.py b/main/models.py
index 10a7737..dc700fb 100644
--- a/main/models.py
+++ b/main/models.py
@@ -19,14 +19,15 @@ class UserProfile(models.Model):
help_text="Required field")
other_contact = models.CharField(max_length=100, null=True, blank=True)
website = models.CharField(max_length=200, null=True, blank=True)
- yob = models.IntegerField(null=True, blank=True)
+ yob = models.IntegerField("Year of birth", null=True, blank=True)
location = models.CharField(max_length=50, null=True, blank=True)
languages = models.CharField(max_length=50, null=True, blank=True)
interests = models.CharField(max_length=255, null=True, blank=True)
occupation = models.CharField(max_length=50, null=True, blank=True)
roles = models.CharField(max_length=255, null=True, blank=True)
favorite_distros = models.CharField(max_length=255, null=True, blank=True)
- picture = models.FileField(upload_to='devs', default='devs/silhouette.png')
+ picture = models.FileField(upload_to='devs', default='devs/silhouette.png',
+ help_text="Ideally 125px by 125px")
user = models.OneToOneField(User, related_name='userprofile')
allowed_repos = models.ManyToManyField('Repo', blank=True)
class Meta:
diff --git a/templates/devel/profile.html b/templates/devel/profile.html
index 0dde934..4da6dad 100644
--- a/templates/devel/profile.html
+++ b/templates/devel/profile.html
@@ -7,10 +7,17 @@
<h2>Developer Profile</h2>
<form id="edit-profile-form" method="post">{% csrf_token %}
+ <p><em>Note:</em> This is the public information shown on the developer
+ and/or TU profiles page, so please be appropriate with the information
+ you provide here.</p>
<fieldset>
- <legend>Username: <strong>{{ user.username }}</strong></legend>
+ <p><label>Username:</label>
+ <strong>{{ user.username }}</strong></p>
{{ form.as_p }}
</fieldset>
+ <fieldset>
+ {{ profile_form.as_p }}
+ </fieldset>
<p><label></label> <input title="Save changes" type="submit" value="Save" /></p>
</form>