#69: Added missing config option to publish voting results for selected
winners only.
This commit is contained in:
parent
57f784aa22
commit
3992b04dc2
@ -138,6 +138,7 @@ def assignment_votes(item):
|
||||
votes = []
|
||||
if item.type == "ItemAssignment":
|
||||
assignment = item.cast().assignment
|
||||
publish_winner_results_only = config_get("assignment_publish_winner_results_only")
|
||||
# list of votes
|
||||
votes = []
|
||||
for candidate in assignment.candidates:
|
||||
@ -145,7 +146,9 @@ def assignment_votes(item):
|
||||
for poll in assignment.poll_set.all():
|
||||
if poll.published:
|
||||
if candidate in poll.options_values:
|
||||
if assignment.is_elected(candidate):
|
||||
# check config option 'publish_winner_results_only'
|
||||
if not publish_winner_results_only \
|
||||
or publish_winner_results_only and assignment.is_elected(candidate):
|
||||
option = Option.objects.filter(poll=poll).filter(user=candidate)[0]
|
||||
if poll.optiondecision:
|
||||
tmplist[1].append([option.yes, option.no, option.undesided])
|
||||
|
@ -54,6 +54,7 @@ class AssignmentConfigForm(Form):
|
||||
error_css_class = 'error'
|
||||
required_css_class = 'required'
|
||||
|
||||
assignment_publish_winner_results_only = BooleanField(required=False, label=_("Only publish voting results for selected winners (Projector view only)"))
|
||||
assignment_pdf_ballot_papers_selection = ChoiceField(widget=Select(), required=False, label=_("Number of ballot papers (selection)"), choices=[("1", _("Number of all delegates")),("2", _("Number of all participants")),("0", _("Use the following custum number"))])
|
||||
assignment_pdf_ballot_papers_number = IntegerField(widget=TextInput(attrs={'class':'small-input'}), required=False, min_value=1, label=_("Custom number of ballot papers"))
|
||||
assignment_pdf_title = CharField(widget=TextInput(), required=False, label=_("Title for PDF document (all elections)"))
|
||||
|
@ -100,6 +100,10 @@ def get_assignment_config(request):
|
||||
if request.method == 'POST':
|
||||
form_assignment = AssignmentConfigForm(request.POST, prefix='assignment')
|
||||
if form_assignment.is_valid():
|
||||
if form_assignment.cleaned_data['assignment_publish_winner_results_only']:
|
||||
config_set('assignment_publish_winner_results_only', True)
|
||||
else:
|
||||
config_set('assignment_publish_winner_results_only', '')
|
||||
config_set('assignment_pdf_ballot_papers_selection', form_assignment.cleaned_data['assignment_pdf_ballot_papers_selection'])
|
||||
config_set('assignment_pdf_ballot_papers_number', form_assignment.cleaned_data['assignment_pdf_ballot_papers_number'])
|
||||
config_set('assignment_pdf_title', form_assignment.cleaned_data['assignment_pdf_title'])
|
||||
@ -109,6 +113,7 @@ def get_assignment_config(request):
|
||||
messages.error(request, _('Please check the form for errors.'))
|
||||
else:
|
||||
form_assignment = AssignmentConfigForm(initial={
|
||||
'assignment_publish_winner_results_only': config_get('assignment_publish_winner_results_only'),
|
||||
'assignment_pdf_ballot_papers_selection': config_get('assignment_pdf_ballot_papers_selection'),
|
||||
'assignment_pdf_ballot_papers_number': config_get('assignment_pdf_ballot_papers_number'),
|
||||
'assignment_pdf_title': config_get('assignment_pdf_title'),
|
||||
|
Loading…
Reference in New Issue
Block a user