Fixed username
This commit is contained in:
parent
38558e9b03
commit
6b558907c0
@ -35,7 +35,7 @@ def gen_username(first_name, last_name):
|
|||||||
"""
|
"""
|
||||||
generates the username for new users.
|
generates the username for new users.
|
||||||
"""
|
"""
|
||||||
testname = "%s %s" % (first_name.strip(), last_name.strip())
|
testname = "%s_%s" % (first_name.strip(), last_name.strip())
|
||||||
try:
|
try:
|
||||||
User.objects.get(username=testname)
|
User.objects.get(username=testname)
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
@ -43,7 +43,7 @@ def gen_username(first_name, last_name):
|
|||||||
i = 0
|
i = 0
|
||||||
while True:
|
while True:
|
||||||
i += 1
|
i += 1
|
||||||
testname = "%s %s %s" % (first_name, last_name, i)
|
testname = "%s_%s_%s" % (first_name, last_name, i)
|
||||||
try:
|
try:
|
||||||
User.objects.get(username=testname)
|
User.objects.get(username=testname)
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
|
@ -62,9 +62,12 @@ class UserUpdateForm(UserCreateForm):
|
|||||||
Raises a validation error, if a non-superuser user edits himself
|
Raises a validation error, if a non-superuser user edits himself
|
||||||
and removes the last group containing the permission to manage participants.
|
and removes the last group containing the permission to manage participants.
|
||||||
"""
|
"""
|
||||||
|
# TODO: Check this in clean_groups
|
||||||
if self.request.user == self.instance and not self.instance.is_superuser:
|
if self.request.user == self.instance and not self.instance.is_superuser:
|
||||||
protected_perm = Permission.objects.get(content_type=ContentType.objects.get(app_label='participant', model='user'),
|
protected_perm = Permission.objects.get(
|
||||||
codename='can_manage_participant')
|
content_type=ContentType.objects.get(app_label='participant',
|
||||||
|
model='user'),
|
||||||
|
codename='can_manage_participant')
|
||||||
if not self.cleaned_data['groups'].filter(permissions__in=[protected_perm]).exists():
|
if not self.cleaned_data['groups'].filter(permissions__in=[protected_perm]).exists():
|
||||||
error_msg = _('You can not remove the last group containing the permission to manage participants.')
|
error_msg = _('You can not remove the last group containing the permission to manage participants.')
|
||||||
messages.error(self.request, error_msg)
|
messages.error(self.request, error_msg)
|
||||||
|
Loading…
Reference in New Issue
Block a user