Fixed percentage for special values (fixes #3736), added config to couple the candidates with the list of speakers (closes #3737)

This commit is contained in:
FinnStutzenstein 2018-05-09 08:47:05 +02:00 committed by Emanuel Schütze
parent 39da8f942f
commit c7a2f5c47c
4 changed files with 22 additions and 9 deletions

View File

@ -55,6 +55,15 @@ def get_config_variables():
group='Elections', group='Elections',
subgroup='Ballot and ballot papers') subgroup='Ballot and ballot papers')
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=428,
group='Elections',
subgroup='Ballot and ballot papers')
yield ConfigVariable( yield ConfigVariable(
name='assignments_pdf_ballot_papers_selection', name='assignments_pdf_ballot_papers_selection',
default_value='CUSTOM_NUMBER', default_value='CUSTOM_NUMBER',

View File

@ -285,14 +285,15 @@ class Assignment(RESTModelMixin, models.Model):
# Add all candidates to list of speakers of related agenda item # Add all candidates to list of speakers of related agenda item
# TODO: Try to do this in a bulk create # TODO: Try to do this in a bulk create
for candidate in self.candidates: if config['assignments_add_candidates_to_list_of_speakers']:
try: for candidate in self.candidates:
Speaker.objects.add(candidate, self.agenda_item, skip_autoupdate=True) try:
except OpenSlidesError: Speaker.objects.add(candidate, self.agenda_item, skip_autoupdate=True)
# The Speaker is already on the list. Do nothing. except OpenSlidesError:
# TODO: Find a smart way not to catch the error concerning AnonymousUser. # The Speaker is already on the list. Do nothing.
pass # TODO: Find a smart way not to catch the error concerning AnonymousUser.
inform_changed_data(self.agenda_item) pass
inform_changed_data(self.agenda_item)
return poll return poll

View File

@ -72,7 +72,9 @@ angular.module('OpenSlidesApp.assignments', [])
if (base && !skipPercents) { if (base && !skipPercents) {
percentNumber = Math.round(vote.weight * 100 / base * 100) / 100; percentNumber = Math.round(vote.weight * 100 / base * 100) / 100;
percentStr = "(" + percentNumber + "%)"; if (percentNumber >= 0) {
percentStr = '(' + percentNumber + ' %)';
}
} }
votes.push({ votes.push({
'order': order, 'order': order,

View File

@ -875,6 +875,7 @@ angular.module('OpenSlidesApp.assignments.site', [
gettext('Two-thirds majority'); gettext('Two-thirds majority');
gettext('Three-quarters majority'); gettext('Three-quarters majority');
gettext('Disabled'); gettext('Disabled');
gettext('Put all candidates on the list of speakers');
gettext('Title for PDF document (all elections)'); gettext('Title for PDF document (all elections)');
gettext('Preamble text for PDF document (all elections)'); gettext('Preamble text for PDF document (all elections)');
//other translations //other translations