diff --git a/eos/base/election.py b/eos/base/election.py index e563142..62cf3dc 100644 --- a/eos/base/election.py +++ b/eos/base/election.py @@ -119,11 +119,23 @@ class ListChoiceQuestion(Question): def pretty_answer(self, answer): if len(answer.choices) == 0: return '(blank votes)' - return ', '.join([self.choices[choice].name for choice in answer.choices]) + flat_choices = self.flatten_choices() + return ', '.join([flat_choices[choice].name for choice in answer.choices]) def max_bits(self): answer = self.answer_type(choices=list(range(len(self.choices)))) return len(EosObject.to_json(EosObject.serialise_and_wrap(answer))) * 8 + + def flatten_choices(self): + # Return a flat list of Choices, without Tickets + flat_choices = [] + for choice in self.choices: + if isinstance(choice, Ticket): + for choice2 in choice.choices: + flat_choices.append(choice2) + else: + flat_choices.append(choice) + return flat_choices class ApprovalAnswer(Answer): choices = ListField(IntField()) @@ -140,6 +152,16 @@ class PreferentialQuestion(ListChoiceQuestion): class Choice(EmbeddedObject): name = StringField() party = StringField(default=None) + + @property + def party_or_ticket(self): + if self.party is not None: + return self.party + else: + ticket = self.recurse_parents(Ticket) + if ticket: + return ticket.name + return None class Ticket(EmbeddedObject): name = StringField() diff --git a/eosweb/core/static/css/main.css b/eosweb/core/static/css/main.css index 99eacc2..a700e29 100644 --- a/eosweb/core/static/css/main.css +++ b/eosweb/core/static/css/main.css @@ -109,10 +109,14 @@ text-align: center; } -.preferential-choice .party-name { +.preferential-choice .party-name, .preferential-choice .ticket-party-name { font-style: italic; } +.ticket .ticket-party-name { + display: none; +} + .ticket > .content > .party-name { min-height: 2em; } diff --git a/eosweb/core/static/nunjucks/question/approval/selections_make.html b/eosweb/core/static/nunjucks/question/approval/selections_make.html index 1526e6f..20d47cf 100644 --- a/eosweb/core/static/nunjucks/question/approval/selections_make.html +++ b/eosweb/core/static/nunjucks/question/approval/selections_make.html @@ -26,7 +26,7 @@
You have selected more than the maximum allowed number of choices. To proceed, you must deselect some choices by dragging them from the blue box back to the grey box.
Technical details: ' + err + '
'; } $("#booth-content").html(' '); + console.error(err); } function showTemplate(template, opts, destination) {