diff --git a/scipost_django/colleges/forms.py b/scipost_django/colleges/forms.py index 17877d8ff3490a3f9f1db3a649705c6692bccad9..ee34488000d89501bf7f75c472b95113d432ea12 100644 --- a/scipost_django/colleges/forms.py +++ b/scipost_django/colleges/forms.py @@ -727,6 +727,10 @@ class FellowshipNominationDecisionForm(forms.ModelForm): "comments", ] + widgets = { + "comments": forms.Textarea(attrs={"rows": 4}), + } + def __init__(self, *args, **kwargs): voting_round = kwargs.pop("voting_round", None) super().__init__(*args, **kwargs) diff --git a/scipost_django/colleges/models/nomination.py b/scipost_django/colleges/models/nomination.py index 23b7dbda143bb54f5c009e95a3be8316bb616c48..d2c545c3155db10567574b503bf75bc4bf93e643 100644 --- a/scipost_django/colleges/models/nomination.py +++ b/scipost_django/colleges/models/nomination.py @@ -247,17 +247,23 @@ class FellowshipNominationVotingRound(models.Model): @property def is_open(self): - if self.voting_deadline is None or self.voting_opens is None: + if (self.voting_deadline is None) or (self.voting_opens is None): return False return self.voting_opens <= timezone.now() <= self.voting_deadline @property def is_scheduled(self): - return self.voting_deadline is not None and self.voting_opens > timezone.now() + return (self.voting_opens is not None) and (self.voting_opens > timezone.now()) @property def is_unscheduled(self): - return self.voting_opens is None or self.voting_deadline is None + return (self.voting_opens is None) or (self.voting_deadline is None) + + @property + def is_closed(self): + return (self.voting_deadline is not None) and ( + self.voting_deadline < timezone.now() + ) @property def vote_outcome(self): diff --git a/scipost_django/colleges/templates/colleges/_hx_nomination_voting_rounds_tab.html b/scipost_django/colleges/templates/colleges/_hx_nomination_voting_rounds_tab.html index d0eb327ec17931a892315ef34738ca8e74fae005..6d9dd5649c2ed48d5115294358328442dce8f1e8 100644 --- a/scipost_django/colleges/templates/colleges/_hx_nomination_voting_rounds_tab.html +++ b/scipost_django/colleges/templates/colleges/_hx_nomination_voting_rounds_tab.html @@ -33,15 +33,22 @@ </div> {% endfor %} + <div id="indicator-nomination-{{ nomination_id }}-details-contents" + class="htmx-indicator p-2 ms-auto"> + <button class="btn btn-warning" type="button" disabled> + <strong>Loading ...</strong> + + <div class="spinner-grow spinner-grow-sm ms-2" + role="status" + aria-hidden="true"></div> + </button> + </div> + </nav> {% if selected_round %} <div id="nomination-{{ nomination_id }}-round-{{ selected_round.id }}-tab-content-holder" class="mt-3 px-3"> - {% if selected_round.is_unscheduled %} - {% include "colleges/_hx_voting_round_creation.html" with voting_round=selected_round round_start_form=round_start_form %} - {% else %} - {% include "colleges/_hx_voting_round_results.html" with voting_round=selected_round %} - {% endif %} + {% include "colleges/_hx_voting_round_details.html" with voting_round=selected_round round_start_form=round_start_form %} </div> {% endif %} diff --git a/scipost_django/colleges/templates/colleges/_hx_voting_round_details.html b/scipost_django/colleges/templates/colleges/_hx_voting_round_details.html index fb76f950a4bf888d089449548f225c328953242c..90c468e36a6197105319e6e11aca1461b06ca531 100644 --- a/scipost_django/colleges/templates/colleges/_hx_voting_round_details.html +++ b/scipost_django/colleges/templates/colleges/_hx_voting_round_details.html @@ -1,11 +1,36 @@ -<details id="round-{{ round.id }}-details" - class="border border-2 mx-3 p-2 bg-primary bg-opacity-10"> - <summary class="list-none">{% include "colleges/_hx_voting_round_summary.html" with round=round %}</summary> +{% load crispy_forms_tags %} - <div id="round-{{ round.id }}-details-contents" - class="p-2 mt-2 bg-white" - hx-get="{% url 'colleges:_hx_voting_round_li_contents' round_id=round.id %}" - hx-trigger="toggle once from:#round-{{ round.id }}-details" - hx-indicator="#indicator-round-{{ round.id }}-details-contents"></div> +<div class="row"> + <div class="col"> + <h3>Eligible voters</h3> + <div id="nomination-{{ nomination.id }}-round-{{ voting_round.id }}-votes" + hx-get="{% url 'colleges:_hx_nomination_voter_table' round_id=voting_round.id %}" + hx-trigger="intersect once"></div> + </div> -</details> + {% if "edadmin" in user_roles and not voting_round.is_closed %} + <div class="col-4"> + <h4>Add new voter</h4> + bla + </div> + {% endif %} + +</div> + +{% if voting_round.is_closed %} + <div class="row mb-0"> + <div class="col-12 col-md mt-3"> + <h3>Decision</h3> + + <div hx-get="{% url 'colleges:_hx_nomination_decision_form' round_id=voting_round.id %}" + hx-trigger="intersect once"></div> + + </div> + <div class="col-auto mt-3">{% include "colleges/_voting_results_box.html" with voting_round=voting_round %}</div> + </div> +{% elif "edadmin" in user_roles %} + <div class="col-12"> + <h4>Start round</h4> + {% crispy round_start_form %} + </div> +{% endif %} diff --git a/scipost_django/colleges/templates/colleges/_voting_results_box.html b/scipost_django/colleges/templates/colleges/_voting_results_box.html index 043d5894f8f0c1cd14bf3c5a9214d0c69a98d738..11592a769aaf5d6b96d315a0d24e5f81bf95b4c3 100644 --- a/scipost_django/colleges/templates/colleges/_voting_results_box.html +++ b/scipost_django/colleges/templates/colleges/_voting_results_box.html @@ -1,8 +1,8 @@ <h3>Summary</h3> -<ul class="list-inline m-2"> - <li class="list-inline-item p-2 text-muted">Eligible: {{ voting_round.eligible_to_vote.count }}</li> - <li class="list-inline-item p-2 text-success">Agree: {{ voting_round.votes.agree.count }}</li> - <li class="list-inline-item p-2 text-warning">Abstain: {{ voting_round.votes.abstain.count }}</li> - <li class="list-inline-item p-2 text-danger">Disagree: {{ voting_round.votes.disagree.count }}</li> - <li class="list-inline-item p-2 text-black">Veto: {{ voting_round.votes.veto.count }}</li> +<ul class="list-group list-group-flush m-2"> + <li class="list-group-item p-2 text-muted">Eligible: {{ voting_round.eligible_to_vote.count }}</li> + <li class="list-group-item p-2 text-success">Agree: {{ voting_round.votes.agree.count }}</li> + <li class="list-group-item p-2 text-warning">Abstain: {{ voting_round.votes.abstain.count }}</li> + <li class="list-group-item p-2 text-danger">Disagree: {{ voting_round.votes.disagree.count }}</li> + <li class="list-group-item p-2 text-black">Veto: {{ voting_round.votes.veto.count }}</li> </ul>