diff --git a/src/ekklesia_portal/concepts/voting_phase/templates/voting_phase.j2.jade b/src/ekklesia_portal/concepts/voting_phase/templates/voting_phase.j2.jade index 531480c..be83070 100644 --- a/src/ekklesia_portal/concepts/voting_phase/templates/voting_phase.j2.jade +++ b/src/ekklesia_portal/concepts/voting_phase/templates/voting_phase.j2.jade @@ -49,7 +49,7 @@ = _("could_not_vote_currently") if show_registration - p.help-text.mb-2= _("registration_links_help_text", end=registration_end|datetimeformat) + p.help-text.mb-2= _("registration_links_help_text", end=registration_ends_at|datetimeformat) for title, url in votings p a.btn.btn-primary.btn-sm(href=url,target='_blank') @@ -57,10 +57,10 @@ = _('register_now_with_voting_module', title=title) if show_voting_without_url - p.help-text.mb-2= _("voting_info_text", end=voting_end|datetimeformat) + p.help-text.mb-2= _("voting_info_text", end=voting_ends_at|datetimeformat) if show_voting_with_url - p.help-text.mb-2= _("voting_links_help_text", end=voting_end|datetimeformat) + p.help-text.mb-2= _("voting_links_help_text", end=voting_ends_at|datetimeformat) for title, url in votings p a.btn.btn-primary.btn-sm(href=url,target='_blank') @@ -93,13 +93,13 @@ dt i.fas.fa-sign-in-alt   = _('registration_from') - dd= _('start_end_duration', start=registration_start|datetimeformat, end=registration_end|datetimeformat) + dd= _('start_end_duration', start=registration_starts_at|datetimeformat, end=registration_ends_at|datetimeformat) if show_voting_period dt i.fas.fa-person-booth   = _('voting_from') - dd= _('start_end_duration', start=voting_start|datetimeformat, end=voting_end|datetimeformat) + dd= _('start_end_duration', start=voting_starts_at|datetimeformat, end=voting_ends_at|datetimeformat) else dt= _('voting_status') dd= status|enum_value diff --git a/src/ekklesia_portal/concepts/voting_phase/voting_phase_cells.py b/src/ekklesia_portal/concepts/voting_phase/voting_phase_cells.py index 16830f4..eefe655 100644 --- a/src/ekklesia_portal/concepts/voting_phase/voting_phase_cells.py +++ b/src/ekklesia_portal/concepts/voting_phase/voting_phase_cells.py @@ -27,20 +27,22 @@ def show_new_button(self): @App.cell(VotingPhase) class VotingPhaseCell(LayoutCell): + _model: VotingPhase + model_properties = [ 'ballots', 'department', 'description', 'name', 'phase_type', - 'registration_end', - 'registration_start', + 'registration_ends_at', + 'registration_starts_at', 'secret', 'status', 'target', 'title', - 'voting_end', - 'voting_start', + 'voting_ends_at', + 'voting_starts_at', ] def show_edit_button(self): @@ -60,16 +62,16 @@ def show_voting_details(self): return False def show_registration_period(self): - if self.registration_end is None: + if self._model.registration_ends_at is None: return - return datetime.now() < self.registration_end + return datetime.now() < self._model.registration_ends_at def show_voting_period(self): - if self.voting_end is None: + if self._model.voting_ends_at is None: return - return datetime.now() < self.voting_end + return datetime.now() < self._model.voting_ends_at def can_participate_in_voting(self): user = self._request.current_user @@ -89,13 +91,13 @@ def show_registration(self): if not self.can_participate_in_voting: return - if self.registration_start is None: + if self._model.registration_starts_at is None: return if not self.votings: return - return self.registration_start < datetime.now() < self.registration_end + return self.registration_start < datetime.now() < self._model.registration_ends_at def show_will_be_able_to_vote(self): if self._request.current_user is None: @@ -104,10 +106,10 @@ def show_will_be_able_to_vote(self): if self._model.status not in (VotingStatus.PREPARING, VotingStatus.VOTING): return - if self.registration_start: - return datetime.now() < self.registration_start - elif self.voting_start: - return datetime.now() < self.voting_start + if self._model.registration_starts_at: + return datetime.now() < self._model.registration_starts_at + elif self._model.voting_starts_at: + return datetime.now() < self._model.voting_starts_at else: return True @@ -122,13 +124,13 @@ def show_voting_without_url(self): if not self.votings: return - if self.registration_start is None: + if self._model.registration_starts_at is None: return if self.voting_start is None: return - return self.voting_start < datetime.now() < self.voting_end + return self._model.voting_starts_at < datetime.now() < self._model.voting_ends_at def show_voting_with_url(self): """Determines if voting info should be shown. @@ -138,16 +140,16 @@ def show_voting_with_url(self): if not self.can_participate_in_voting: return - if self.registration_start is not None: + if self._model.registration_starts_at: return if not self.votings: return - if self.voting_start is None: + if self._model.voting_starts_at is None: return - return self.voting_start < datetime.now() < self.voting_end + return self._model.voting_starts_at < datetime.now() < self._model.voting_ends_at def show_result_link(self): """ @@ -156,10 +158,10 @@ def show_result_link(self): if not self.votings: return - if self.voting_end is None: + if self._model.voting_ends_at is None: return - return self.voting_end < datetime.now() + return self._model.voting_ends_at < datetime.now() def ballot_count(self): return len(self._model.ballots) @@ -276,7 +278,7 @@ def retrieve_voting_action(self): return self._request.link(self._model, "retrieve_voting") def allow_retrieve_results(self): - if self._model.voting_end is None: + if self._model.voting_ends_at is None: return False - return datetime.now() > self._model.voting_end + return datetime.now() > self._model.voting_ends_at diff --git a/src/ekklesia_portal/datamodel.py b/src/ekklesia_portal/datamodel.py index 3379501..512ca95 100644 --- a/src/ekklesia_portal/datamodel.py +++ b/src/ekklesia_portal/datamodel.py @@ -382,7 +382,7 @@ def ballots_can_be_added(self): return self.status == VotingStatus.PREPARING @property - def registration_start(self): + def registration_starts_at(self): if self.target is None: return @@ -397,7 +397,7 @@ def registration_start(self): return self.target - timedelta(days=days) @property - def registration_end(self): + def registration_ends_at(self): """Registration ends at `target - registration_end_days` or at `target` if registration_end_days is not set""" if self.target is None: @@ -415,14 +415,14 @@ def registration_end(self): @property def voting_can_be_created(self): - return self.status == VotingStatus.PREPARING and self.voting_start is not None and self.voting_end is not None + return self.status == VotingStatus.PREPARING and self.voting_starts_at is not None and self.voting_ends_at is not None @property def voting_can_be_retrieved(self): - return self.status == VotingStatus.FINISHED and self.voting_start is not None and self.voting_end is not None + return self.status == VotingStatus.FINISHED and self.voting_starts_at is not None and self.voting_ends_at is not None @property - def voting_start(self): + def voting_starts_at(self): if self.target is None: return @@ -434,7 +434,7 @@ def voting_start(self): return self.target - timedelta(days=days) @property - def voting_end(self): + def voting_ends_at(self): return self.target diff --git a/src/ekklesia_portal/lib/vvvote/election_config.py b/src/ekklesia_portal/lib/vvvote/election_config.py index 9a430ce..e56b4c0 100644 --- a/src/ekklesia_portal/lib/vvvote/election_config.py +++ b/src/ekklesia_portal/lib/vvvote/election_config.py @@ -62,10 +62,10 @@ def voting_phase_to_vvvote_election_config(module_config, phase) -> vvvote_schem phase_title = phase.title or phase.name or phase.phase_type.name required_phase_attrs = [ - "registration_start", - "registration_end", - "voting_start", - "voting_end", + "registration_starts_at", + "registration_ends_at", + "voting_starts_at", + "voting_ends_at", ] missing_attrs = [attr for attr in required_phase_attrs if getattr(phase, attr) is None] @@ -81,10 +81,10 @@ def voting_phase_to_vvvote_election_config(module_config, phase) -> vvvote_schem verified=module_config["must_be_verified"], nested_groups=[module_config["required_role"]], serverId=module_config["auth_server_id"], - RegistrationStartDate=phase.registration_start, - RegistrationEndDate=phase.registration_end, - VotingStart=phase.voting_start, - VotingEnd=phase.voting_end, + RegistrationStartDate=phase.registration_starts_at, + RegistrationEndDate=phase.registration_ends_at, + VotingStart=phase.voting_starts_at, + VotingEnd=phase.voting_ends_at, ) config = vvvote_schema.ElectionConfig( electionId=str(uuid4()),