commit
4f9041df65
@ -35,7 +35,7 @@ def gen_username(first_name, last_name):
|
||||
"""
|
||||
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:
|
||||
User.objects.get(username=testname)
|
||||
except User.DoesNotExist:
|
||||
@ -43,7 +43,7 @@ def gen_username(first_name, last_name):
|
||||
i = 0
|
||||
while True:
|
||||
i += 1
|
||||
testname = "%s %s %s" % (first_name, last_name, i)
|
||||
testname = "%s_%s_%s" % (first_name, last_name, i)
|
||||
try:
|
||||
User.objects.get(username=testname)
|
||||
except User.DoesNotExist:
|
||||
|
@ -62,8 +62,11 @@ class UserUpdateForm(UserCreateForm):
|
||||
Raises a validation error, if a non-superuser user edits himself
|
||||
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:
|
||||
protected_perm = Permission.objects.get(content_type=ContentType.objects.get(app_label='participant', model='user'),
|
||||
protected_perm = Permission.objects.get(
|
||||
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():
|
||||
error_msg = _('You can not remove the last group containing the permission to manage participants.')
|
||||
|
Loading…
Reference in New Issue
Block a user