2013-03-01 17:13:12 +01:00
|
|
|
from django import forms
|
2013-09-25 10:01:01 +02:00
|
|
|
from django.utils.translation import ugettext as _
|
|
|
|
from django.utils.translation import ugettext_lazy, ugettext_noop
|
2013-03-01 17:13:12 +01:00
|
|
|
|
2015-06-16 10:37:23 +02:00
|
|
|
from openslides.config.api import (
|
|
|
|
ConfigGroup,
|
|
|
|
ConfigGroupedCollection,
|
|
|
|
ConfigVariable,
|
|
|
|
)
|
2014-04-10 20:18:22 +02:00
|
|
|
from openslides.poll.models import PERCENT_BASE_CHOICES
|
2013-03-01 17:13:12 +01:00
|
|
|
|
|
|
|
|
2013-12-02 19:33:43 +01:00
|
|
|
def setup_assignment_config(sender, **kwargs):
|
2013-03-01 17:13:12 +01:00
|
|
|
"""
|
2014-11-13 22:23:16 +01:00
|
|
|
Receiver function to setup all assignment config variables. It is
|
|
|
|
connected to the signal openslides.config.signals.config_signal during
|
|
|
|
app loading.
|
2013-03-01 17:13:12 +01:00
|
|
|
"""
|
2014-01-31 00:55:18 +01:00
|
|
|
# Ballot and ballot papers
|
2015-06-16 18:12:59 +02:00
|
|
|
assignments_poll_vote_values = ConfigVariable(
|
|
|
|
name='assignments_poll_vote_values',
|
2014-01-31 00:55:18 +01:00
|
|
|
default_value='auto',
|
|
|
|
form_field=forms.ChoiceField(
|
|
|
|
widget=forms.Select(),
|
2013-03-01 17:13:12 +01:00
|
|
|
required=False,
|
2014-01-31 00:55:18 +01:00
|
|
|
label=ugettext_lazy('Election method'),
|
|
|
|
choices=(
|
|
|
|
('auto', ugettext_lazy('Automatic assign of method')),
|
|
|
|
('votes', ugettext_lazy('Always one option per candidate')),
|
|
|
|
('yesnoabstain', ugettext_lazy('Always Yes-No-Abstain per candidate')))))
|
2015-06-16 18:12:59 +02:00
|
|
|
assignments_poll_100_percent_base = ConfigVariable(
|
|
|
|
name='assignments_poll_100_percent_base',
|
2014-04-10 20:18:22 +02:00
|
|
|
default_value='WITHOUT_INVALID',
|
|
|
|
form_field=forms.ChoiceField(
|
|
|
|
widget=forms.Select(),
|
|
|
|
required=False,
|
|
|
|
label=ugettext_lazy('The 100 % base of an election result consists of'),
|
|
|
|
choices=PERCENT_BASE_CHOICES))
|
2015-06-16 18:12:59 +02:00
|
|
|
assignments_pdf_ballot_papers_selection = ConfigVariable(
|
|
|
|
name='assignments_pdf_ballot_papers_selection',
|
2013-03-01 17:13:12 +01:00
|
|
|
default_value='CUSTOM_NUMBER',
|
|
|
|
form_field=forms.ChoiceField(
|
|
|
|
widget=forms.Select(),
|
|
|
|
required=False,
|
2013-04-22 19:59:05 +02:00
|
|
|
label=ugettext_lazy('Number of ballot papers (selection)'),
|
2013-03-01 17:13:12 +01:00
|
|
|
choices=(
|
2013-04-22 19:59:05 +02:00
|
|
|
('NUMBER_OF_DELEGATES', ugettext_lazy('Number of all delegates')),
|
|
|
|
('NUMBER_OF_ALL_PARTICIPANTS', ugettext_lazy('Number of all participants')),
|
|
|
|
('CUSTOM_NUMBER', ugettext_lazy('Use the following custom number')))))
|
2015-06-16 18:12:59 +02:00
|
|
|
assignments_pdf_ballot_papers_number = ConfigVariable(
|
|
|
|
name='assignments_pdf_ballot_papers_number',
|
2013-03-01 17:13:12 +01:00
|
|
|
default_value=8,
|
|
|
|
form_field=forms.IntegerField(
|
|
|
|
widget=forms.TextInput(attrs={'class': 'small-input'}),
|
|
|
|
required=False,
|
|
|
|
min_value=1,
|
2013-04-22 19:59:05 +02:00
|
|
|
label=ugettext_lazy('Custom number of ballot papers')))
|
2015-06-16 18:12:59 +02:00
|
|
|
assignments_publish_winner_results_only = ConfigVariable(
|
|
|
|
name='assignments_publish_winner_results_only',
|
2014-01-31 00:55:18 +01:00
|
|
|
default_value=False,
|
|
|
|
form_field=forms.BooleanField(
|
|
|
|
required=False,
|
2013-10-17 11:34:54 +02:00
|
|
|
label=ugettext_lazy('Publish election result for elected candidates only '
|
|
|
|
'(projector view)')))
|
2014-01-31 00:55:18 +01:00
|
|
|
group_ballot = ConfigGroup(
|
|
|
|
title=ugettext_lazy('Ballot and ballot papers'),
|
2015-06-16 18:12:59 +02:00
|
|
|
variables=(assignments_poll_vote_values,
|
|
|
|
assignments_poll_100_percent_base,
|
|
|
|
assignments_pdf_ballot_papers_selection,
|
|
|
|
assignments_pdf_ballot_papers_number,
|
|
|
|
assignments_publish_winner_results_only))
|
2014-01-31 00:55:18 +01:00
|
|
|
|
|
|
|
# PDF
|
2015-06-16 18:12:59 +02:00
|
|
|
assignments_pdf_title = ConfigVariable(
|
|
|
|
name='assignments_pdf_title',
|
2013-03-01 17:13:12 +01:00
|
|
|
default_value=_('Elections'),
|
2014-01-31 01:54:41 +01:00
|
|
|
translatable=True,
|
2013-03-01 17:13:12 +01:00
|
|
|
form_field=forms.CharField(
|
|
|
|
widget=forms.TextInput(),
|
|
|
|
required=False,
|
2013-04-22 19:59:05 +02:00
|
|
|
label=ugettext_lazy('Title for PDF document (all elections)')))
|
2015-06-16 18:12:59 +02:00
|
|
|
assignments_pdf_preamble = ConfigVariable(
|
|
|
|
name='assignments_pdf_preamble',
|
2013-03-01 17:13:12 +01:00
|
|
|
default_value='',
|
|
|
|
form_field=forms.CharField(
|
|
|
|
widget=forms.Textarea(),
|
|
|
|
required=False,
|
2013-04-22 19:59:05 +02:00
|
|
|
label=ugettext_lazy('Preamble text for PDF document (all elections)')))
|
2014-01-31 00:55:18 +01:00
|
|
|
group_pdf = ConfigGroup(
|
|
|
|
title=ugettext_lazy('PDF'),
|
2015-06-16 18:12:59 +02:00
|
|
|
variables=(assignments_pdf_title, assignments_pdf_preamble))
|
2013-03-01 17:13:12 +01:00
|
|
|
|
2014-01-31 00:55:18 +01:00
|
|
|
return ConfigGroupedCollection(
|
|
|
|
title=ugettext_noop('Elections'),
|
|
|
|
url='assignment',
|
|
|
|
weight=40,
|
|
|
|
groups=(group_ballot, group_pdf))
|