From 7c53eb1843b85e918ee740e19d78796be8bd43fe Mon Sep 17 00:00:00 2001
From: Henrik Levkowetz <henrik@levkowetz.com>
Date: Thu, 9 Jun 2016 21:58:01 +0000
Subject: [PATCH] Renamed group.views.all_photos() back to chair_photos().
 Added differentiated ordering by role to group photo pages.  Moved the
 external links (dependency graph and tools pages) off of the tabs, to the
 charter page.  - Legacy-Id: 11303

---
 ietf/group/views.py                  | 43 ++++++++++++++++++----------
 ietf/templates/group/active_rgs.html |  2 +-
 ietf/templates/group/active_wgs.html |  2 +-
 3 files changed, 30 insertions(+), 17 deletions(-)

diff --git a/ietf/group/views.py b/ietf/group/views.py
index a3506b14d..5388819c0 100644
--- a/ietf/group/views.py
+++ b/ietf/group/views.py
@@ -347,24 +347,15 @@ def construct_group_menu_context(request, group, selected, group_type, others):
         entries.append(("Materials", urlreverse("ietf.group.views.materials", kwargs=kwargs)))
     if group.type_id in ('rg','wg','team'):
         entries.append(("Meetings", urlreverse("ietf.group.views.meetings", kwargs=kwargs)))
-    entries.append(("Email expansions", urlreverse("ietf.group.views.email", kwargs=kwargs)))
     entries.append(("History", urlreverse("ietf.group.views.history", kwargs=kwargs)))
-
+    entries.append(("Photos", urlreverse("ietf.group.views.group_photos", kwargs=kwargs)))
+    entries.append(("Email expansions", urlreverse("ietf.group.views.email", kwargs=kwargs)))
     if group.list_archive.startswith("http:") or group.list_archive.startswith("https:") or group.list_archive.startswith("ftp:"):
         if 'mailarchive.ietf.org' in group.list_archive:
-            entries.append(("List archive", urlreverse("ietf.group.views.derived_archives", kwargs=kwargs)))
+            entries.append(("list archive", urlreverse("ietf.group.views.derived_archives", kwargs=kwargs)))
         else:
             entries.append((mark_safe("List archive &raquo;"), group.list_archive))
 
-    if group.features.has_documents:
-        kwargs["output_type"] = "svg"
-        entries.append((mark_safe("Dependencies &raquo;"), urlreverse("ietf.group.views.dependencies", kwargs=kwargs)))
-        del kwargs["output_type"]
-
-    if group.has_tools_page():
-        entries.append((mark_safe("Tools page &raquo;"), "https://tools.ietf.org/%s/%s/" % (group.type_id, group.acronym)))
-
-
     # actions
     actions = []
 
@@ -871,16 +862,38 @@ def derived_archives(request, acronym=None, group_type=None):
                      'list_acronym':list_acronym,
                   }))
 
-def all_photos(request, group_type=None):
+def chair_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 })
+    return render(request, 'group/all_photos.html', {'group_type': group_type, 'role': 'Chair', 'roles': roles })
 
+def reorder_roles(roles, role_names):
+    list = []
+    for name in role_names:
+        list += [ r for r in roles if r.name_id == name ]
+    list += [ r for r in roles if not r in list ]
+    return list
+    
 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())
+
+    if   group.type_id in ['wg', 'rg', ]:
+        roles = reorder_roles(roles, ['chair', 'secr'])
+    elif group.type_id in ['nomcom', ]:
+        roles = reorder_roles(roles, ['chair', 'member', 'advisor', ])
+    elif group.type_id in ['team', ]:
+        roles = reorder_roles(roles, ['chair', 'member', 'matman', ])
+    elif group.type_id in ['sdo', ]:
+        roles = reorder_roles(roles, ['liaiman', ])
+    else:
+        pass
     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 })
+    return render(request, 'group/group_photos.html',
+                  construct_group_menu_context(request, group, "photos", group_type, {
+                      '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 bea497ee4..0602d6783 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.all_photos" group_type="rg" %}">Chair Photos</a>
+    <a class="btn btn-default" href="{% url "ietf.group.views.chair_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 81ade5330..db088d32c 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.all_photos" group_type="wg" %}">Chair Photos</a>
+      <a class="btn btn-default" href="{% url "ietf.group.views.chair_photos" group_type="wg" %}">Chair Photos</a>
 
       {% for area in areas %}
         <h2 class="anchor-target" id="{{area.acronym}}">{{ area.name }} ({{ area.acronym }})</h2>