Some clean up and styling work for motion config 'without abstains'.

Manage all config strings in site.js of each app.
This commit is contained in:
Emanuel Schuetze 2016-08-29 16:08:27 +02:00
parent fc1ce3d90d
commit 65b0772556
7 changed files with 62 additions and 41 deletions

View File

@ -741,6 +741,9 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments'])
gettext('Elections'); gettext('Elections');
gettext('Ballot and ballot papers'); gettext('Ballot and ballot papers');
gettext('The 100 % base of an election result consists of'); gettext('The 100 % base of an election result consists of');
gettext('All valid votes (Yes/No/Abstain)');
gettext('All votes cast (including invalid votes)');
gettext('Disabled (no percents)');
gettext('Number of ballot papers (selection)'); gettext('Number of ballot papers (selection)');
gettext('Number of all delegates'); gettext('Number of all delegates');
gettext('Number of all participants'); gettext('Number of all participants');

View File

@ -1,5 +1,4 @@
from django.core.validators import MinValueValidator from django.core.validators import MinValueValidator
from django.utils.translation import ugettext_lazy
from openslides.core.config import ConfigVariable from openslides.core.config import ConfigVariable
from openslides.poll.models import PERCENT_BASE_CHOICES from openslides.poll.models import PERCENT_BASE_CHOICES
@ -24,10 +23,10 @@ def get_config_variables():
papers' and 'PDF'. The generator has to be evaluated during app loading papers' and 'PDF'. The generator has to be evaluated during app loading
(see apps.py). (see apps.py).
""" """
percent_base_choices_motion = PERCENT_BASE_CHOICES PERCENT_BASE_CHOICES_MOTION = ({
percent_base_choices_motion += ({
'value': "WITHOUT_ABSTAIN", 'value': "WITHOUT_ABSTAIN",
'display_name': ugettext_lazy('Yes and No votes')},) 'display_name': 'Yes and No votes'},)
PERCENT_BASE_CHOICES_MOTION += PERCENT_BASE_CHOICES
# General # General
yield ConfigVariable( yield ConfigVariable(
name='motions_workflow', name='motions_workflow',
@ -153,7 +152,7 @@ def get_config_variables():
default_value='WITHOUT_INVALID', default_value='WITHOUT_INVALID',
input_type='choice', input_type='choice',
label='The 100 % base of a voting result consists of', label='The 100 % base of a voting result consists of',
choices=percent_base_choices_motion, choices=PERCENT_BASE_CHOICES_MOTION,
weight=355, weight=355,
group='Motions', group='Motions',
subgroup='Voting and ballot papers') subgroup='Voting and ballot papers')

View File

@ -95,8 +95,8 @@ angular.module('OpenSlidesApp.motions', [
percentNumber = Math.round(vote * 100 / this.votesvalid * 10) / 10; percentNumber = Math.round(vote * 100 / this.votesvalid * 10) / 10;
} else if (config == "WITH_INVALID" && this.votescast > 0 && vote >= 0) { } else if (config == "WITH_INVALID" && this.votescast > 0 && vote >= 0) {
percentNumber = Math.round(vote * 100 / (this.votescast) * 10) / 10; percentNumber = Math.round(vote * 100 / (this.votescast) * 10) / 10;
} else if (config == "WITHOUT_ABSTAIN" && this.votesvalid > 0 && vote >= 0){ } else if (config == "WITHOUT_ABSTAIN" && vote >= 0) {
if (type == 'yes' || type == 'no') { if (type == 'yes' || type == 'no') {
percentNumber = Math.round(vote * 100 / (this.yes + this.no) * 10) / 10; percentNumber = Math.round(vote * 100 / (this.yes + this.no) * 10) / 10;
} }
} }

View File

