2015-06-17 18:32:05 +02:00
|
|
|
from django.core.validators import MinValueValidator
|
2013-03-01 17:13:12 +01:00
|
|
|
|
2015-06-29 12:08:15 +02:00
|
|
|
from openslides.core.config import ConfigVariable
|
2018-11-22 12:33:40 +01:00
|
|
|
from openslides.poll.majority import majorityMethods
|
2013-03-01 17:13:12 +01:00
|
|
|
|
|
|
|
|
2016-06-02 12:47:01 +02:00
|
|
|
def get_config_variables():
|
2013-03-01 17:13:12 +01:00
|
|
|
"""
|
2016-06-02 12:47:01 +02:00
|
|
|
Generator which yields all config variables of this app.
|
|
|
|
|
|
|
|
They are grouped in 'Ballot and ballot papers' and 'PDF'. The generator has
|
|
|
|
to be evaluated during app loading (see apps.py).
|
2013-03-01 17:13:12 +01:00
|
|
|
"""
|
2014-01-31 00:55:18 +01:00
|
|
|
# Ballot and ballot papers
|
2015-06-17 18:32:05 +02:00
|
|
|
yield ConfigVariable(
|
2019-01-06 16:22:33 +01:00
|
|
|
name="assignments_poll_100_percent_base",
|
|
|
|
default_value="YES_NO_ABSTAIN",
|
|
|
|
input_type="choice",
|
|
|
|
label="The 100-%-base of an election result consists of",
|
2016-08-26 13:46:57 +02:00
|
|
|
choices=(
|
2019-01-06 16:22:33 +01:00
|
|
|
{"value": "YES_NO_ABSTAIN", "display_name": "Yes/No/Abstain per candidate"},
|
|
|
|
{"value": "YES_NO", "display_name": "Yes/No per candidate"},
|
|
|
|
{"value": "VALID", "display_name": "All valid ballots"},
|
|
|
|
{"value": "CAST", "display_name": "All casted ballots"},
|
|
|
|
{"value": "DISABLED", "display_name": "Disabled (no percents)"},
|
|
|
|
),
|
|
|
|
help_text=(
|
|
|
|
"For Yes/No/Abstain per candidate and Yes/No per candidate the 100-%-base "
|
|
|
|
"depends on the election method: If there is only one option per candidate, "
|
|
|
|
"the sum of all votes of all candidates is 100 %. Otherwise for each "
|
|
|
|
"candidate the sum of all votes is 100 %."
|
|
|
|
),
|
2015-06-17 18:32:05 +02:00
|
|
|
weight=420,
|
2019-01-06 16:22:33 +01:00
|
|
|
group="Elections",
|
|
|
|
subgroup="Ballot and ballot papers",
|
|
|
|
)
|
2015-06-17 18:32:05 +02:00
|
|
|
|
2016-10-26 18:32:00 +02:00
|
|
|
# TODO: Add server side validation of the choices.
|
|
|
|
yield ConfigVariable(
|
2019-01-06 16:22:33 +01:00
|
|
|
name="assignments_poll_default_majority_method",
|
|
|
|
default_value=majorityMethods[0]["value"],
|
|
|
|
input_type="choice",
|
2018-11-22 12:33:40 +01:00
|
|
|
choices=majorityMethods,
|
2019-01-06 16:22:33 +01:00
|
|
|
label="Required majority",
|
|
|
|
help_text="Default method to check whether a candidate has reached the required majority.",
|
2016-10-26 18:32:00 +02:00
|
|
|
weight=425,
|
2019-01-06 16:22:33 +01:00
|
|
|
group="Elections",
|
|
|
|
subgroup="Ballot and ballot papers",
|
|
|
|
)
|
2016-10-26 18:32:00 +02:00
|
|
|
|
2015-06-17 18:32:05 +02:00
|
|
|
yield ConfigVariable(
|
2019-01-06 16:22:33 +01:00
|
|
|
name="assignments_pdf_ballot_papers_selection",
|
|
|
|
default_value="CUSTOM_NUMBER",
|
|
|
|
input_type="choice",
|
|
|
|
label="Number of ballot papers (selection)",
|
2015-06-17 18:32:05 +02:00
|
|
|
choices=(
|
2019-01-06 16:22:33 +01:00
|
|
|
{"value": "NUMBER_OF_DELEGATES", "display_name": "Number of all delegates"},
|
|
|
|
{
|
|
|
|
"value": "NUMBER_OF_ALL_PARTICIPANTS",
|
|
|
|
"display_name": "Number of all participants",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"value": "CUSTOM_NUMBER",
|
|
|
|
"display_name": "Use the following custom number",
|
|
|
|
},
|
|
|
|
),
|
2015-06-17 18:32:05 +02:00
|
|
|
weight=430,
|
2019-01-06 16:22:33 +01:00
|
|
|
group="Elections",
|
|
|
|
subgroup="Ballot and ballot papers",
|
|
|
|
)
|
2015-06-17 18:32:05 +02:00
|
|
|
|
|
|
|
yield ConfigVariable(
|
2019-01-06 16:22:33 +01:00
|
|
|
name="assignments_pdf_ballot_papers_number",
|
2013-03-01 17:13:12 +01:00
|
|
|
default_value=8,
|
2019-01-06 16:22:33 +01:00
|
|
|
input_type="integer",
|
|
|
|
label="Custom number of ballot papers",
|
2019-08-14 21:53:42 +02:00
|
|
|
weight=435,
|
2019-01-06 16:22:33 +01:00
|
|
|
group="Elections",
|
|
|
|
subgroup="Ballot and ballot papers",
|
|
|
|
validators=(MinValueValidator(1),),
|
|
|
|
)
|
2015-06-17 18:32:05 +02:00
|
|
|
|
2019-08-14 21:53:42 +02:00
|
|
|
yield ConfigVariable(
|
|
|
|
name="assignments_add_candidates_to_list_of_speakers",
|
|
|
|
default_value=True,
|
|
|
|
input_type="boolean",
|
|
|
|
label="Put all candidates on the list of speakers",
|
|
|
|
weight=440,
|
|
|
|
group="Elections",
|
|
|
|
subgroup="Ballot and ballot papers",
|
|
|
|
)
|
|
|
|
|
2014-01-31 00:55:18 +01:00
|
|
|
# PDF
|
2015-06-17 18:32:05 +02:00
|
|
|
|
|
|
|
yield ConfigVariable(
|
2019-01-06 16:22:33 +01:00
|
|
|
name="assignments_pdf_title",
|
|
|
|
default_value="Elections",
|
|
|
|
label="Title for PDF document (all elections)",
|
2015-06-17 18:32:05 +02:00
|
|
|
weight=460,
|
2019-01-06 16:22:33 +01:00
|
|
|
group="Elections",
|
2019-08-14 21:53:42 +02:00
|
|
|
subgroup="PDF export",
|
2019-01-06 16:22:33 +01:00
|
|
|
)
|
2015-06-17 18:32:05 +02:00
|
|
|
|
|
|
|
yield ConfigVariable(
|
2019-01-06 16:22:33 +01:00
|
|
|
name="assignments_pdf_preamble",
|
|
|
|
default_value="",
|
|
|
|
label="Preamble text for PDF document (all elections)",
|
2015-06-17 18:32:05 +02:00
|
|
|
weight=470,
|
2019-01-06 16:22:33 +01:00
|
|
|
group="Elections",
|
2019-08-14 21:53:42 +02:00
|
|
|
subgroup="PDF export",
|
2019-01-06 16:22:33 +01:00
|
|
|
)
|