SciPost Code Repository

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

add new voting round button to nominations

parent c6ec10cf
No related branches found
No related tags found
1 merge request!58[Fellowship Nominations] Rework the fellowship nomination system and UI
...@@ -219,6 +219,14 @@ class FellowshipNominationVotingRound(models.Model): ...@@ -219,6 +219,14 @@ class FellowshipNominationVotingRound(models.Model):
def is_open(self): def is_open(self):
return self.voting_opens <= timezone.now() <= self.voting_deadline 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()
@property
def is_unscheduled(self):
return self.voting_opens is None or self.voting_deadline is None
@property @property
def vote_outcome(self): def vote_outcome(self):
"""The outcome as determined by the votes.""" """The outcome as determined by the votes."""
...@@ -244,7 +252,7 @@ class FellowshipNominationVotingRound(models.Model): ...@@ -244,7 +252,7 @@ class FellowshipNominationVotingRound(models.Model):
def can_view(self, user) -> bool: def can_view(self, user) -> bool:
"""Return whether the user can view this voting round. """Return whether the user can view this voting round.
They must be authenticated and have voting eligibility or be edadmin.""" They must be authenticated and have voting eligibility or be edadmin."""
eligibility_per_fellowship = [ eligibility_per_fellowship = [
fellowship in self.eligible_to_vote.all() fellowship in self.eligible_to_vote.all()
for fellowship in user.contributor.fellowships.all() for fellowship in user.contributor.fellowships.all()
......
...@@ -127,7 +127,7 @@ ...@@ -127,7 +127,7 @@
<div class="card"> <div class="card">
<div class="card-header">Voting Rounds</div> <div class="card-header">Voting Rounds</div>
<div class="card-body p-0"> <div class="card-body p-0">
<div hx-get="{% url 'colleges:_hx_nomination_voting_rounds_tab' nomination_id=nomination.id round_id=nomination.latest_voting_round.id %}" <div hx-get="{% url 'colleges:_hx_nomination_voting_rounds_tab' nomination_id=nomination.id round_id=nomination.latest_voting_round.id|default:0 %}"
hx-trigger="intersect once"></div> hx-trigger="intersect once"></div>
</div> </div>
</div> </div>
......
<div id="nomination-{{ nomination_id }}-round-tab-holder"> <div id="nomination-{{ nomination_id }}-round-tab-holder">
<nav class="nav nav-pills m-2 overflow-scroll"> <nav class="nav nav-pills m-2 overflow-scroll">
<div type="button" class="me-2 px-2 nav-link {% if new_round %}bg-success{% else %}border border-success{% endif %}"
hx-get="{% url 'colleges:_hx_nomination_voting_rounds_tab' nomination_id=nomination_id round_id=0 %}"
hx-target="#nomination-{{ nomination_id }}-round-tab-holder"
hx-swap="outerHTML">
<span class="fs-1 align-items-center text-{% if new_round %}white{% else %}success{% endif %}">+</span>
</div>
{% for voting_round in voting_rounds %} {% for voting_round in voting_rounds %}
<div type="button" class="nav-link {% if selected_round.id == voting_round.id %}active{% endif %} {% if voting_round.id in inaccessible_round_ids %}disabled opacity-50{% endif %}" <div type="button" class="me-2 nav-link {% if selected_round and selected_round.id == voting_round.id %}active{% endif %} {% if voting_round.id in inaccessible_round_ids %}disabled opacity-50{% endif %}"
hx-get="{% url 'colleges:_hx_nomination_voting_rounds_tab' nomination_id=nomination_id round_id=voting_round.id %}" hx-get="{% url 'colleges:_hx_nomination_voting_rounds_tab' nomination_id=nomination_id round_id=voting_round.id %}"
hx-target="#nomination-{{ nomination_id }}-round-tab-holder" hx-target="#nomination-{{ nomination_id }}-round-tab-holder"
hx-swap="outerHTML"> hx-swap="outerHTML">
<span class="d-block text-nowrap"> <span class="d-block text-nowrap">
<span class="d-flex justify-content-between"> <span class="d-flex justify-content-between">
<span>Round #{{ forloop.counter0|add:1 }}</span> <span>Round #{{ forloop.counter0|add:1 }}</span>
{% if voting_round.is_open %} {% if voting_round.is_unscheduled %}
<span class="text-danger">Uncheduled</span>
{% elif voting_round.is_scheduled %}
<span class="text-warning">Scheduled</span>
{% elif voting_round.is_open %}
<span class="text-success">Open</span> <span class="text-success">Open</span>
{% endif %} {% endif %}
</span> </span>
...@@ -21,8 +31,12 @@ ...@@ -21,8 +31,12 @@
</nav> </nav>
<div id="nomination-{{ nomination_id }}-round-{{ selected_round.id }}-tab-content-holder"> <div id="nomination-{{ nomination_id }}-round-{{ selected_round.id }}-tab-content-holder" class="mt-3 px-3">
{% include "colleges/_hx_voting_round_results.html" with voting_round=selected_round %} {% if new_round %}
Newrounds!
{% else %}
{% include "colleges/_hx_voting_round_results.html" with voting_round=selected_round %}
{% endif %}
</div> </div>
</div> </div>
<div class="px-3"> {% if "edadmin" in user_roles %}
<h3>Votes</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>
{% endif %}
{% if "edadmin" in user_roles %} <div class="row mb-0">
<h3>Votes</h3> <div class="col-12 col-md mt-3">
<div id="nomination-{{ nomination.id }}-round-{{ voting_round.id }}-votes" <h3>Decision</h3>
hx-get="{% url 'colleges:_hx_nomination_voter_table' round_id=voting_round.id %}"
hx-trigger="intersect once"></div>
{% endif %}
<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 %}" <div hx-get="{% url 'colleges:_hx_nomination_decision_form' round_id=voting_round.id %}"
hx-trigger="intersect once"></div> hx-trigger="intersect once"></div>
</div>
<div class="col-12 col-md mt-3">{% include "colleges/_voting_results_box.html" with voting_round=voting_round %}</div>
</div> </div>
<div class="col-12 col-md mt-3">{% include "colleges/_voting_results_box.html" with voting_round=voting_round %}</div>
</div> </div>
...@@ -912,9 +912,15 @@ def _hx_nomination_voting_rounds_tab(request, nomination_id, round_id): ...@@ -912,9 +912,15 @@ def _hx_nomination_voting_rounds_tab(request, nomination_id, round_id):
context = { context = {
"nomination_id": nomination_id, "nomination_id": nomination_id,
"voting_rounds": voting_rounds, "voting_rounds": voting_rounds,
"selected_round": voting_rounds.get(id=round_id),
"inaccessible_round_ids": inaccessible_round_ids, "inaccessible_round_ids": inaccessible_round_ids,
"new_round": False,
} }
if round_id == 0:
context["new_round"] = True
else:
context["selected_round"] = voting_rounds.get(id=round_id)
return render(request, "colleges/_hx_nomination_voting_rounds_tab.html", context) return render(request, "colleges/_hx_nomination_voting_rounds_tab.html", context)
......
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