@ -70,14 +70,14 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions', 'OpenSlid
results = function() { results = function() {
return motion.polls.map(function(poll, index) { return motion.polls.map(function(poll, index) {
var id = index + 1, var id = index + 1,
yes = poll.yes ? poll.yes : 0, // if no poll.yes is given, set it to 0 yes = poll.yes ? poll.yes : '-', // if no poll.yes is given set it to '-'
yesRelative = poll.getVote(poll.yes, 'yes').percentStr, yesRelative = poll.getVote(poll.yes, 'yes').percentStr,
no = poll.no ? poll.no : 0, no = poll.no ? poll.no : '-',
noRelative = poll.getVote(poll.no, 'no').percentStr, noRelative = poll.getVote(poll.no, 'no').percentStr,
abstain = poll.abstain ? poll.abstain : 0, abstain = poll.abstain ? poll.abstain : '-',
abstainrelativeGet = poll.getVote(poll.abstain, 'abstain').percentStr, abstainrelativeGet = poll.getVote(poll.abstain, 'abstain').percentStr,
abstainRelative = abstainrelativeGet? abstainrelativeGet : "", abstainRelative = abstainrelativeGet ? abstainrelativeGet : '',
valid = poll.votesvalid, valid = poll.votesvalid ? poll.votesvalid : '-',
validRelative = poll.getVote(poll.votesvalid, 'votesvalid').percentStr, validRelative = poll.getVote(poll.votesvalid, 'votesvalid').percentStr,
number = { number = {
text: id + ".", text: id + ".",
@ -1570,29 +1570,17 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions', 'OpenSlid
.config([ .config([
'gettext', 'gettext',
function (gettext) { function (gettext) {
gettext('The assembly may decide,');
gettext('Workflow of new motions');
gettext('Motions'); gettext('Motions');
// subgroup General
gettext('General');
gettext('Workflow of new motions');
gettext('Identifier'); gettext('Identifier');
gettext('Numbered per category'); gettext('Numbered per category');
gettext('Serially numbered'); gettext('Serially numbered');
gettext('Set it manually'); gettext('Set it manually');
gettext('Motion preamble'); gettext('Motion preamble');
gettext('Stop submitting new motions by non-staff users'); gettext('The assembly may decide,');
gettext('Allow to disable versioning');
gettext('Activate amendments');
gettext('Amendments');
gettext('Prefix for the identifier for amendments');
gettext('Number of (minimum) required supporters for a motion');
gettext('Choose 0 to disable the supporting system.');
gettext('Supporters');
gettext('Remove all supporters of a motion if a submitter edits his ' +
'motion in early state');
gettext('Title for PDF document (all motions)');
gettext('Preamble text for PDF document (all motioqns)');
gettext('Show paragraph numbering (only in PDF)');
/// Prefix for the identifier for amendments
gettext('A');
gettext('Default line numbering'); gettext('Default line numbering');
/// Line numbering: Outside /// Line numbering: Outside
gettext('Outside'); gettext('Outside');
@ -1602,6 +1590,40 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions', 'OpenSlid
gettext('None'); gettext('None');
gettext('Line length'); gettext('Line length');
gettext('The maximum number of characters per line. Relevant when line numbering is enabled. Min: 40'); gettext('The maximum number of characters per line. Relevant when line numbering is enabled. Min: 40');
gettext('Stop submitting new motions by non-staff users');
gettext('Allow to disable versioning');
// subgroup Amendments
gettext('Amendments');
gettext('Activate amendments');
gettext('Prefix for the identifier for amendments');
/// Prefix for the identifier for amendments
gettext('A');
// subgroup Suppoerters
gettext('Supporters');
gettext('Number of (minimum) required supporters for a motion');
gettext('Choose 0 to disable the supporting system.');
gettext('Remove all supporters of a motion if a submitter edits his ' +
'motion in early state');
// subgroup Voting and ballot papers
gettext('Voting and ballot papers');
gettext('The 100 % base of a voting result consists of');
gettext('All valid votes (Yes/No/Abstain)');
gettext('All votes cast (including invalid votes)');
gettext('Disabled (no percents)');
gettext('Yes and No votes');
gettext('Number of ballot papers (selection)');
gettext('Number of all delegates');
gettext('Number of all participants');
gettext('Use the following custom number');
gettext('Custom number of ballot papers');
// subgroup PDF
gettext('Title for PDF document (all motions)');
gettext('Preamble text for PDF document (all motioqns)');
gettext('Show paragraph numbering (only in PDF)');
} }
]); ]);

View File

@ -184,7 +184,7 @@
<uib-progressbar value="voteAbstain.percentNumber" type="warning"></uib-progressbar> <uib-progressbar value="voteAbstain.percentNumber" type="warning"></uib-progressbar>
</div> </div>
<!-- valid votes --> <!-- valid votes -->
<tr> <tr ng-if="poll.votesvalid !== null">
<td class="icon"> <td class="icon">
<i class="fa fa-check fa-lg"></i> <i class="fa fa-check fa-lg"></i>
<td ng-init="votesValid = poll.getVote(poll.votesvalid, 'votesvalid')"> <td ng-init="votesValid = poll.getVote(poll.votesvalid, 'votesvalid')">
@ -193,7 +193,7 @@
{{ votesValid.value }} {{ votesValid.percentStr }} {{ votesValid.value }} {{ votesValid.percentStr }}
</span> </span>
<!-- invalid votes --> <!-- invalid votes -->
<tr> <tr ng-if="poll.votesinvalid !== null">
<td class="icon"> <td class="icon">
<i class="fa fa-ban fa-lg"></i> <i class="fa fa-ban fa-lg"></i>
<td ng-init="votesInvalid = poll.getVote(poll.votesinvalid, 'votesinvalid')"> <td ng-init="votesInvalid = poll.getVote(poll.votesinvalid, 'votesinvalid')">
@ -205,7 +205,7 @@
</span> </span>
</span> </span>
<!-- votes cast --> <!-- votes cast -->
<tr class="total"> <tr class="total" ng-if="poll.votescast !== null">
<td class="icon"> <td class="icon">
<strong style="font-size: 16px">&sum;</strong> <strong style="font-size: 16px">&sum;</strong>
<td ng-init="votesCast = poll.getVote(poll.votescast, 'votescast')"> <td ng-init="votesCast = poll.getVote(poll.votescast, 'votescast')">

View File

@ -52,7 +52,7 @@
<span class="result_value"> <span class="result_value">
{{ voteAbstain.value }} {{ voteAbstain.percentStr }} {{ voteAbstain.value }} {{ voteAbstain.percentStr }}
</span> </span>
<div ng-if="voteAbstain.percentNumber >= 0"> <div ng-if="voteAbstain.percentNumber">
<uib-progressbar value="voteAbstain.percentNumber" type="warning"></uib-progressbar> <uib-progressbar value="voteAbstain.percentNumber" type="warning"></uib-progressbar>
</div> </div>
</table> </table>

View File

@ -3,7 +3,6 @@ import locale
from django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import ObjectDoesNotExist
from django.db import models from django.db import models
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy
from openslides.utils.models import MinMaxIntegerField from openslides.utils.models import MinMaxIntegerField
@ -67,9 +66,9 @@ class BaseVote(models.Model):
return print_value(self.weight, percent_base) return print_value(self.weight, percent_base)
PERCENT_BASE_CHOICES = ( PERCENT_BASE_CHOICES = (
{'value': 'WITHOUT_INVALID', 'display_name': ugettext_lazy('All valid votes (Yes/No/Abstain)')}, {'value': 'WITHOUT_INVALID', 'display_name': 'All valid votes (Yes/No/Abstain)'},
{'value': 'WITH_INVALID', 'display_name': ugettext_lazy('All votes cast (including invalid votes)')}, {'value': 'WITH_INVALID', 'display_name': 'All votes cast (including invalid votes)'},
{'value': 'DISABLED', 'display_name': ugettext_lazy('Disabled (no percents)')}) {'value': 'DISABLED', 'display_name': 'Disabled (no percents)'})
class CollectDefaultVotesMixin(models.Model): class CollectDefaultVotesMixin(models.Model):
@ -118,11 +117,9 @@ class CollectDefaultVotesMixin(models.Model):
return value return value
def get_percent_base(self): def get_percent_base(self):
if self.get_percent_base_choice() == "WITHOUT_INVALID" and\ if self.get_percent_base_choice() == "WITHOUT_INVALID" and self.votesvalid and self.votesvalid > 0:
self.votesvalid and self.votesvalid > 0:
base = 100 / float(self.votesvalid) base = 100 / float(self.votesvalid)
elif self.get_percent_base_choice() == "WITH_INVALID" and\ elif self.get_percent_base_choice() == "WITH_INVALID" and self.votescast and self.votescast > 0:
self.votescast and self.votescast > 0:
base = 100 / float(self.votescast) base = 100 / float(self.votescast)
else: else:
base = None base = None