Skip to content

Commit

Permalink
feat: Display and bulk-edit nomcom position flags (#4681) (#5878)
Browse files Browse the repository at this point in the history
This adds a table to show the state of all nomcom positions, and lets the
chair set or un-set multiple state flags at the same time.

As a consequence, it moves the email templates to the "Edit position" form.
  • Loading branch information
pselkirk committed Jun 26, 2023
1 parent 9ae860f commit 98bf7af
Show file tree
Hide file tree
Showing 3 changed files with 164 additions and 45 deletions.
35 changes: 35 additions & 0 deletions ietf/nomcom/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,41 @@ def edit_template(request, year, template_id):
def list_positions(request, year):
nomcom = get_nomcom_by_year(year)
positions = nomcom.position_set.order_by('-is_open')
if request.method == 'POST':
if nomcom.group.state_id != 'active':
messages.warning(request, "This nomcom is not active. Request administrative assistance if Position state needs to change.")
else:
action = request.POST.get('action')
positions_to_modify = request.POST.getlist('selected')
if positions_to_modify:
positions = positions.filter(id__in=positions_to_modify)
if action == "set_iesg":
positions.update(is_iesg_position=True)
messages.success(request,'The selected positions have been set as IESG Positions')
elif action == "unset_iesg":
positions.update(is_iesg_position=False)
messages.success(request,'The selected positions have been set as NOT IESG Positions')
elif action == "set_open":
positions.update(is_open=True)
messages.success(request,'The selected positions have been set as Open')
elif action == "unset_open":
positions.update(is_open=False)
messages.success(request,'The selected positions have been set as NOT Open')
elif action == "set_accept_nom":
positions.update(accepting_nominations=True)
messages.success(request,'The selected positions have been set as Accepting Nominations')
elif action == "unset_accept_nom":
positions.update(accepting_nominations=False)
messages.success(request,'The selected positions have been set as NOT Accepting Nominations')
elif action == "set_accept_fb":
positions.update(accepting_feedback=True)
messages.success(request,'The selected positions have been set as Accepting Feedback')
elif action == "unset_accept_fb":
positions.update(accepting_feedback=False)
messages.success(request,'The selected positions have been set as NOT Accepting Feedback')
positions = nomcom.position_set.order_by('-is_open')
else:
messages.warning(request, "Please select some positions to work with")

return render(request, 'nomcom/list_positions.html',
{'positions': positions,
Expand Down
11 changes: 10 additions & 1 deletion ietf/templates/nomcom/edit_position.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,14 @@ <h2>
{% if position %}Save{% else %}Add{% endif %}</button>
<a class="btn btn-secondary float-end" href="../">Back</a>
</form>
{% if position.name %}
<h3>
Templates
</h3>
{% for template in position.get_templates %}
<a href="{% url 'ietf.nomcom.views.edit_template' year template.id %}">{{ template }}</a>
<br>
{% endfor %}
{% endif %}
{% endblock %}
{% block content_end %}{{ form.media.js }}{% endblock %}
{% block content_end %}{{ form.media.js }}{% endblock %}
163 changes: 119 additions & 44 deletions ietf/templates/nomcom/list_positions.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "nomcom/nomcom_private_base.html" %}
{# Copyright The IETF Trust 2015, All Rights Reserved #}
{% load origin %}
{% load origin static %}
{% block subtitle %}- Positions{% endblock %}
{% block nomcom_content %}
{% origin %}
Expand All @@ -13,54 +13,129 @@ <h2 class="mb-3">Positions in {{ nomcom.group }}</h2>
<a href="{% url 'ietf.nomcom.views.configuration_help' year=nomcom.year %}">Configuration Hints</a>.
</p>
{% endif %}

{% if nomcom.group.state_id == 'active' %}
<form class="form-inline" id="batch-action-form" method="post">
{% csrf_token %}
{% endif %}
{% if positions %}
{% regroup positions by is_open as posgroups %}
{% for group in posgroups %}
<h3>{{ group.grouper| yesno:"Open Positions,Closed Positions" }}</h3>
{% for position in group.list %}
<h4>
{{ position.name }}
{% if position.is_iesg_position %}(IESG){% endif %}
</h4>
{% if group.grouper %}
<dl class="row">
<dt class="col-sm-2">
Accepting
</dt>
<dd class="col-sm-10">
{% if position.accepting_nominations %}Nominations{% endif %}
{% if position.accepting_nominations and position.accepting_feedback %}and{% endif %}
{% if position.accepting_feedback %}Feedback{% endif %}
</dd>
</dl>
{% endif %}
<dl class="row">
<dt class="col-sm-2">
Templates
</dt>
<dd class="col-sm-10">
{% for template in position.get_templates %}
<a href="{% url 'ietf.nomcom.views.edit_template' year template.id %}">{{ template }}</a>
<br>
{% endfor %}
</dd>
<table class="table table-sm table-striped table-hover tablesorter"
id="position-table">
<thead>
<tr>
{% if nomcom.group.state_id == 'active' %}
<dt class="col-sm-2">
Actions
</dt>
<dd class="col-sm-10">
<a class="btn btn-primary btn-sm"
href="{% url 'ietf.nomcom.views.edit_position' year position.id %}">Edit</a>
<a class="btn btn-danger btn-sm"
href="{% url 'ietf.nomcom.views.remove_position' year position.id %}">Remove</a>
</dd>
<th scope="colgroup" colspan="3">
<i class="bi bi-check"></i>
</th>
{% endif %}
</dl>
{% endfor %}
{% endfor %}
<th scope="col" data-sort="position">
Position
</th>
<th scope="col" data-sort="iesg">
IESG
</th>
<th scope="col" data-sort="open">
Open
</th>
<th scope="col" data-sort="accept_nom">
Accepting Nominations
</th>
<th scope="col" data-sort="accept_fb">
Accepting Feedback
</th>
</tr>
</thead>
<tbody>
<!-- [html-validate-disable-block input-missing-label -- labelled via aria-label] -->
{% for position in positions %}
<tr>
{% if nomcom.group.state_id == 'active' %}
<td>
<input class="batch-select form-check-input"
type="checkbox"
value="{{ position.id }}"
id="id-{{ position.id }}"
aria-label="position.name"
name="selected">
</td>
<td class="edit">
<a class="btn btn-primary btn-sm"
href="{% url 'ietf.nomcom.views.edit_position' year position.id %}">
Edit
</a>
</td>
<td class="remove">
<a class="btn btn-danger btn-sm"
href="{% url 'ietf.nomcom.views.remove_position' year position.id %}">
Remove
</a>
</td>
{% endif %}
<td>
{{ position.name }}
</td>
<td>
{{ position.is_iesg_position|yesno:"✓," }}
</td>
<td>
{{ position.is_open|yesno:"✓," }}
</td>
<td>
{{ position.accepting_nominations|yesno:"✓," }}
</td>
<td>
{{ position.accepting_feedback|yesno:"✓," }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% if nomcom.group.state_id == 'active' %}
<div class="mb-3">
<label class="form-label" for="action">
Action:
</label>
<select class="form-select" name="action" id="action">
<option value="" selected="selected">
---------
</option>
<option value="set_iesg">
Is IESG Position: Yes
</option>
<option value="unset_iesg">
Is IESG Position: No
</option>
<option value="set_open">
Is Open: Yes
</option>
<option value="unset_open">
Is Open: No
</option>
<option value="set_accept_nom">
Is Accepting Nominations: Yes
</option>
<option value="unset_accept_nom">
Is Accepting Nominations: No
</option>
<option value="set_accept_bf">
Is Accepting Feedback: Yes
</option>
<option value="unset_accept_fb">
Is Accepting Feedback: No
</option>
</select>
</div>
<button class="btn btn-warning" type="submit" title="Run action">
Apply
</button>
</form>
{% endif %}
{% else %}
<p>
There are no positions defined.
</p>
{% endif %}
{% endblock %}
{% endblock %}
{% block js %}
<script src="{% static "ietf/js/list.js" %}"></script>
{% endblock %}

0 comments on commit 98bf7af

Please sign in to comment.