Fix field order in motion forms.

Add documentation for new attribute.
Added .idea to .gitignore.
This commit is contained in:
André Böhlke 2015-01-17 23:05:52 +01:00
parent e2e16a4c34
commit 591d230cbb
6 changed files with 26 additions and 6 deletions

3
.gitignore vendored
View File

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

View File

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

View File

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

View File

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

View File

@ -1,3 +1,5 @@
import collections
from django import forms
from django.utils.translation import ugettext_lazy
@ -51,6 +53,21 @@ class BaseMotionForm(CleanHtmlFormMixin, CssClassMixin, forms.ModelForm):
required=False,
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:
model = Motion
fields = ()
@ -71,6 +88,11 @@ class BaseMotionForm(CleanHtmlFormMixin, CssClassMixin, forms.ModelForm):
self.initial['tags'] = self.motion.tags.all()
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):
"""Mixin to append the submitter field to a MotionForm."""

View File

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