From 4d5de5dee6bb1e5eec7247ce0ec006d2a88decfc Mon Sep 17 00:00:00 2001 From: Robert Sparks Date: Wed, 26 Sep 2018 18:57:30 +0000 Subject: [PATCH] Allow a nomcom to show nominees that have accepted nomination before feedback is open. Fixes #2598. Commit ready for merge. - Legacy-Id: 15486 --- ietf/nomcom/forms.py | 2 +- .../0003_nomcom_show_accepted_nominees.py | 20 +++++++++++ ...pted_nominees_false_on_existing_nomcoms.py | 23 ++++++++++++ ietf/nomcom/models.py | 2 ++ ietf/nomcom/resources.py | 2 ++ ietf/nomcom/tests.py | 21 +++++++++++ ietf/nomcom/views.py | 1 + ietf/templates/nomcom/public_nominate.html | 36 +++++++++++++------ 8 files changed, 96 insertions(+), 11 deletions(-) create mode 100644 ietf/nomcom/migrations/0003_nomcom_show_accepted_nominees.py create mode 100644 ietf/nomcom/migrations/0004_set_show_accepted_nominees_false_on_existing_nomcoms.py diff --git a/ietf/nomcom/forms.py b/ietf/nomcom/forms.py index 391cefae6..59d0eb330 100644 --- a/ietf/nomcom/forms.py +++ b/ietf/nomcom/forms.py @@ -99,7 +99,7 @@ class EditNomcomForm(forms.ModelForm): class Meta: model = NomCom - fields = ('public_key', 'initial_text', 'show_nominee_pictures', + fields = ('public_key', 'initial_text', 'show_nominee_pictures', 'show_accepted_nominees', 'send_questionnaire', 'reminder_interval') widgets = {'public_key':FileInput, } diff --git a/ietf/nomcom/migrations/0003_nomcom_show_accepted_nominees.py b/ietf/nomcom/migrations/0003_nomcom_show_accepted_nominees.py new file mode 100644 index 000000000..a6691afd2 --- /dev/null +++ b/ietf/nomcom/migrations/0003_nomcom_show_accepted_nominees.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.15 on 2018-09-26 11:10 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('nomcom', '0002_auto_20180918_0550'), + ] + + operations = [ + migrations.AddField( + model_name='nomcom', + name='show_accepted_nominees', + field=models.BooleanField(default=True, help_text=b'Show accepted nominees on the public nomination page', verbose_name=b'Show accepted nominees'), + ), + ] diff --git a/ietf/nomcom/migrations/0004_set_show_accepted_nominees_false_on_existing_nomcoms.py b/ietf/nomcom/migrations/0004_set_show_accepted_nominees_false_on_existing_nomcoms.py new file mode 100644 index 000000000..49bf943d9 --- /dev/null +++ b/ietf/nomcom/migrations/0004_set_show_accepted_nominees_false_on_existing_nomcoms.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.15 on 2018-09-26 11:12 +from __future__ import unicode_literals + +from django.db import migrations + +def forward(apps, schema_editor): + NomCom = apps.get_model('nomcom','NomCom') + NomCom.objects.update(show_accepted_nominees=False) + +def reverse(apps, schema_editor): + pass + +class Migration(migrations.Migration): + + dependencies = [ + ('nomcom', '0003_nomcom_show_accepted_nominees'), + ] + + operations = [ + migrations.RunPython(forward,reverse) + ] + diff --git a/ietf/nomcom/models.py b/ietf/nomcom/models.py index 8b1407ad5..727652606 100644 --- a/ietf/nomcom/models.py +++ b/ietf/nomcom/models.py @@ -51,6 +51,8 @@ class NomCom(models.Model): blank=True) show_nominee_pictures = models.BooleanField(verbose_name='Show nominee pictures', default=True, help_text='Display pictures of each nominee (if available) on the feedback pages') + show_accepted_nominees = models.BooleanField(verbose_name='Show accepted nominees', default=True, + help_text='Show accepted nominees on the public nomination page') class Meta: verbose_name_plural = 'NomComs' diff --git a/ietf/nomcom/resources.py b/ietf/nomcom/resources.py index 03e74f628..43d5e2029 100644 --- a/ietf/nomcom/resources.py +++ b/ietf/nomcom/resources.py @@ -24,6 +24,8 @@ class NomComResource(ModelResource): "send_questionnaire": ALL, "reminder_interval": ALL, "initial_text": ALL, + "show_nominee_pictures": ALL, + "show_accepted_nominees": ALL, "group": ALL_WITH_RELATIONS, } api.nomcom.register(NomComResource()) diff --git a/ietf/nomcom/tests.py b/ietf/nomcom/tests.py index ca406663f..d7a53ab88 100644 --- a/ietf/nomcom/tests.py +++ b/ietf/nomcom/tests.py @@ -1941,6 +1941,27 @@ class FeedbackPictureTests(TestCase): q = PyQuery(response.content) self.assertFalse(q('.photo')) +class ShowNomineeTests(TestCase): + def setUp(self): + build_test_public_keys_dir(self) + self.nc = NomComFactory(**nomcom_kwargs_for_year()) + self.plain_person = PersonFactory.create() + + def tearDown(self): + clean_test_public_keys_dir(self) + + def test_feedback_pictures(self): + url = reverse('ietf.nomcom.views.public_nominate',kwargs={'year':self.nc.year()}) + login_testing_unauthorized(self,self.plain_person.user.username,url) + response = self.client.get(url) + q = PyQuery(response.content) + self.assertTrue(q('h3')) + self.nc.show_accepted_nominees=False; + self.nc.save() + response = self.client.get(url) + q = PyQuery(response.content) + self.assertFalse(q('h3')) + class TopicTests(TestCase): def setUp(self): build_test_public_keys_dir(self) diff --git a/ietf/nomcom/views.py b/ietf/nomcom/views.py index a202c6258..3a46fef7a 100644 --- a/ietf/nomcom/views.py +++ b/ietf/nomcom/views.py @@ -424,6 +424,7 @@ def nominate(request, year, public, newperson): {'form': form, 'nomcom': nomcom, 'year': year, + 'positions': nomcom.position_set.filter(is_open=True), 'selected': 'nominate'}) @login_required diff --git a/ietf/templates/nomcom/public_nominate.html b/ietf/templates/nomcom/public_nominate.html index 0880bc2bf..664f5710b 100644 --- a/ietf/templates/nomcom/public_nominate.html +++ b/ietf/templates/nomcom/public_nominate.html @@ -16,16 +16,32 @@ {% block nomcom_content %} {% origin %} - {% if form %} -
- {% csrf_token %} - {% bootstrap_form form %} - {% buttons %} - - {% endbuttons %} -
- {% endif %} - +
+
+ {% if form %} +
+ {% csrf_token %} + {% bootstrap_form form %} + {% buttons %} + + {% endbuttons %} +
+ {% endif %} +
+
+ {% if nomcom.show_accepted_nominees %} +

Nominees
who have accepted nomination

+ {% for p in positions %} + {% if p.nomineeposition_set.accepted.not_duplicated %} +

{{ p.name }}

+ {% for np in p.nomineeposition_set.accepted.not_duplicated %} +
{{ np.nominee.name }}
+ {% endfor %} + {% endif %} + {% endfor %} + {% endif %} +
+
{% endblock %} {% block js %}