From 71b9bd0a08a208e168e2d707fd4cb7c258d0d717 Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Tue, 12 Mar 2013 23:54:37 +0100 Subject: [PATCH] dont set identifier prefix, if it is empty --- openslides/motion/models.py | 12 +++++++++--- openslides/motion/urls.py | 2 +- openslides/motion/views.py | 10 +++++++--- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/openslides/motion/models.py b/openslides/motion/models.py index a1b13b950..e4cf800b4 100644 --- a/openslides/motion/models.py +++ b/openslides/motion/models.py @@ -38,7 +38,7 @@ from .exceptions import MotionError, WorkflowError # TODO: into the config-tab -config['motion_identifier'] = ('manually', 'per_category', 'serially_numbered')[0] +config['motion_identifier'] = ('manually', 'per_category', 'serially_numbered')[2] class Motion(SlideMixin, models.Model): @@ -190,7 +190,7 @@ class Motion(SlideMixin, models.Model): motions = Motion.objects.all() number = motions.aggregate(Max('identifier_number'))['identifier_number__max'] or 0 - if self.category is None: + if self.category is None or not self.category.prefix: prefix = '' else: prefix = self.category.prefix + ' ' @@ -577,7 +577,13 @@ class MotionSupporter(models.Model): class Category(models.Model): name = models.CharField(max_length=255, verbose_name=ugettext_lazy("Category name")) - prefix = models.CharField(max_length=32, verbose_name=ugettext_lazy("Category prefix")) + """Name of the category.""" + + prefix = models.CharField(blank=True, max_length=32, verbose_name=ugettext_lazy("Category prefix")) + """Prefix of the category. + + Used to build the identifier of a motion. + """ def __unicode__(self): return self.name diff --git a/openslides/motion/urls.py b/openslides/motion/urls.py index 577073c38..85de6fbfc 100644 --- a/openslides/motion/urls.py +++ b/openslides/motion/urls.py @@ -40,7 +40,7 @@ urlpatterns = patterns('openslides.motion.views', name='motion_delete', ), - url(r'^(?P\d+)/set_identifier', + url(r'^(?P\d+)/set_identifier/', 'set_identifier', name='motion_set_identifier', ), diff --git a/openslides/motion/views.py b/openslides/motion/views.py index 8af3fef2c..d397f8b78 100644 --- a/openslides/motion/views.py +++ b/openslides/motion/views.py @@ -131,15 +131,19 @@ class MotionMixin(object): will be mixed in dependence of some config values. See motion.forms for more information on the mixins. """ + form_classes = [] + + if (self.request.user.has_perm('motion.can_manage_motion') and + config['motion_identifier'] == 'manually'): + form_classes.append(MotionIdentifierMixin) + + form_classes.append(BaseMotionForm) - form_classes = [BaseMotionForm] if self.request.user.has_perm('motion.can_manage_motion'): form_classes.append(MotionSubmitterMixin) form_classes.append(MotionCategoryMixin) if config['motion_min_supporters'] > 0: form_classes.append(MotionSupporterMixin) - if config['motion_identifier'] == 'manually': - form_classes.append(MotionIdentifierMixin) if self.object: if config['motion_allow_disable_versioning'] and self.object.state.versioning: form_classes.append(MotionDisableVersioningMixin)