Add CategoryFormField to the MotionForm

This commit is contained in:
Oskar Hahn 2013-03-11 20:41:02 +01:00
parent 2614a1cb2f
commit bc7be27131
2 changed files with 9 additions and 2 deletions

View File

@ -15,7 +15,7 @@ from django.utils.translation import ugettext as _
from openslides.utils.forms import CssClassMixin
from openslides.utils.person import PersonFormField, MultiplePersonFormField
from .models import Motion, Workflow
from .models import Motion, Workflow, Category
class BaseMotionForm(forms.ModelForm, CssClassMixin):
@ -90,6 +90,12 @@ class MotionDisableVersioningMixin(forms.ModelForm):
last_version will be used."""
class MotionCategoryMixin(forms.ModelForm):
"""Mixin to let the user choose the category for the motion."""
category = forms.ModelChoiceField(queryset=Category.objects.all(), required=False)
class ConfigForm(CssClassMixin, forms.Form):
"""Form for the configuration tab of OpenSlides."""
motion_min_supporters = forms.IntegerField(

View File

@ -35,7 +35,7 @@ from openslides.agenda.models import Item
from .models import (Motion, MotionSubmitter, MotionSupporter, MotionPoll,
MotionVersion, State, WorkflowError, Category)
from .forms import (BaseMotionForm, MotionSubmitterMixin, MotionSupporterMixin,
MotionDisableVersioningMixin, ConfigForm)
MotionDisableVersioningMixin, ConfigForm, MotionCategoryMixin)
from .pdf import motions_to_pdf, motion_to_pdf
@ -124,6 +124,7 @@ class MotionMixin(object):
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 self.object: