From 6b558907c05272392e2a77ad79b54fefe730776e Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Fri, 19 Apr 2013 16:45:18 +0200 Subject: [PATCH] Fixed username --- openslides/participant/api.py | 4 ++-- openslides/participant/forms.py | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/openslides/participant/api.py b/openslides/participant/api.py index 433dc2fc3..8c0bd94ed 100644 --- a/openslides/participant/api.py +++ b/openslides/participant/api.py @@ -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: diff --git a/openslides/participant/forms.py b/openslides/participant/forms.py index bd50ac5a9..0b6053953 100644 --- a/openslides/participant/forms.py +++ b/openslides/participant/forms.py @@ -62,9 +62,12 @@ 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'), - codename='can_manage_participant') + 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.') messages.error(self.request, error_msg)