diff --git a/scipost_django/colleges/forms.py b/scipost_django/colleges/forms.py index aefa515b3664beb36b87aac769ed0f49b3602420..467335b79c110a08123ea72239400b2bec772680 100644 --- a/scipost_django/colleges/forms.py +++ b/scipost_django/colleges/forms.py @@ -568,8 +568,8 @@ class FellowshipNominationDecisionForm(forms.ModelForm): css_class="row", ), ) - if voting_round: + self.fields["voting_round"].initial = voting_round self.fields["outcome"].initial = voting_round.vote_outcome 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 8944c9831ba8af1fd160944092c01817ee612dd2..aa9e4d6fbf2188a317cc3ae773e201e1d0dc37e7 100644 --- a/scipost_django/colleges/templates/colleges/_hx_nomination_decision_form.html +++ b/scipost_django/colleges/templates/colleges/_hx_nomination_decision_form.html @@ -1,26 +1,47 @@ {% load crispy_forms_tags %} {% load automarkup %} -{% if voting_round.decision %} - {{ voting_round.decision }} - <p>Fixed on: {{ voting_round.decision.fixed_on }}</p> +<div id="nomination-{{ voting_round.id }}-decision"> - {% if voting_round.decision.comments %} - <p>Comments:</p> - {% automarkup voting_round.decision.comments %} - {% endif %} + {% if voting_round.decision %} + + {% if voting_round.decision.outcome == 'elected' %} + <div class="badge fs-4 mb-2 bg-success">{{ voting_round.decision.get_outcome_display }}</div> + {% elif voting_round.decision.outcome == 'notelected' %} + <div class="badge fs-4 mb-2 bg-danger">{{ voting_round.decision.get_outcome_display }}</div> + {% endif %} + + {% if voting_round.decision.comments %} + <h5>Decision comments</h5> + <p>{{ voting_round.decision.comments }}</p> + {% endif %} + + {% else %} -{% else %} - {% with blocks=voting_round.decision_blocks %} + {% if "edadmin" in user_roles %} + + {% if not voting_round.is_open %} + {% 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 %} + {% else %} + <p class="text-warning">The voting round is still open. You many not draft a decision yet.</p> + {% endif %} - {% 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> + <p class="text-warning">No decision has been formulated yet.</p> {% endif %} - {% endwith %} -{% endif %} + {% endif %} + +</div> diff --git a/scipost_django/colleges/templates/colleges/_hx_nomination_li.html b/scipost_django/colleges/templates/colleges/_hx_nomination_li.html index 20f0263881830b690e31d7a871a0aaa353916e40..187f1f54e047c09039611c74c0b8ca84dded0aa8 100644 --- a/scipost_django/colleges/templates/colleges/_hx_nomination_li.html +++ b/scipost_django/colleges/templates/colleges/_hx_nomination_li.html @@ -50,7 +50,6 @@ <div id="nomination-{{ nomination.id }}-li-contents" hx-get="{% url 'colleges:_hx_nomination_li_contents' nomination_id=nomination.id %}" - hx-trigger="toggle from:#nomination-{{ nomination.id }}-li-details" - hx-target="this"></div> + hx-trigger="intersect once"></div> </details> </div> diff --git a/scipost_django/colleges/templates/colleges/_hx_nomination_li_contents.html b/scipost_django/colleges/templates/colleges/_hx_nomination_li_contents.html index b5e521051282722348740ef9a4bd718c7a31d720..a7d11ee58f2bc161f0a0d6de932621e01dc30bc8 100644 --- a/scipost_django/colleges/templates/colleges/_hx_nomination_li_contents.html +++ b/scipost_django/colleges/templates/colleges/_hx_nomination_li_contents.html @@ -118,8 +118,7 @@ <div id="nomination-{{ nomination.id }}-comments" hx-get="{% url 'colleges:_hx_nomination_comments' nomination_id=nomination.id %}" - hx-trigger="revealed" - hx-target="this"></div> + hx-trigger="intersect once"></div> </div> </details> </div> @@ -139,8 +138,7 @@ {% if round.is_open and session_fellowship in round.eligible_to_vote.all %} <div id="nomination-{{ round.nomination.id }}-vote" hx-get="{% url 'colleges:_hx_nomination_vote' voting_round_id=round.id %}" - hx-trigger="revealed" - hx-target="this"></div> + hx-trigger="intersect once"></div> {% else %} {% include "colleges/_hx_voting_round_results.html" with voting_round=round %} {% endif %} diff --git a/scipost_django/colleges/templates/colleges/_hx_nominations_invitations.html b/scipost_django/colleges/templates/colleges/_hx_nominations_invitations.html index dda5c98a5cd0c57bd109aba03e7cab1a452cc9f0..7b4a51157171e752c5ab980bcbd7eb696c96e8af 100644 --- a/scipost_django/colleges/templates/colleges/_hx_nominations_invitations.html +++ b/scipost_django/colleges/templates/colleges/_hx_nominations_invitations.html @@ -49,8 +49,7 @@ <h4>Update the response to this invitation:</h4> <div id="invitation-{{ invitation.id }}-update-response" hx-get="{% url 'colleges:_hx_fellowship_invitation_update_response' invitation_id=invitation.id %}" - hx-trigger="toggle from:#invitation-{{ invitation.id }}-details" - hx-target="this"></div> + hx-trigger="toggle from:#invitation-{{ invitation.id }}-details"></div> </div> </details> {% empty %} diff --git a/scipost_django/colleges/templates/colleges/_hx_nominations_needing_specialties.html b/scipost_django/colleges/templates/colleges/_hx_nominations_needing_specialties.html index d12155d46e71ee9bcbd39ba4be9b5031296f1c12..228dd433cb2e369878081e46377cfddb1192b56c 100644 --- a/scipost_django/colleges/templates/colleges/_hx_nominations_needing_specialties.html +++ b/scipost_django/colleges/templates/colleges/_hx_nominations_needing_specialties.html @@ -6,7 +6,7 @@ class="p-2 mt-2" hx-get="{% url 'profiles:_hx_profile_specialties' profile_id=nomination.profile.id %}" hx-trigger="toggle from:#nomination-{{ nomination.id }}-specialties"></div> - <button class="btn btn-success text-white m-2" + <button class="btn btn-success text-white m-2 nomination-specialties-done-btn" hx-get="{% url 'colleges:_hx_nominations_needing_specialties' %}" hx-target="#nominations_needing_specialties">Done</button> </details> diff --git a/scipost_django/colleges/templates/colleges/_hx_voting_round_results.html b/scipost_django/colleges/templates/colleges/_hx_voting_round_results.html index a6d5f3d3e2ab558281a220250aad72f30d7b5043..e82d9f903234c37a2f97d8f90d733aac48721608 100644 --- a/scipost_django/colleges/templates/colleges/_hx_voting_round_results.html +++ b/scipost_django/colleges/templates/colleges/_hx_voting_round_results.html @@ -5,36 +5,15 @@ <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="revealed" - hx-target="this"></div> + hx-trigger="intersect once"></div> {% endif %} <div class="row mb-0"> <div class="col-12 col-md mt-3"> <h3>Decision</h3> - {% if voting_round.decision.outcome == 'elected' %} - <div class="badge fs-4 ms-2 bg-success">{{ voting_round.decision.get_outcome_display }}</div> - {% elif voting_round.decision.outcome == 'notelected' %} - <div class="badge fs-4 ms-2 bg-danger">{{ voting_round.decision.get_outcome_display }}</div> - {% else %} - - {% if "edadmin" in user_roles %} - - {% if not voting_round.is_open %} - <div id="nomination-{{ nomination.id }}-decision_form" - hx-get="{% url 'colleges:_hx_nomination_decision_form' round_id=voting_round.id %}" - hx-trigger="revealed" - hx-target="this"></div> - {% else %} - <p class="text-warning">The voting round is still open. You many not draft a decision yet.</p> - {% endif %} - - {% else %} - <p class="text-warning">No decision has been formulated yet.</p> - {% endif %} - - {% endif %} + <div hx-get="{% url 'colleges:_hx_nomination_decision_form' round_id=voting_round.id %}" + 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> diff --git a/scipost_django/colleges/templates/colleges/_hx_voting_rounds_tablist.html b/scipost_django/colleges/templates/colleges/_hx_voting_rounds_tablist.html index 0758404ac3999f8e579bd4e18bd0294a70a2d97e..9e584c1255a8de13f3f6d22902b71ebb179d9383 100644 --- a/scipost_django/colleges/templates/colleges/_hx_voting_rounds_tablist.html +++ b/scipost_django/colleges/templates/colleges/_hx_voting_rounds_tablist.html @@ -1,7 +1,9 @@ <div class="tablist"> + {% for tab_choice in tab_choices %} - <a hx-get="{% url 'colleges:_hx_voting_rounds' %}?tab={{ tab_choice.0 }}" - {% if selected == tab_choice.0 %}class="selected"{% endif %} + <a hx-get="{% url 'colleges:_hx_voting_rounds' %}?tab={{ tab_choice.0 }}" hx-target="#voting_tablist" + {% if selected == tab_choice.0 %}class="selected"{% endif %} >{{ tab_choice.1 }}</a> {% endfor %} + </div> diff --git a/scipost_django/colleges/templates/colleges/nominations.html b/scipost_django/colleges/templates/colleges/nominations.html index d8eb941542c924e4238aa4712f33b7c14312b49e..4eaecfc68dbc04384293c47cf7bad35da8343809 100644 --- a/scipost_django/colleges/templates/colleges/nominations.html +++ b/scipost_django/colleges/templates/colleges/nominations.html @@ -113,12 +113,12 @@ <h3>Add specialties</h3> <div id="nominations_needing_specialties" hx-get="{% url 'colleges:_hx_nominations_needing_specialties' %}" - hx-trigger="toggle from:#ensure-specialties-details"></div> + hx-trigger="intersect once"></div> <h3 class="mt-4 ">Start round</h3> <div id="nominations_no_round_started" hx-get="{% url 'colleges:_hx_nominations_no_round_started' %}" - hx-trigger="toggle from:#ensure-specialties-details, click from:body target:.nomination-start-round-btn"> + hx-trigger="intersect once, click from:body target:.nomination-start-round-btn, click from:body target:.nomination-specialties-done-btn"> </div> </div> </details> @@ -138,10 +138,8 @@ </summary> <div class="p-2"> - <div id="voting_tablist" hx-get="{% url 'colleges:_hx_voting_rounds' %}?tab= - {% if 'edadmin' in user_roles %}ongoing{% else %}ongoing-vote_required{% endif %} - " hx-trigger="toggle from:#voting-details, click from:body target:.nomination-start-round-btn" hx-target="this" hx-swap="innerHTML"> - </div> + <div id="voting_tablist" hx-trigger="toggle from:#voting-details, click from:body target:.nomination-start-round-btn" + hx-get="{% url 'colleges:_hx_voting_rounds' %}?tab={% if 'edadmin' in user_roles %}ongoing{% else %}ongoing-vote_required{% endif %}" ></div> </div> </details> @@ -154,9 +152,7 @@ <div class="p-2 mt-2"> <div id="invitations_tablist" hx-get="{% url 'colleges:_hx_nominations_invitations' %}?response=notyetinvited" - hx-trigger="toggle from:#invitations-details" - hx-target="this" - hx-swap="innerHTML"></div> + hx-trigger="toggle from:#invitations-details"></div> </div> </details> {% endif %}