From 7edecaee2755d20a3e572d0ee9a0dbc2be877e3b Mon Sep 17 00:00:00 2001
From: Henrik Levkowetz <henrik@levkowetz.com>
Date: Mon, 6 Jun 2016 16:33:24 +0000
Subject: [PATCH] Added photo page support for individual groups, and tweaked
 some names.  This provides a photo page for the IAB, but also as a benefit
 photo pages for other groups.  - Legacy-Id: 11287

---
 ietf/group/urls_info.py                               | 2 +-
 ietf/group/urls_info_details.py                       | 2 ++
 ietf/group/views.py                                   | 9 ++++++++-
 ietf/templates/group/active_rgs.html                  | 2 +-
 ietf/templates/group/active_wgs.html                  | 2 +-
 ietf/templates/group/{photos.html => all_photos.html} | 0
 6 files changed, 13 insertions(+), 4 deletions(-)
 rename ietf/templates/group/{photos.html => all_photos.html} (100%)

diff --git a/ietf/group/urls_info.py b/ietf/group/urls_info.py
index 3cc663507..715bf10f0 100644
--- a/ietf/group/urls_info.py
+++ b/ietf/group/urls_info.py
@@ -19,6 +19,6 @@ urlpatterns = patterns('',
     (r'^bofs/$', views.bofs),
     (r'^email-aliases/$', 'ietf.group.views.email_aliases'),
     (r'^bofs/create/$', views_edit.edit, {'action': "create"}, "bof_create"),
-    (r'^photos/$', views.photos),
+    (r'^photos/$', views.all_photos),
     (r'^(?P<acronym>[a-zA-Z0-9-._]+)/', include('ietf.group.urls_info_details')),
 )
diff --git a/ietf/group/urls_info_details.py b/ietf/group/urls_info_details.py
index fd3dfbb54..0c60d806a 100644
--- a/ietf/group/urls_info_details.py
+++ b/ietf/group/urls_info_details.py
@@ -1,5 +1,6 @@
 from django.conf.urls import patterns, url
 from django.views.generic import RedirectView
+import views
 
 urlpatterns = patterns('',
     (r'^$', 'ietf.group.views.group_home', None, "group_home"),
@@ -28,5 +29,6 @@ urlpatterns = patterns('',
     (r'^materials/new/$', 'ietf.doc.views_material.choose_material_type'),
     (r'^materials/new/(?P<doc_type>[\w-]+)/$', 'ietf.doc.views_material.edit_material', { 'action': "new" }, "group_new_material"),
     (r'^archives/$', 'ietf.group.views.derived_archives'),
+    (r'^photos/$', views.group_photos),
     url(r'^email-aliases/$', RedirectView.as_view(pattern_name='ietf.group.views.email',permanent=False),name='old_group_email_aliases'),
 )
diff --git a/ietf/group/views.py b/ietf/group/views.py
index 25a9585d1..a3506b14d 100644
--- a/ietf/group/views.py
+++ b/ietf/group/views.py
@@ -871,9 +871,16 @@ def derived_archives(request, acronym=None, group_type=None):
                      'list_acronym':list_acronym,
                   }))
 
-def photos(request, group_type=None):
+def all_photos(request, group_type=None):
     roles = sorted(Role.objects.filter(group__type=group_type, group__state='active', name_id='chair'),key=lambda x: x.person.last_name()+x.person.name+x.group.acronym)
     for role in roles:
         role.last_initial = role.person.last_name()[0]
     return render(request, 'group/photos.html', {'group_type': group_type, 'role': 'Chair', 'roles': roles })
 
+def group_photos(request, group_type=None, acronym=None):
+    group = get_object_or_404(Group, acronym=acronym)
+    roles = sorted(Role.objects.filter(group__acronym=acronym),key=lambda x: x.name.name+x.person.last_name())
+    for role in roles:
+        role.last_initial = role.person.last_name()[0]
+    return render(request, 'group/group_photos.html', {'group_type': group_type, 'roles': roles, 'group':group })
+
diff --git a/ietf/templates/group/active_rgs.html b/ietf/templates/group/active_rgs.html
index 9c3571847..bea497ee4 100644
--- a/ietf/templates/group/active_rgs.html
+++ b/ietf/templates/group/active_rgs.html
@@ -17,7 +17,7 @@
 
   <h2>Active research groups</h2>
     <a class="btn btn-default" href="{% url "ietf.group.views.all_status" %}">Status Reports</a>
-    <a class="btn btn-default" href="{% url "ietf.group.views.photos" group_type="rg" %}">Chair Photos</a>
+    <a class="btn btn-default" href="{% url "ietf.group.views.all_photos" group_type="rg" %}">Chair Photos</a>
 
   <table class="table table-striped table-condensed tablesorter">
     <thead>
diff --git a/ietf/templates/group/active_wgs.html b/ietf/templates/group/active_wgs.html
index 9dca6da87..81ade5330 100644
--- a/ietf/templates/group/active_wgs.html
+++ b/ietf/templates/group/active_wgs.html
@@ -20,7 +20,7 @@
       <a class="btn btn-default" href="{% url "ietf.group.views.concluded_groups" %}">Concluded WGs</a>
       <a class="btn btn-default" href="https://www.ietf.org/dyn/wg/charter/history/">Historic charters</a>
       <a class="btn btn-default" href="{% url "ietf.group.views.all_status" %}">Status Reports</a>
-      <a class="btn btn-default" href="{% url "ietf.group.views.photos" group_type="wg" %}">Chair Photos</a>
+      <a class="btn btn-default" href="{% url "ietf.group.views.all_photos" group_type="wg" %}">Chair Photos</a>
 
       {% for area in areas %}
         <h2 class="anchor-target" id="{{area.acronym}}">{{ area.name }} ({{ area.acronym }})</h2>
diff --git a/ietf/templates/group/photos.html b/ietf/templates/group/all_photos.html
similarity index 100%
rename from ietf/templates/group/photos.html
rename to ietf/templates/group/all_photos.html