Automated merge with ssh://openslides.org/openslides
This commit is contained in:
commit
9f2929df6b
@ -66,11 +66,10 @@ class Application(models.Model):
|
||||
"""
|
||||
accept a Version
|
||||
"""
|
||||
if version.id > self.permitted.id:
|
||||
self.permitted = version
|
||||
self.save()
|
||||
return True
|
||||
return False
|
||||
self.permitted = version
|
||||
self.save()
|
||||
version.rejected = False
|
||||
version.save()
|
||||
|
||||
def reject_version(self, version):
|
||||
if version.id > self.permitted.id:
|
||||
|
@ -128,7 +128,7 @@ def edit(request, application_id=None):
|
||||
messages.success(request, _('New application was successfully created.'))
|
||||
else:
|
||||
messages.success(request, _('Application was successfully modified.'))
|
||||
|
||||
|
||||
if not 'apply' in request.POST:
|
||||
return redirect(reverse('application_view', args=[application.id]))
|
||||
if application_id is None:
|
||||
@ -362,10 +362,7 @@ def view_poll(request, poll_id):
|
||||
def permit_version(request, aversion_id):
|
||||
aversion = AVersion.objects.get(pk=aversion_id)
|
||||
application = aversion.application
|
||||
if application.accept_version(aversion):
|
||||
messages.success(request, _("Version accepted") )
|
||||
else:
|
||||
messages.error(request, _("ERROR by accepting the Version") )
|
||||
messages.success(request, _("Version accepted") )
|
||||
return redirect(reverse('application_view', args=[application.id]))
|
||||
|
||||
|
||||
|
@ -16,7 +16,18 @@ from django.contrib.auth.forms import AdminPasswordChangeForm
|
||||
from django.utils.translation import ugettext as _
|
||||
from participant.models import Profile
|
||||
|
||||
class UserForm(ModelForm):
|
||||
class UserNewForm(ModelForm):
|
||||
error_css_class = 'error'
|
||||
required_css_class = 'required'
|
||||
|
||||
first_name = CharField(label=_("First name"))
|
||||
last_name = CharField(label=_("Last name"))
|
||||
|
||||
class Meta:
|
||||
model = User
|
||||
exclude = ('username', 'password', 'is_staff', 'last_login', 'date_joined', 'user_permissions')
|
||||
|
||||
class UserEditForm(ModelForm):
|
||||
error_css_class = 'error'
|
||||
required_css_class = 'required'
|
||||
|
||||
@ -49,10 +60,7 @@ class GroupForm(ModelForm):
|
||||
class Meta:
|
||||
model = Group
|
||||
|
||||
class UsersettingsForm(UserForm):
|
||||
error_css_class = 'error'
|
||||
required_css_class = 'required'
|
||||
|
||||
class UsersettingsForm(UserEditForm):
|
||||
class Meta:
|
||||
model = User
|
||||
fields = ('username', 'first_name', 'last_name', 'email')
|
||||
|
@ -23,7 +23,7 @@ from django.utils.translation import ugettext as _
|
||||
|
||||
from participant.models import Profile, set_first_user_passwords
|
||||
from participant.api import gen_username
|
||||
from participant.forms import UserForm, UsernameForm, ProfileForm, UsersettingsForm, UserImportForm, GroupForm, AdminPasswordChangeForm
|
||||
from participant.forms import UserNewForm, UserEditForm, ProfileForm, UsersettingsForm, UserImportForm, GroupForm, AdminPasswordChangeForm
|
||||
from utils.utils import template, permission_required, gen_confirm_form
|
||||
from utils.pdf import print_userlist, print_passwords
|
||||
|
||||
@ -81,19 +81,18 @@ def edit(request, user_id=None):
|
||||
user = None
|
||||
|
||||
if request.method == 'POST':
|
||||
userform = UserForm(request.POST, instance=user, prefix="user")
|
||||
try:
|
||||
profileform = ProfileForm(request.POST, instance=user.profile, prefix="profile")
|
||||
except:
|
||||
if user_id is None:
|
||||
userform = UserNewForm(request.POST, prefix="user")
|
||||
profileform = ProfileForm(request.POST, prefix="profile")
|
||||
else:
|
||||
userform = UserEditForm(request.POST, instance=user, prefix="user")
|
||||
profileform = ProfileForm(request.POST, instance=user.profile, prefix="profile")
|
||||
|
||||
formlist = [userform, profileform]
|
||||
formerror = 0
|
||||
for f in formlist:
|
||||
if not f.is_valid():
|
||||
formerror += 1
|
||||
if formerror == 0:
|
||||
if userform.is_valid and profileform.is_valid:
|
||||
user = userform.save()
|
||||
if user_id is None:
|
||||
user.username = gen_username(user.first_name, user.last_name)
|
||||
user.save()
|
||||
profile = profileform.save(commit=False)
|
||||
profile.user = user
|
||||
profile.save()
|
||||
@ -108,11 +107,13 @@ def edit(request, user_id=None):
|
||||
else:
|
||||
messages.error(request, _('Please check the form for errors.'))
|
||||
else:
|
||||
userform = UserForm(instance=user, prefix="user")
|
||||
try:
|
||||
profileform = ProfileForm(instance=user.profile, prefix="profile")
|
||||
except AttributeError:
|
||||
if user_id is None:
|
||||
userform = UserNewForm(prefix="user")
|
||||
profileform = ProfileForm(prefix="profile")
|
||||
else:
|
||||
userform = UserEditForm(instance=user, prefix="user")
|
||||
profileform = ProfileForm(instance=user.profile, prefix="profile")
|
||||
|
||||
return {
|
||||
'userform': userform,
|
||||
'profileform': profileform,
|
||||
|
Loading…
Reference in New Issue
Block a user