fix some problems with the creation of new users

This commit is contained in:
Oskar Hahn 2012-08-11 11:09:20 +02:00
parent f01fe5a894
commit cdf160dfc3
3 changed files with 5 additions and 3 deletions

View File

@ -24,8 +24,8 @@ class UserCreateForm(forms.ModelForm, CssClassMixin):
first_name = forms.CharField(label=_("First name")) first_name = forms.CharField(label=_("First name"))
last_name = forms.CharField(label=_("Last name")) last_name = forms.CharField(label=_("Last name"))
groups = forms.ModelMultipleChoiceField( groups = forms.ModelMultipleChoiceField(
queryset=OpenSlidesGroup.objects.all(), label=_("User groups"), queryset=OpenSlidesGroup.objects.exclude(name__iexact='anonymous'),
required=False) label=_("User groups"), required=False)
is_active = forms.BooleanField( is_active = forms.BooleanField(
label=_("Active"), required=False, initial=True) label=_("Active"), required=False, initial=True)

View File

@ -28,6 +28,7 @@ from reportlab.platypus import (
from django.contrib import messages from django.contrib import messages
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.contrib.auth.forms import PasswordChangeForm from django.contrib.auth.forms import PasswordChangeForm
from django.contrib.auth.models import User
from django.contrib.auth.views import login as django_login from django.contrib.auth.views import login as django_login
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.shortcuts import redirect from django.shortcuts import redirect
@ -143,7 +144,7 @@ class UserCreateView(CreateView):
context_object_name = 'edit_user' context_object_name = 'edit_user'
form_class = UserCreateForm form_class = UserCreateForm
success_url = 'user_overview' success_url = 'user_overview'
apply_url = 'participant_edit' apply_url = 'user_edit'
def manipulate_object(self, form): def manipulate_object(self, form):
self.object.username = gen_username(form.cleaned_data['first_name'], self.object.username = gen_username(form.cleaned_data['first_name'],

View File

@ -256,6 +256,7 @@ class CreateView(PermissionMixin, _CreateView):
self.object = form.save(commit=False) self.object = form.save(commit=False)
self.manipulate_object(form) self.manipulate_object(form)
self.object.save() self.object.save()
form.save_m2m()
return HttpResponseRedirect(self.get_success_url()) return HttpResponseRedirect(self.get_success_url())
def get_success_message(self): def get_success_message(self):