From e2e16a4c345b3adc3c0142fcbd0de82cb94b12ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20B=C3=B6hlke?= Date: Sat, 17 Jan 2015 22:28:32 +0100 Subject: [PATCH 1/2] explicitly define fields attribute to fix deprecation warnings --- openslides/core/views.py | 2 ++ openslides/mediafile/views.py | 2 ++ openslides/motion/views.py | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/openslides/core/views.py b/openslides/core/views.py index f0d9cf934..e5f5d085a 100644 --- a/openslides/core/views.py +++ b/openslides/core/views.py @@ -189,6 +189,8 @@ 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 diff --git a/openslides/mediafile/views.py b/openslides/mediafile/views.py index 1e7184d62..1ab030c7d 100644 --- a/openslides/mediafile/views.py +++ b/openslides/mediafile/views.py @@ -38,6 +38,8 @@ 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 = [] diff --git a/openslides/motion/views.py b/openslides/motion/views.py index f4bef5474..f7770dcab 100644 --- a/openslides/motion/views.py +++ b/openslides/motion/views.py @@ -792,6 +792,8 @@ class CategoryListView(ListView): class CategoryCreateView(CreateView): + fields = ("name", "prefix",) + required_permission = 'motion.can_manage_motion' model = Category success_url_name = 'motion_category_list' @@ -799,6 +801,8 @@ class CategoryCreateView(CreateView): class CategoryUpdateView(UpdateView): + fields = ("name", "prefix",) + required_permission = 'motion.can_manage_motion' model = Category success_url_name = 'motion_category_list' From 591d230cbb27e6ca48cf61cc3ad39f6dc12fa799 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20B=C3=B6hlke?= Date: Sat, 17 Jan 2015 23:05:52 +0100 Subject: [PATCH 2/2] Fix field order in motion forms. Add documentation for new attribute. Added .idea to .gitignore. --- .gitignore | 3 ++- AUTHORS | 1 + openslides/core/views.py | 3 +-- openslides/mediafile/views.py | 1 - openslides/motion/forms.py | 22 ++++++++++++++++++++++ openslides/motion/views.py | 2 -- 6 files changed, 26 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index ad3b7e67d..5745da234 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/AUTHORS b/AUTHORS index 39b9dd30d..2c76e7a89 100644 --- a/AUTHORS +++ b/AUTHORS @@ -14,3 +14,4 @@ Authors of OpenSlides in chronological order of first contribution: Max Brauer Marco A. G. Pinto (Portuguese translation) Dominik Breu + André Böhlke diff --git a/openslides/core/views.py b/openslides/core/views.py index e5f5d085a..c1b8c7800 100644 --- a/openslides/core/views.py +++ b/openslides/core/views.py @@ -189,8 +189,7 @@ class CustomSlideViewMixin(object): """ Mixin for for CustomSlide Views. """ - fields = ('title', 'text', 'weight', ) - + fields = ('title', 'text', 'weight',) required_permission = 'core.can_manage_projector' template_name = 'core/customslide_update.html' model = CustomSlide diff --git a/openslides/mediafile/views.py b/openslides/mediafile/views.py index 1ab030c7d..54f1f60a6 100644 --- a/openslides/mediafile/views.py +++ b/openslides/mediafile/views.py @@ -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 = [] diff --git a/openslides/motion/forms.py b/openslides/motion/forms.py index 4fd340ddb..74b40df4c 100644 --- a/openslides/motion/forms.py +++ b/openslides/motion/forms.py @@ -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.""" diff --git a/openslides/motion/views.py b/openslides/motion/views.py index f7770dcab..967b03bf3 100644 --- a/openslides/motion/views.py +++ b/openslides/motion/views.py @@ -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'