From c49abdd5578c6bf607607cc5721e9f4b51521b19 Mon Sep 17 00:00:00 2001
From: Robert Sparks
Date: Tue, 23 May 2017 22:18:04 +0000
Subject: [PATCH] Allow nomcoms to configure the feedback page to show nominee
pictures. Fixes #2252. Commit ready for merge, - Legacy-Id: 13413
---
ietf/nomcom/forms.py | 2 +-
ietf/nomcom/migrations/0015_show_pictures.py | 20 ++++++++++++++
ietf/nomcom/models.py | 2 ++
ietf/nomcom/tests.py | 20 ++++++++++++++
ietf/templates/nomcom/feedback.html | 28 +++++++++++++++++++-
5 files changed, 70 insertions(+), 2 deletions(-)
create mode 100644 ietf/nomcom/migrations/0015_show_pictures.py
diff --git a/ietf/nomcom/forms.py b/ietf/nomcom/forms.py
index 6fff204bc..3fde106b5 100644
--- a/ietf/nomcom/forms.py
+++ b/ietf/nomcom/forms.py
@@ -210,7 +210,7 @@ class EditNomcomForm(forms.ModelForm):
class Meta:
model = NomCom
- fields = ('public_key', 'initial_text',
+ fields = ('public_key', 'initial_text', 'show_nominee_pictures',
'send_questionnaire', 'reminder_interval')
def clean_public_key(self):
diff --git a/ietf/nomcom/migrations/0015_show_pictures.py b/ietf/nomcom/migrations/0015_show_pictures.py
new file mode 100644
index 000000000..5e6f359d2
--- /dev/null
+++ b/ietf/nomcom/migrations/0015_show_pictures.py
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.7 on 2017-05-23 12:18
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('nomcom', '0014_alter_is_open_help_text'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='nomcom',
+ name='show_nominee_pictures',
+ field=models.BooleanField(default=True, help_text=b'Display pictures of each nominee (if available) on the feedback pages', verbose_name=b'Show nominee pictures'),
+ ),
+ ]
diff --git a/ietf/nomcom/models.py b/ietf/nomcom/models.py
index 4a8e2f6b8..1652436e0 100644
--- a/ietf/nomcom/models.py
+++ b/ietf/nomcom/models.py
@@ -46,6 +46,8 @@ class NomCom(models.Model):
blank=True, null=True)
initial_text = models.TextField(verbose_name='Help text for nomination form',
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')
class Meta:
verbose_name_plural = 'NomComs'
diff --git a/ietf/nomcom/tests.py b/ietf/nomcom/tests.py
index 28865f581..434163ffe 100644
--- a/ietf/nomcom/tests.py
+++ b/ietf/nomcom/tests.py
@@ -1861,3 +1861,23 @@ class AcceptingTests(TestCase):
self.assertEqual( len(q('.badge')) , 3 )
+class FeedbackPictureTests(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_feedback',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('.photo'))
+ self.nc.show_nominee_pictures=False;
+ self.nc.save()
+ response = self.client.get(url)
+ q = PyQuery(response.content)
+ self.assertFalse(q('.photo'))
diff --git a/ietf/templates/nomcom/feedback.html b/ietf/templates/nomcom/feedback.html
index 14b9014c1..5759f09e7 100644
--- a/ietf/templates/nomcom/feedback.html
+++ b/ietf/templates/nomcom/feedback.html
@@ -12,11 +12,27 @@
.btn-group-vertical .btn .badge {
float:right;
margin-top: 0.15em;
+ margin-right: 0.15em;
}
+.btn-group-vertical .btn .photo {
+ display: inline-block;
+ min-width: 15px;
+ float:right;
+}
+.feedbackphoto {
+ display: inline-block;
+ float:right;
+ margin-bottom: 0.15em;
+ margin-left: 0.15em;
+}
+
@-moz-document url-prefix() {
.btn-group-vertical .btn .badge {
margin-top: -1.3em;
}
+ .btn-group-vertical .btn .photo {
+ margin-top: -1.5em;
+ }
}
{% endblock %}
@@ -46,6 +62,13 @@
{{ np.nominee.name }}
{% with count=counts|lookup:np.position.id|lookup:np.nominee.id %}
+ {% if nomcom.show_nominee_pictures %}
+ {% if np.nominee.person.photo_thumb %}
+
+ {% else %}
+
+ {% endif %}
+ {% endif %}
{{ count | default:"no feedback" }}
@@ -70,7 +93,10 @@
{% if form %}
Provide feedback
{% if form.position %}
- about {{form.nominee.email.person.name}} ({{form.nominee.email.address}}) for the {{form.position.name}} position.
+ about {{form.nominee.email.person.name}} ({{form.nominee.email.address}}) for the {{form.position.name}} position.
+ {% if nomcom.show_nominee_pictures and form.nominee.email.person.photo_thumb %}
+
+ {% endif %}
{% endif %}
This feedback will only be available to NomCom {{year}}.