2011-07-31 10:46:29 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
openslides.assignment.forms
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Forms for the assignment app.
|
|
|
|
|
2012-04-25 22:29:19 +02:00
|
|
|
:copyright: 2011, 2012 by OpenSlides team, see AUTHORS.
|
2011-07-31 10:46:29 +02:00
|
|
|
:license: GNU GPL, see LICENSE for more details.
|
|
|
|
"""
|
|
|
|
|
2012-03-16 14:31:59 +01:00
|
|
|
from django import forms
|
2011-07-31 10:46:29 +02:00
|
|
|
from django.forms import ModelForm, Form, ModelChoiceField, Select
|
|
|
|
|
2012-02-20 18:44:02 +01:00
|
|
|
from utils.forms import CssClassMixin
|
2012-05-15 01:08:08 +02:00
|
|
|
from utils.translation_ext import ugettext as _
|
2011-07-31 10:46:29 +02:00
|
|
|
from participant.models import Profile
|
|
|
|
from assignment.models import Assignment
|
|
|
|
|
|
|
|
|
2012-02-20 18:44:02 +01:00
|
|
|
class AssignmentForm(ModelForm, CssClassMixin):
|
2012-06-24 22:38:42 +02:00
|
|
|
posts = forms.IntegerField(min_value=1, label=_("Number of available posts"))
|
2011-07-31 10:46:29 +02:00
|
|
|
class Meta:
|
|
|
|
model = Assignment
|
2011-09-03 12:26:14 +02:00
|
|
|
exclude = ('status', 'profile', 'elected')
|
2011-07-31 10:46:29 +02:00
|
|
|
|
|
|
|
|
2012-02-20 18:44:02 +01:00
|
|
|
class AssignmentRunForm(Form, CssClassMixin):
|
2011-07-31 10:46:29 +02:00
|
|
|
candidate = ModelChoiceField(
|
2012-02-20 18:44:02 +01:00
|
|
|
widget=Select(attrs={'class': 'medium-input'}),
|
|
|
|
queryset=Profile.objects.all().order_by('user__first_name'),
|
|
|
|
label=_("Nominate a participant"),
|
|
|
|
)
|
2012-03-16 14:31:59 +01:00
|
|
|
|
|
|
|
|
|
|
|
class ConfigForm(Form, CssClassMixin):
|
|
|
|
assignment_publish_winner_results_only = forms.BooleanField(
|
|
|
|
required=False,
|
|
|
|
label=_("Only publish voting results for selected winners (Projector view only)")
|
|
|
|
)
|
|
|
|
assignment_pdf_ballot_papers_selection = forms.ChoiceField(widget=forms.Select(),
|
|
|
|
required=False,
|
|
|
|
label=_("Number of ballot papers (selection)"),
|
2012-06-18 09:48:27 +02:00
|
|
|
choices=(
|
2012-03-16 14:31:59 +01:00
|
|
|
("1", _("Number of all delegates")),
|
|
|
|
("2", _("Number of all participants")),
|
|
|
|
("0", _("Use the following custum number"))
|
2012-06-18 09:48:27 +02:00
|
|
|
)
|
2012-03-16 14:31:59 +01:00
|
|
|
)
|
|
|
|
assignment_pdf_ballot_papers_number = forms.IntegerField(
|
|
|
|
widget=forms.TextInput(attrs={'class':'small-input'}),
|
|
|
|
required=False,
|
|
|
|
min_value=1,
|
|
|
|
label=_("Custom number of ballot papers")
|
|
|
|
)
|
|
|
|
assignment_pdf_title = forms.CharField(
|
|
|
|
widget=forms.TextInput(),
|
|
|
|
required=False,
|
|
|
|
label=_("Title for PDF document (all elections)")
|
|
|
|
)
|
|
|
|
assignment_pdf_preamble = forms.CharField(
|
|
|
|
widget=forms.Textarea(),
|
|
|
|
required=False,
|
|
|
|
label=_("Preamble text for PDF document (all elections)")
|
|
|
|
)
|
2012-06-18 09:48:27 +02:00
|
|
|
assignment_poll_vote_values = forms.ChoiceField(widget=forms.Select(),
|
|
|
|
required=False,
|
2012-06-23 15:36:02 +02:00
|
|
|
label=_("Election method"),
|
2012-06-18 09:48:27 +02:00
|
|
|
choices=(
|
|
|
|
("auto", _("Choose the right method.")),
|
2012-06-23 15:36:02 +02:00
|
|
|
("votes", _("Always one option per candidate.")),
|
|
|
|
("yesnoabstain", _("Always Yes-No-Abstain per candidate.")),
|
2012-06-18 09:48:27 +02:00
|
|
|
)
|
|
|
|
)
|