Merge pull request #1411 from boehlke/master

Fix #1352 and fix order in motion form.
This commit is contained in:
Norman Jäckel 2015-01-18 09:07:24 +01:00
commit c5a7cc889e
6 changed files with 29 additions and 1 deletions

3
.gitignore vendored
View File

@ -19,12 +19,13 @@ whoosh_index/*
bower_components/* bower_components/*
openslides/static/* openslides/static/*
# Package building # Package building/IDE
docs/_build/* docs/_build/*
*.egg-info *.egg-info
build/* build/*
dist/* dist/*
.DS_Store .DS_Store
.idea
# Unit test and coverage reports # Unit test and coverage reports
.coverage .coverage

View File

@ -14,3 +14,4 @@ Authors of OpenSlides in chronological order of first contribution:
Max Brauer <max@max-brauer.de> Max Brauer <max@max-brauer.de>
Marco A. G. Pinto <marcoagpinto@mail.telepac.pt> (Portuguese translation) Marco A. G. Pinto <marcoagpinto@mail.telepac.pt> (Portuguese translation)
Dominik Breu <dominikbreu@yahoo.de> Dominik Breu <dominikbreu@yahoo.de>
André Böhlke <ab@bcoding.de>

View File

@ -189,6 +189,7 @@ class CustomSlideViewMixin(object):
""" """
Mixin for for CustomSlide Views. Mixin for for CustomSlide Views.
""" """
fields = ('title', 'text', 'weight',)
required_permission = 'core.can_manage_projector' required_permission = 'core.can_manage_projector'
template_name = 'core/customslide_update.html' template_name = 'core/customslide_update.html'
model = CustomSlide model = CustomSlide

View File

@ -38,6 +38,7 @@ class MediafileViewMixin(object):
A manager can set the uploader manually, else the request user is set as uploader. A manager can set the uploader manually, else the request user is set as uploader.
""" """
fields = ('mediafile', 'title', 'uploader', 'is_presentable',)
model = Mediafile model = Mediafile
success_url_name = 'mediafile_list' success_url_name = 'mediafile_list'
url_name_args = [] url_name_args = []

View File

@ -1,3 +1,5 @@
import collections
from django import forms from django import forms
from django.utils.translation import ugettext_lazy from django.utils.translation import ugettext_lazy
@ -51,6 +53,21 @@ class BaseMotionForm(CleanHtmlFormMixin, CssClassMixin, forms.ModelForm):
required=False, required=False,
label=ugettext_lazy('Tags')) label=ugettext_lazy('Tags'))
key_order = ('identifier',
'title',
'text',
'reason',
'submitter',
'supporter',
'category',
'tags',
'attachments',
'workflow',
'disable_versioning',)
"""
Order of fields, including optional fields from mixins (for example MotionSupporterMixin)
"""
class Meta: class Meta:
model = Motion model = Motion
fields = () fields = ()
@ -71,6 +88,11 @@ class BaseMotionForm(CleanHtmlFormMixin, CssClassMixin, forms.ModelForm):
self.initial['tags'] = self.motion.tags.all() self.initial['tags'] = self.motion.tags.all()
super(BaseMotionForm, self).__init__(*args, **kwargs) super(BaseMotionForm, self).__init__(*args, **kwargs)
keys = self.fields.keys()
keys_order = [key for key in self.key_order if key in keys]
keys_order.extend(set(keys) - set(keys_order))
self.fields = collections.OrderedDict([(key, self.fields[key]) for key in keys_order])
class MotionSubmitterMixin(forms.ModelForm): class MotionSubmitterMixin(forms.ModelForm):
"""Mixin to append the submitter field to a MotionForm.""" """Mixin to append the submitter field to a MotionForm."""

View File

@ -792,6 +792,7 @@ class CategoryListView(ListView):
class CategoryCreateView(CreateView): class CategoryCreateView(CreateView):
fields = ("name", "prefix",)
required_permission = 'motion.can_manage_motion' required_permission = 'motion.can_manage_motion'
model = Category model = Category
success_url_name = 'motion_category_list' success_url_name = 'motion_category_list'
@ -799,6 +800,7 @@ class CategoryCreateView(CreateView):
class CategoryUpdateView(UpdateView): class CategoryUpdateView(UpdateView):
fields = ("name", "prefix",)
required_permission = 'motion.can_manage_motion' required_permission = 'motion.can_manage_motion'
model = Category model = Category
success_url_name = 'motion_category_list' success_url_name = 'motion_category_list'