Automated merge with ssh://openslides.org/openslides

This commit is contained in:
Emanuel Schuetze 2011-09-04 10:21:11 +02:00
commit 9f2929df6b
4 changed files with 35 additions and 30 deletions

View File

@ -66,11 +66,10 @@ class Application(models.Model):
""" """
accept a Version accept a Version
""" """
if version.id > self.permitted.id: self.permitted = version
self.permitted = version self.save()
self.save() version.rejected = False
return True version.save()
return False
def reject_version(self, version): def reject_version(self, version):
if version.id > self.permitted.id: if version.id > self.permitted.id:

View File

@ -362,10 +362,7 @@ def view_poll(request, poll_id):
def permit_version(request, aversion_id): def permit_version(request, aversion_id):
aversion = AVersion.objects.get(pk=aversion_id) aversion = AVersion.objects.get(pk=aversion_id)
application = aversion.application application = aversion.application
if application.accept_version(aversion): messages.success(request, _("Version accepted") )
messages.success(request, _("Version accepted") )
else:
messages.error(request, _("ERROR by accepting the Version") )
return redirect(reverse('application_view', args=[application.id])) return redirect(reverse('application_view', args=[application.id]))

View File

@ -16,7 +16,18 @@ from django.contrib.auth.forms import AdminPasswordChangeForm
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from participant.models import Profile 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' error_css_class = 'error'
required_css_class = 'required' required_css_class = 'required'
@ -49,10 +60,7 @@ class GroupForm(ModelForm):
class Meta: class Meta:
model = Group model = Group
class UsersettingsForm(UserForm): class UsersettingsForm(UserEditForm):
error_css_class = 'error'
required_css_class = 'required'
class Meta: class Meta:
model = User model = User
fields = ('username', 'first_name', 'last_name', 'email') fields = ('username', 'first_name', 'last_name', 'email')

View File

@ -23,7 +23,7 @@ from django.utils.translation import ugettext as _
from participant.models import Profile, set_first_user_passwords from participant.models import Profile, set_first_user_passwords
from participant.api import gen_username 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.utils import template, permission_required, gen_confirm_form
from utils.pdf import print_userlist, print_passwords from utils.pdf import print_userlist, print_passwords
@ -81,19 +81,18 @@ def edit(request, user_id=None):
user = None user = None
if request.method == 'POST': if request.method == 'POST':
userform = UserForm(request.POST, instance=user, prefix="user") if user_id is None:
try: userform = UserNewForm(request.POST, prefix="user")
profileform = ProfileForm(request.POST, instance=user.profile, prefix="profile")
except:
profileform = ProfileForm(request.POST, prefix="profile") 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] if userform.is_valid and profileform.is_valid:
formerror = 0
for f in formlist:
if not f.is_valid():
formerror += 1
if formerror == 0:
user = userform.save() 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 = profileform.save(commit=False)
profile.user = user profile.user = user
profile.save() profile.save()
@ -108,11 +107,13 @@ def edit(request, user_id=None):
else: else:
messages.error(request, _('Please check the form for errors.')) messages.error(request, _('Please check the form for errors.'))
else: else:
userform = UserForm(instance=user, prefix="user") if user_id is None:
try: userform = UserNewForm(prefix="user")
profileform = ProfileForm(instance=user.profile, prefix="profile")
except AttributeError:
profileform = ProfileForm(prefix="profile") profileform = ProfileForm(prefix="profile")
else:
userform = UserEditForm(instance=user, prefix="user")
profileform = ProfileForm(instance=user.profile, prefix="profile")
return { return {
'userform': userform, 'userform': userform,
'profileform': profileform, 'profileform': profileform,