From 8d93b3c55c4785e2ebc2fda9fdef4b76b8199ed2 Mon Sep 17 00:00:00 2001 From: George Katsikas <giorgakis.katsikas@gmail.com> Date: Fri, 29 Sep 2023 15:58:52 +0200 Subject: [PATCH] change layout for nomination decisions --- .../_hx_nomination_decision_form.html | 58 ++-------- .../colleges/_hx_voting_round_details.html | 105 ++++++++++-------- 2 files changed, 64 insertions(+), 99 deletions(-) diff --git a/scipost_django/colleges/templates/colleges/_hx_nomination_decision_form.html b/scipost_django/colleges/templates/colleges/_hx_nomination_decision_form.html index dc9e78564..4435e60ca 100644 --- a/scipost_django/colleges/templates/colleges/_hx_nomination_decision_form.html +++ b/scipost_django/colleges/templates/colleges/_hx_nomination_decision_form.html @@ -2,58 +2,16 @@ {% load automarkup %} <div id="nomination-{{ voting_round.id }}-decision"> + {% with blocks=voting_round.decision_blocks %} - {% if voting_round.decision %} - <div class="row"> - <div class="col-auto"> - <h3>Decision</h3> - - {% if voting_round.decision.outcome == 'elected' %} - <div class="badge fs-5 mb-2 bg-success">{{ voting_round.decision.get_outcome_display }}</div> - {% elif voting_round.decision.outcome == 'notelected' %} - <div class="badge fs-5 mb-2 bg-danger">{{ voting_round.decision.get_outcome_display }}</div> - {% endif %} - - </div> - - {% if voting_round.decision.comments %} - <div class="col"> - <h4>Decision comments</h4> - <p>{{ voting_round.decision.comments }}</p> - </div> - {% endif %} - - </div> - - {% else %} - - {% if "edadmin" in user_roles %} - - {% if voting_round.is_open %} - <p class="text-warning">The voting round is still open. You many not draft a decision yet.</p> - {% elif voting_round.is_scheduled %} - <p class="text-warning">The voting round is scheduled but has not yet started.</p> - {% elif voting_round.is_unscheduled %} - <p class="text-warning">The voting round is not yet scheduled.</p> - {% else %} - {% with blocks=voting_round.decision_blocks %} - - {% if blocks %} - <p>The decision cannot be fixed at this moment: {{ blocks }}</p> - {% else %} - <form hx-post="{% url 'colleges:_hx_nomination_decision_form' round_id=voting_round.id %}" - hx-target="#nomination-{{ voting_round.id }}-decision"> - {% crispy decision_form %} - </form> - {% endif %} - - {% endwith %} - {% endif %} - + {% if blocks %} + <p>The decision cannot be fixed at this moment: {{ blocks }}</p> {% else %} - <p class="text-warning">No decision has been formulated yet.</p> + <form hx-post="{% url 'colleges:_hx_nomination_decision_form' round_id=voting_round.id %}" + hx-target="#nomination-{{ voting_round.id }}-decision"> + {% crispy decision_form %} + </form> {% endif %} - {% endif %} - + {% endwith %} </div> 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 1c803bd2e..ac91b51e5 100644 --- a/scipost_django/colleges/templates/colleges/_hx_voting_round_details.html +++ b/scipost_django/colleges/templates/colleges/_hx_voting_round_details.html @@ -8,43 +8,54 @@ hx-trigger="intersect once"></div> </div> - {% if "edadmin" in user_roles and not voting_round.is_closed %} - <div class="col-4"> - <h4>Add new voter</h4> - <form hx-post="{% url 'colleges:_hx_fellowship_dynsel_list' %}" - hx-trigger="keyup delay:200ms, change" - hx-target="#nomination-{{ voting_round.nomination.id }}_round-{{ voting_round.id }}_add_voter_results"> - <div id="nomination-{{ voting_round.nomination.id }}_round-{{ voting_round.id }}_add_voter_form"> - {% crispy voter_add_form %} - </div> - </form> - <div id="nomination-{{ voting_round.nomination.id }}_round-{{ voting_round.id }}_add_voter_results"></div> - <h5>Add senior fellows</h5> - <button type="button" - class="mb-2 btn btn-primary btn-sm" - hx-get="{% url 'colleges:_hx_nomination_round_add_eligible_voter_set' round_id=voting_round.id voter_set_name='with_specialty_overlap' %}" - hx-target="#nomination-{{ voting_round.nomination.id }}-round-{{ voting_round.id }}-voters"> - With specialty overlap - </button> - <button type="button" - class="mb-2 btn btn-warning text-white btn-sm" - hx-get="{% url 'colleges:_hx_nomination_round_add_eligible_voter_set' round_id=voting_round.id voter_set_name='all_seniors' %}" - hx-target="#nomination-{{ voting_round.nomination.id }}-round-{{ voting_round.id }}-voters"> - ALL seniors - </button> - </div> + <div class="col-auto d-flex flex-column justify-content-between"> + + {% if not voting_round.is_closed %} + + {% if "edadmin" in user_roles %} - {% elif session_fellowship and session_fellowship in voting_round.eligible_to_vote.all %} - - {% if voting_round.is_open %} - <div id="nomination-{{ voting_round.nomination.id }}-vote" - class="col-12 col-md-4" - hx-get="{% url 'colleges:_hx_nomination_vote' voting_round_id=voting_round.id %}" - hx-trigger="intersect once"></div> - {% elif voting_round.decision %} - <div class="col-12 col-md-4 d-flex flex-column justify-content-between"> - <div>{% include "colleges/_voting_results_box.html" with voting_round=voting_round %}</div> + <div> + <h4>Add new voter</h4> + <form hx-post="{% url 'colleges:_hx_fellowship_dynsel_list' %}" + hx-trigger="keyup delay:200ms, change" + hx-target="#nomination-{{ voting_round.nomination.id }}_round-{{ voting_round.id }}_add_voter_results"> + <div id="nomination-{{ voting_round.nomination.id }}_round-{{ voting_round.id }}_add_voter_form"> + {% crispy voter_add_form %} + </div> + </form> + <div id="nomination-{{ voting_round.nomination.id }}_round-{{ voting_round.id }}_add_voter_results"></div> + </div> + + <div> + <h5>Add senior fellows</h5> + <button type="button" + class="mb-2 btn btn-primary btn-sm" + hx-get="{% url 'colleges:_hx_nomination_round_add_eligible_voter_set' round_id=voting_round.id voter_set_name='with_specialty_overlap' %}" + hx-target="#nomination-{{ voting_round.nomination.id }}-round-{{ voting_round.id }}-voters"> + With specialty overlap + </button> + <button type="button" + class="mb-2 btn btn-warning text-white btn-sm" + hx-get="{% url 'colleges:_hx_nomination_round_add_eligible_voter_set' round_id=voting_round.id voter_set_name='all_seniors' %}" + hx-target="#nomination-{{ voting_round.nomination.id }}-round-{{ voting_round.id }}-voters"> + ALL seniors + </button> + </div> + + {% elif session_fellowship and session_fellowship in voting_round.eligible_to_vote.all %} + + <div id="nomination-{{ voting_round.nomination.id }}-vote" + class="col-12 col-md-4" + hx-get="{% url 'colleges:_hx_nomination_vote' voting_round_id=voting_round.id %}" + hx-trigger="intersect once"></div> + + {% endif %} + + {% else %} + <div>{% include "colleges/_voting_results_box.html" with voting_round=voting_round %}</div> + + {% if voting_round.decision %} <div> <h3>Decision</h3> @@ -58,32 +69,28 @@ <h4 class="mt-2">Decision comments</h4> <span>{{ voting_round.decision.comments }}</span> {% endif %} - - </div> + {% endif %} </div> - {% endif %} - {% endif %} - + </div> </div> {% if "edadmin" in user_roles %} - {% if voting_round.is_closed %} - <div class="row mb-0"> - <div class="col-12 col-md mt-3"> - <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> - {% else %} + {% if not voting_round.is_closed %} + <div class="col-12"> <h4>Start round</h4> {% crispy round_start_form %} </div> + + {% elif voting_round.is_closed and not voting_round.decision %} + + <div hx-get="{% url 'colleges:_hx_nomination_decision_form' round_id=voting_round.id %}" + hx-trigger="intersect once"></div> + {% endif %} {% endif %} -- GitLab