Skip to content

Commit e4b211e

Browse files
kyriasjelly
authored andcommitted
Allow users to set their own names
Users should be able to set their own names as they see fit, since names change for any number of reasons, and there's no sense in allowing them to be registered with whatever name they give but then require DevOps to update it if it for whatever reason needs to be updated. This will hopefully also lead to a better visibility of the latin name field, allowing staff members whose names are properly written in non-latin scripts to have their names properly represented. Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
1 parent 403dc9e commit e4b211e

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

devel/forms.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ class ProfileForm(forms.Form):
1919
label='New Password', required=False, widget=forms.PasswordInput)
2020
passwd2 = forms.CharField(
2121
label='Confirm Password', required=False, widget=forms.PasswordInput)
22+
first_name = forms.CharField(
23+
label='First name', required=True)
24+
last_name = forms.CharField(
25+
label='Last name', required=False)
2226

2327
def clean(self):
2428
if self.cleaned_data['passwd1'] != self.cleaned_data['passwd2']:
@@ -36,7 +40,7 @@ def clean_pgp_key(self):
3640

3741
class Meta:
3842
model = UserProfile
39-
exclude = ('allowed_repos', 'user', 'latin_name', 'repos_auth_token')
43+
exclude = ('allowed_repos', 'user', 'repos_auth_token')
4044

4145

4246
class NewUserForm(forms.ModelForm):

devel/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515

1616
class UserProfile(models.Model):
17+
latin_name = models.CharField(
18+
max_length=255, null=True, blank=True, help_text="Latin-form name; used only for non-Latin full names")
1719
notify = models.BooleanField(
1820
"Send notifications",
1921
default=True,
@@ -49,8 +51,6 @@ class UserProfile(models.Model):
4951
upload_to='devs', default='devs/silhouette.png', help_text="Ideally 125px by 125px")
5052
user = models.OneToOneField(User, related_name='userprofile', on_delete=models.CASCADE)
5153
allowed_repos = models.ManyToManyField('main.Repo', blank=True)
52-
latin_name = models.CharField(
53-
max_length=255, null=True, blank=True, help_text="Latin-form name; used only for non-Latin full names")
5454
rebuilderd_updates = models.BooleanField(
5555
default=False, help_text='Receive reproducible build package updates')
5656
repos_auth_token = models.CharField(max_length=32, null=True, blank=True)

devel/views.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,11 @@ def change_profile(request):
247247

248248
return HttpResponseRedirect('/devel/')
249249
else:
250-
form = ProfileForm(initial={'email': request.user.email})
250+
form = ProfileForm(initial={
251+
'email': request.user.email,
252+
'first_name': request.user.first_name,
253+
'last_name': request.user.last_name,
254+
})
251255
profile_form = UserProfileForm(instance=profile)
252256
return render(request, 'devel/profile.html',
253257
{'form': form,

0 commit comments

Comments
 (0)