Skip to content

Commit da351ed

Browse files
committed
Add batch actions form to change nomination states.
See ietf-tools#965 - Legacy-Id: 5481
1 parent 7118f9c commit da351ed

3 files changed

Lines changed: 112 additions & 47 deletions

File tree

ietf/nomcom/admin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class NomineeAdmin(admin.ModelAdmin):
1919
class NomineePositionAdmin(admin.ModelAdmin):
2020
pass
2121
list_display = ('nominee', 'position', 'state')
22-
list_filter = ('state',)
22+
list_filter = ('state', 'position')
2323

2424

2525
class PositionAdmin(admin.ModelAdmin):

ietf/nomcom/views.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,23 @@ def private_key(request, year):
5656
@member_required(role='member')
5757
def private_index(request, year):
5858
nomcom = get_nomcom_by_year(year)
59+
is_chair = nomcom.group.is_chair(request.user)
60+
message = None
61+
if is_chair and request.method == 'POST':
62+
action = request.POST.get('action')
63+
nominations_to_modify = request.POST.getlist('selected')
64+
if nominations_to_modify:
65+
if action == "set_as_accepted":
66+
NomineePosition.objects.filter(id__in=nominations_to_modify).update(state='accepted')
67+
message = ('success', 'The selected nominations has been set as accepted')
68+
elif action == "set_as_declined":
69+
NomineePosition.objects.filter(id__in=nominations_to_modify).update(state='declined')
70+
message = ('success', 'The selected nominations has been set as declined')
71+
elif action == "set_as_pending":
72+
NomineePosition.objects.filter(id__in=nominations_to_modify).update(state='pending')
73+
message = ('success', 'The selected nominations has been set as pending')
74+
else:
75+
message = ('warning', "Please, select some nominations to work with")
5976

6077
filters = {}
6178
selected_state = request.GET.get('state')
@@ -80,9 +97,11 @@ def private_index(request, year):
8097
for s in stats:
8198
for state in states:
8299
if state['slug'] == 'questionnaire':
83-
s[state['slug']] = NomineePosition.objects.filter(position__name=s['position__name'], questionnaires__isnull=False).count()
100+
s[state['slug']] = NomineePosition.objects.filter(position__name=s['position__name'],
101+
questionnaires__isnull=False).count()
84102
else:
85-
s[state['slug']] = NomineePosition.objects.filter(position__name=s['position__name'], state=state['slug']).count()
103+
s[state['slug']] = NomineePosition.objects.filter(position__name=s['position__name'],
104+
state=state['slug']).count()
86105

87106
return render_to_response('nomcom/private_index.html',
88107
{'nomcom': nomcom,
@@ -93,7 +112,9 @@ def private_index(request, year):
93112
'positions': positions,
94113
'selected_state': selected_state,
95114
'selected_position': selected_position and int(selected_position) or None,
96-
'selected': 'index'}, RequestContext(request))
115+
'selected': 'index',
116+
'is_chair': is_chair,
117+
'message': message}, RequestContext(request))
97118

98119

99120
@member_required(role='chair')

ietf/templates/nomcom/private_index.html

Lines changed: 87 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,66 +4,110 @@
44

55
{% block nomcom_content %}
66

7-
<h2>Nomine administration</h2>
8-
<p>The following is a list of registered nominees. (You can <a href="#"> request confirmation<a> from nominees if they haven't
9-
replied to the nomination notification they have received.)</p>
10-
117
<h2>Nominations stats</h2>
128

139
<table class="ietf-table ietf-doctable">
1410
<tr>
1511
<th>Position</th>
1612
<th>Accepted</th>
1713
<th>Declined</th>
18-
<th>Questionnaire</th>
1914
<th>Pending</th>
15+
<th>Questionnaire</th>
2016
<th>Total</th>
2117
</tr>
2218
{% for item in stats %}
2319
<tr class="{{ forloop.counter|divisibleby:2|yesno:"oddrow,evenrow" }}">
24-
<td>
25-
{{ item.position__name }}
26-
</td>
27-
<td>
28-
{{ item.accepted }}
29-
</td>
30-
<td>
31-
{{ item.declined }}
32-
</td>
33-
<td>
34-
{{ item.questionnaire }}
35-
</td>
36-
<td>
37-
{{ item.pending }}
38-
</td>
39-
<td>
40-
{{ item.total }}
41-
</td>
20+
<td>{{ item.position__name }}</td>
21+
<td>{{ item.accepted }}</td>
22+
<td>{{ item.declined }}</td>
23+
<td>{{ item.pending }}</td>
24+
<td>{{ item.questionnaire }}</td>
25+
<td>{{ item.total }}</td>
4226
</tr>
4327
{% endfor %}
4428
</table>
4529

