diff --git a/ietf/nomcom/templatetags/nomcom_tags.py b/ietf/nomcom/templatetags/nomcom_tags.py index 38dfc61b9e..8f795be80e 100644 --- a/ietf/nomcom/templatetags/nomcom_tags.py +++ b/ietf/nomcom/templatetags/nomcom_tags.py @@ -1,8 +1,10 @@ -# Copyright The IETF Trust 2013-2019, All Rights Reserved +# Copyright The IETF Trust 2013-2023, All Rights Reserved import os import tempfile import re +from collections import defaultdict + from django import template from django.conf import settings from django.template.defaultfilters import linebreaksbr, force_escape @@ -84,3 +86,11 @@ def decrypt(string, request, year, plain=False): if not plain: return force_escape(linebreaksbr(out)) return mark_safe(force_escape(out)) + +@register.filter +def feedback_totals(staterank_list): + totals = defaultdict(lambda: 0) + for fb_dict in staterank_list: + for fbtype_name, fbtype_count, _ in fb_dict['feedback']: + totals[fbtype_name] += fbtype_count + return totals.values() diff --git a/ietf/nomcom/tests.py b/ietf/nomcom/tests.py index 216984776c..bce7e5a214 100644 --- a/ietf/nomcom/tests.py +++ b/ietf/nomcom/tests.py @@ -1,4 +1,4 @@ -# Copyright The IETF Trust 2012-2022, All Rights Reserved +# Copyright The IETF Trust 2012-2023, All Rights Reserved # -*- coding: utf-8 -*- @@ -1423,6 +1423,35 @@ def test_can_view_but_not_edit_templates(self): q = PyQuery(response.content) self.assertFalse( q('#templateform') ) +class FeedbackIndexTests(TestCase): + + def setUp(self): + super().setUp() + setup_test_public_keys_dir(self) + self.nc = NomComFactory.create(**nomcom_kwargs_for_year()) + self.author = PersonFactory.create().email_set.first().address + self.member = self.nc.group.role_set.filter(name='member').first().person + self.nominee = self.nc.nominee_set.order_by('pk').first() + self.position = self.nc.position_set.first() + for type_id in ['comment','nomina','questio']: + f = FeedbackFactory.create(author=self.author,nomcom=self.nc,type_id=type_id) + f.positions.add(self.position) + f.nominees.add(self.nominee) + + def tearDown(self): + teardown_test_public_keys_dir(self) + super().tearDown() + + def test_feedback_index_totals(self): + url = reverse('ietf.nomcom.views.view_feedback',kwargs={'year':self.nc.year()}) + login_testing_unauthorized(self, self.member.user.username, url) + provide_private_key_to_test_client(self) + response = self.client.get(url) + self.assertEqual(response.status_code,200) + q = PyQuery(response.content) + r = q('tfoot').eq(0).find('td').contents() + self.assertEqual([a.strip() for a in r], ['1', '1', '1']) + class FeedbackLastSeenTests(TestCase): def setUp(self): diff --git a/ietf/templates/nomcom/view_feedback.html b/ietf/templates/nomcom/view_feedback.html index 9215d3c82c..d1b7f77e4c 100644 --- a/ietf/templates/nomcom/view_feedback.html +++ b/ietf/templates/nomcom/view_feedback.html @@ -1,5 +1,5 @@ {% extends "nomcom/nomcom_private_base.html" %} -{# Copyright The IETF Trust 2015, All Rights Reserved #} +{# Copyright The IETF Trust 2015-2023, All Rights Reserved #} {% load origin static %} {% load nomcom_tags %} {% block subtitle %}- View feedback{% endblock %} @@ -54,6 +54,18 @@