SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit 228c82d2 authored by George Katsikas's avatar George Katsikas :goat:
Browse files

refactor nominations round voting table

parent a51b1b3f
No related branches found
No related tags found
1 merge request!58[Fellowship Nominations] Rework the fellowship nomination system and UI
......@@ -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)
......
......@@ -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):
......
......@@ -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 %}
......
<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 %}
<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>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment