From 4ed83dd7fc0d8f7cc8e13e85f6ffd17cff105207 Mon Sep 17 00:00:00 2001 From: Robert Sparks Date: Mon, 15 Feb 2016 20:01:51 +0000 Subject: [PATCH 1/2] Fill in the list archive tab, showing both mailarchive and mhonarc links when they exists. Preserve the immediate link-to-archive behavior for the group pages for lists that are not in mailarchive/mhonarc. Provides a url at the datatracker for the mailman listinfo pages to use that will show both types of archive. Commit ready for merge. - Legacy-Id: 10840 --- ietf/group/info.py | 25 ++++++++++++++++++++++++- ietf/group/tests.py | 28 ++++++++++++++++++++++++++++ ietf/group/urls_info_details.py | 1 + 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/ietf/group/info.py b/ietf/group/info.py index 6bfc97e89..915419ffb 100644 --- a/ietf/group/info.py +++ b/ietf/group/info.py @@ -345,7 +345,10 @@ def construct_group_menu_context(request, group, selected, group_type, others): del kwargs["output_type"] if group.list_archive.startswith("http:") or group.list_archive.startswith("https:") or group.list_archive.startswith("ftp:"): - entries.append((mark_safe("List archive »"), group.list_archive)) + if 'mailarchive.ietf.org' in group.list_archive: + entries.append(("List archive", urlreverse("ietf.group.info.derived_archives", kwargs=kwargs))) + else: + entries.append((mark_safe("List archive »"), group.list_archive)) if group.has_tools_page(): entries.append((mark_safe("Tools page »"), "https://tools.ietf.org/%s/%s/" % (group.type_id, group.acronym))) @@ -777,3 +780,23 @@ def meetings(request, acronym=None, group_type=None): 'past':past, 'can_edit':can_edit, })) + +def derived_archives(request, acronym=None, group_type=None): + group = get_group_or_404(acronym,group_type) if acronym else None + + list_acronym = None + + m = re.search('mailarchive.ietf.org/arch/search/?\?email_list=([-\w]+)\Z',group.list_archive) + if m: + list_acronym=m.group(1) + + if not list_acronym: + m = re.search('mailarchive.ietf.org/arch/browse/([-\w]+)/?\Z',group.list_archive) + if m: + list_acronym=m.group(1) + + return render(request, 'group/derived_archives.html', + construct_group_menu_context(request, group, "list archive", group_type, { + 'group':group, + 'list_acronym':list_acronym, + })) diff --git a/ietf/group/tests.py b/ietf/group/tests.py index f00a01362..353287813 100644 --- a/ietf/group/tests.py +++ b/ietf/group/tests.py @@ -1,6 +1,8 @@ import os from unittest import skipIf +from pyquery import PyQuery + from django.conf import settings from django.core.urlresolvers import reverse as urlreverse from django.db.models import Q @@ -10,6 +12,7 @@ import debug # pyflakes:ignore from ietf.group.models import Role, Group from ietf.group.utils import get_group_role_emails, get_child_group_role_emails, get_group_ad_emails +from ietf.group.factories import GroupFactory from ietf.utils.test_data import make_test_data from ietf.utils.test_utils import login_testing_unauthorized, TestCase, unicontent @@ -131,3 +134,28 @@ class GroupRoleEmailTests(TestCase): self.assertGreater(len(emails), 0) for item in emails: self.assertIn('@', item) + +class GroupDerivedArchiveTests(TestCase): + + def test_group_with_mailarch(self): + group = GroupFactory() + group.list_archive = 'https://mailarchive.ietf.org/arch/browse/%s/'%group.acronym + group.save() + url = urlreverse("ietf.group.info.derived_archives",kwargs=dict(acronym=group.acronym)) + r = self.client.get(url) + self.assertEqual(r.status_code, 200) + q = PyQuery(r.content) + self.assertEqual(url, q('.nav-tabs .active a')[0].attrib['href']) + self.assertTrue(group.list_archive in unicontent(r)) + self.assertTrue('web/%s/current'%group.acronym in unicontent(r)) + + def test_group_without_mailarch(self): + group = GroupFactory() + group.list_archive = 'https://alienarchive.example.com' + group.save() + url = urlreverse("ietf.group.info.derived_archives",kwargs=dict(acronym=group.acronym)) + r = self.client.get(url) + self.assertEqual(r.status_code, 200) + q = PyQuery(r.content) + self.assertFalse(q('.nav-tabs .active')) + self.assertTrue(group.list_archive in unicontent(r)) diff --git a/ietf/group/urls_info_details.py b/ietf/group/urls_info_details.py index a599349f8..86b41b37e 100644 --- a/ietf/group/urls_info_details.py +++ b/ietf/group/urls_info_details.py @@ -21,5 +21,6 @@ urlpatterns = patterns('', (r'^materials/$', 'ietf.group.info.materials', None, "group_materials"), (r'^materials/new/$', 'ietf.doc.views_material.choose_material_type'), (r'^materials/new/(?P[\w-]+)/$', 'ietf.doc.views_material.edit_material', { 'action': "new" }, "group_new_material"), + (r'^archives/$', 'ietf.group.info.derived_archives'), url(r'^email-aliases/$', RedirectView.as_view(pattern_name='ietf.group.info.email',permanent=False),name='old_group_email_aliases'), ) From 13b46e80ca2b6f6257ad1959a966151bfc127ed8 Mon Sep 17 00:00:00 2001 From: Robert Sparks Date: Mon, 15 Feb 2016 20:20:30 +0000 Subject: [PATCH 2/2] Added template missing from last commit. Commit ready for merge. - Legacy-Id: 10841 --- ietf/templates/group/derived_archives.html | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 ietf/templates/group/derived_archives.html diff --git a/ietf/templates/group/derived_archives.html b/ietf/templates/group/derived_archives.html new file mode 100644 index 000000000..75a5998eb --- /dev/null +++ b/ietf/templates/group/derived_archives.html @@ -0,0 +1,26 @@ +{% extends "group/group_base.html" %} +{# Copyright The IETF Trust 2016, All Rights Reserved #} +{% load origin %} + +{% block title %}Archives{% if group %} for {{group.acronym}}{% endif %}{% endblock %} + +{% block group_content %} +{% origin %} + +{% if list_acronym %} + +
+Mailarchive{{group.list_archive}} +
+ + + +{% else %} + +{% endif %} + +{% endblock %}