30+
<div style="padding: 8px 0 8px 0;"></div>
31+
32+
<div class="ietf-box diffTool">
33+
<h2>Select Filters</h2>
34+
35+
<form action="" method="get">
36+
<table>
37+
<tr>
38+
<td>
39+
<label>State</label>
40+
<select name="state">
41+
<option value="">All</option>
42+
{% for state in states %}
43+
<option value="{{ state.slug }}"
44+
{% ifequal state.slug selected_state %}selected="selected"{% endifequal%}>
45+
{{ state.name }}
46+
</option>
47+
{% endfor %}
48+
</select>
49+
</td>
50+
<td rowspan="2" valign="top">
51+
<label>Position:</label>
52+
<select name="position">
53+
<option value="">All</option>
54+
{% for position in positions %}
55+
<option value="{{ position.position__id }}"
56+
{% ifequal position.position__id selected_position %}selected="selected"{% endifequal%}>
57+
{{ position.position__name }}
58+
</option>
59+
{% endfor %}
60+
</select>
61+
<input name="submit" value="Go!" type="submit" />
62+
</td>
63+
</tr>
64+
</table>
65+
</form>
66+
</div>
67+
4668
<h2>List of nominees</h2>
4769

48-
<table class="ietf-table ietf-doctable">
49-
<tr>
50-
<th>Nominees</th>
51-
<th>Position</th>
52-
<th>State</th>
53-
</tr>
54-
{% for np in nominee_positions %}
55-
<tr class="{{ forloop.counter|divisibleby:2|yesno:"oddrow,evenrow" }}">
56-
<td>
57-
{{ np.nominee }}
58-
</td>
59-
<td>
60-
{{ np.position }}
61-
</td>
62-
<td class="status">
63-
{{ np.state }}
64-
</td>
65-
</tr>
66-
{% endfor %}
67-
</table>
70+
{% if is_chair %}
71+
<form id="batch-action-form" method="post" action="">
72+
{% if message %}
73+
<div class="info-message-{{ message.0 }}">{{ message.1 }}</div>
74+
{% endif %}
75+
<div class="actions">
76+
<label>Action:
77+
<select name="action">
78+
<option value="" selected="selected">---------</option>
79+
<option value="set_as_accepted">Set as accepted</option>
80+
<option value="set_as_pending">Set as pending</option>
81+
<option value="set_as_declined">Set as declined</option>
82+
</select>
83+
</label>
84+
<button type="submit" title="Run action">Go</button>
85+
</div>
86+
{% endif %}
87+
88+
<table class="ietf-table ietf-doctable">
89+
<tr>
90+
{% if is_chair %}<th>&#x2713;</th>{% endif %}
91+
<th>Nominees</th>
92+
<th>Position</th>
93+
<th>State</th>
94+
<th>Questionnaire</th>
95+
</tr>
96+
{% for np in nominee_positions %}
97+
<tr class="{{ forloop.counter|divisibleby:2|yesno:"oddrow,evenrow" }}">
98+
{% if is_chair %}
99+
<td><input class="batch-select" type="checkbox" value="{{ np.id }}" name="selected"{% if charge.is_selected %} checked="checked"{% endif %} /></td>
100+
{% endif %}
101+
<td>{{ np.nominee }}</td>
102+
<td>{{ np.position }}</td>
103+
<td>{{ np.state }}</td>
104+
<td>{{ np.questionnaires.all|yesno:">&#x2713;,No,No" }}
105+
</tr>
106+
{% endfor %}
107+
</table>
108+
109+
{% if is_chair %}
110+
</form>
111+
{% endif %}
68112

69113
{% endblock %}

0 commit comments

Comments
 (0)