dont set identifier prefix, if it is empty

This commit is contained in:
Oskar Hahn 2013-03-12 23:54:37 +01:00
parent b2c888b151
commit 71b9bd0a08
3 changed files with 17 additions and 7 deletions

View File

@ -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

View File

@ -40,7 +40,7 @@ urlpatterns = patterns('openslides.motion.views',
name='motion_delete',
),
url(r'^(?P<pk>\d+)/set_identifier',
url(r'^(?P<pk>\d+)/set_identifier/',
'set_identifier',
name='motion_set_identifier',
),

View File

@ -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)