diff --git a/scipost_django/colleges/templates/colleges/_hx_nomination_voter_table.html b/scipost_django/colleges/templates/colleges/_hx_nomination_voter_table.html index 06e377f0dc40d7b2df3070d2179459a1bdb6def0..ba7b5587e5f6f9954e667b8d7c3dc747d728f368 100644 --- a/scipost_django/colleges/templates/colleges/_hx_nomination_voter_table.html +++ b/scipost_django/colleges/templates/colleges/_hx_nomination_voter_table.html @@ -5,6 +5,7 @@ <th>Fellow</th> <th>Vote</th> <th>Voted on</th> + <th>Actions</th> </tr> </thead> @@ -29,9 +30,18 @@ {% endif %} <td>{{ voter.vote.on }}</td> + + <td> + + {% if not round.is_closed %} + <a class="btn btn-sm btn-danger px-1 py-0 ms-auto">{% include "bi/trash-fill.html" %}</a> + {% endif %} + + </td> </tr> {% endfor %} + </tbody> </table> {% else %} 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 90c468e36a6197105319e6e11aca1461b06ca531..6ff4316bbbade0c89f6202cf947bb39494593dc2 100644 --- a/scipost_django/colleges/templates/colleges/_hx_voting_round_details.html +++ b/scipost_django/colleges/templates/colleges/_hx_voting_round_details.html @@ -11,7 +11,10 @@ {% if "edadmin" in user_roles and not voting_round.is_closed %} <div class="col-4"> <h4>Add new voter</h4> - bla + <h4>Add senior fellows</h4> + <button type="button" class="mb-2 btn btn-primary btn-sm">With specialty overlap</button> + <button type="button" class="mb-2 btn btn-warning text-white btn-sm">ALL seniors</button> + {{ form }} </div> {% endif %} diff --git a/scipost_django/colleges/views.py b/scipost_django/colleges/views.py index 603ec3bca19f3a79dbcb8d97698759ea4527ba00..2874e04ed66557433728cb9ab2416b43c155a10e 100644 --- a/scipost_django/colleges/views.py +++ b/scipost_django/colleges/views.py @@ -921,19 +921,20 @@ def _hx_nomination_voting_rounds_tab(request, nomination_id, round_id): selected_round = voting_rounds.get(id=round_id) context["selected_round"] = selected_round - round_start_form = FellowshipNominationVotingRoundStartForm( - request.POST or None, - instance=selected_round, - ) - - if round_start_form.is_valid(): - round_start_form.save() - messages.success( - request, - f"Voting round for {nomination.profile} started " - f"from {selected_round.voting_opens} until {selected_round.voting_deadline}.", + if not round.is_closed(): + round_start_form = FellowshipNominationVotingRoundStartForm( + request.POST or None, + instance=selected_round, ) - context["round_start_form"] = round_start_form + + if round_start_form.is_valid(): + round_start_form.save() + messages.success( + request, + f"Voting round for {nomination.profile} started " + f"from {selected_round.voting_opens} until {selected_round.voting_deadline}.", + ) + context["round_start_form"] = round_start_form return render(request, "colleges/_hx_nomination_voting_rounds_tab.html", context) @@ -1254,3 +1255,19 @@ def _hx_nomination_voter_table(request, round_id): "round": round, } return render(request, "colleges/_hx_nomination_voter_table.html", context) + + +@login_required +@user_passes_test(is_edadmin) +def _hx_nomination_round_eligible_voter_action( + request, round_id, fellowship_id, action +): + round = get_object_or_404(FellowshipNominationVotingRound, pk=round_id) + fellowship = get_object_or_404(Fellowship, pk=fellowship_id) + if action == "add": + round.eligible_to_vote.add(fellowship) + if action == "remove": + round.eligible_to_vote.remove(fellowship) + return redirect( + reverse("colleges:_hx_nomination_voter_table", kwargs={"round_id": round.id}) + )