Skip to content

Commit c2c0227

Browse files
larseggertrjsparks
andauthored
fix: Allow filtering for nominees who have not declined (ietf-tools#6382)
* fix: Allow filtering for nominees who have not declined Fixes ietf-tools#6380 * Update views.py Co-authored-by: Robert Sparks <rjsparks@nostrum.com> --------- Co-authored-by: Robert Sparks <rjsparks@nostrum.com>
1 parent 61045d3 commit c2c0227

2 files changed

Lines changed: 35 additions & 2 deletions

File tree

ietf/nomcom/tests.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,6 +1327,36 @@ def test_cannot_modify_nominees(self):
13271327
q = PyQuery(response.content)
13281328
self.assertIn('not active', q('.alert-warning').text() )
13291329

1330+
def test_filter_nominees(self):
1331+
url = reverse(
1332+
"ietf.nomcom.views.private_index", kwargs={"year": self.nc.year()}
1333+
)
1334+
login_testing_unauthorized(self, self.chair.user.username, url)
1335+
response = self.client.get(url)
1336+
self.assertEqual(response.status_code, 200)
1337+
1338+
states = list(NomineePositionStateName.objects.values_list("slug", flat=True))
1339+
states += ["not-declined", "questionnaire"]
1340+
for state in states:
1341+
response = self.client.get(url, {"state": state})
1342+
self.assertEqual(response.status_code, 200)
1343+
q = PyQuery(response.content)
1344+
nps = []
1345+
if state == "not-declined":
1346+
nps = NomineePosition.objects.exclude(state__slug="declined")
1347+
elif state == "questionnaire":
1348+
nps = [
1349+
np
1350+
for np in NomineePosition.objects.not_duplicated()
1351+
if np.questionnaires
1352+
]
1353+
else:
1354+
nps = NomineePosition.objects.filter(state__slug=state)
1355+
# nomination state is in third table column
1356+
self.assertEqual(
1357+
len(nps), len(q("#nominee-position-table td:nth-child(3)"))
1358+
)
1359+
13301360
def test_email_pasting_closed(self):
13311361
url = reverse('ietf.nomcom.views.private_feedback_email', kwargs={'year':self.nc.year()})
13321362
login_testing_unauthorized(self, self.chair.user.username, url)

ietf/nomcom/views.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,11 @@ def private_index(request, year):
216216

217217
filters = {}
218218
questionnaire_state = "questionnaire"
219+
not_declined_state = "not-declined"
219220
selected_state = request.GET.get('state')
220221
selected_position = request.GET.get('position')
221222

222-
if selected_state and not selected_state == questionnaire_state:
223+
if selected_state and selected_state not in [questionnaire_state, not_declined_state]:
223224
filters['state__slug'] = selected_state
224225

225226
if selected_position:
@@ -231,13 +232,15 @@ def private_index(request, year):
231232

232233
if selected_state == questionnaire_state:
233234
nominee_positions = [np for np in nominee_positions if np.questionnaires]
235+
elif selected_state == not_declined_state:
236+
nominee_positions = nominee_positions.exclude(state__slug='declined')
234237

235238
positions = Position.objects.get_by_nomcom(nomcom=nomcom)
236239
stats = [ { 'position__name':p.name,
237240
'position__id':p.pk,
238241
'position': p,
239242
} for p in positions]
240-
states = [{'slug': questionnaire_state, 'name': 'Accepted and sent Questionnaire'}] + list(NomineePositionStateName.objects.values('slug', 'name'))
243+
states = [{'slug': questionnaire_state, 'name': 'Accepted and sent Questionnaire'}, {'slug': not_declined_state, 'name': 'Not declined'}] + list(NomineePositionStateName.objects.values('slug', 'name'))
241244
positions = set([ n.position for n in all_nominee_positions.order_by('position__name') ])
242245
for s in stats:
243246
for state in states:

0 commit comments

Comments
 (0)