Skip to content

Commit e4ce370

Browse files
committed
Merged in [10840] from rjsparks@nostrum.com:
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. - Legacy-Id: 10843 Note: SVN reference [10840] has been migrated to Git commit 4ed83dd
2 parents b19aae7 + 13b46e8 commit e4ce370

4 files changed

Lines changed: 79 additions & 1 deletion

File tree

ietf/group/info.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,10 @@ def construct_group_menu_context(request, group, selected, group_type, others):
345345
del kwargs["output_type"]
346346

347347
if group.list_archive.startswith("http:") or group.list_archive.startswith("https:") or group.list_archive.startswith("ftp:"):
348-
entries.append((mark_safe("List archive »"), group.list_archive))
348+
if 'mailarchive.ietf.org' in group.list_archive:
349+
entries.append(("List archive", urlreverse("ietf.group.info.derived_archives", kwargs=kwargs)))
350+
else:
351+
entries.append((mark_safe("List archive »"), group.list_archive))
349352
if group.has_tools_page():
350353
entries.append((mark_safe("Tools page »"), "https://tools.ietf.org/%s/%s/" % (group.type_id, group.acronym)))
351354

@@ -777,3 +780,23 @@ def sort_key(session):
777780
'past':past,
778781
'can_edit':can_edit,
779782
}))
783+
784+
def derived_archives(request, acronym=None, group_type=None):
785+
group = get_group_or_404(acronym,group_type) if acronym else None
786+
787+
list_acronym = None
788+
789+
m = re.search('mailarchive.ietf.org/arch/search/?\?email_list=([-\w]+)\Z',group.list_archive)
790+
if m:
791+
list_acronym=m.group(1)
792+
793+
if not list_acronym:
794+
m = re.search('mailarchive.ietf.org/arch/browse/([-\w]+)/?\Z',group.list_archive)
795+
if m:
796+
list_acronym=m.group(1)
797+
798+
return render(request, 'group/derived_archives.html',
799+
construct_group_menu_context(request, group, "list archive", group_type, {
800+
'group':group,
801+
'list_acronym':list_acronym,
802+
}))

ietf/group/tests.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import os
22
from unittest import skipIf
33

4+
from pyquery import PyQuery
5+
46
from django.conf import settings
57
from django.core.urlresolvers import reverse as urlreverse
68
from django.db.models import Q
@@ -10,6 +12,7 @@
1012

1113
from ietf.group.models import Role, Group
1214
from ietf.group.utils import get_group_role_emails, get_child_group_role_emails, get_group_ad_emails
15+
from ietf.group.factories import GroupFactory
1316
from ietf.utils.test_data import make_test_data
1417
from ietf.utils.test_utils import login_testing_unauthorized, TestCase, unicontent
1518

@@ -131,3 +134,28 @@ def test_group_ad_emails(self):
131134
self.assertGreater(len(emails), 0)
132135
for item in emails:
133136
self.assertIn('@', item)
137+
138+
class GroupDerivedArchiveTests(TestCase):
139+
140+
def test_group_with_mailarch(self):
141+
group = GroupFactory()
142+
group.list_archive = 'https://mailarchive.ietf.org/arch/browse/%s/'%group.acronym
143+
group.save()
144+
url = urlreverse("ietf.group.info.derived_archives",kwargs=dict(acronym=group.acronym))
145+
r = self.client.get(url)
146+
self.assertEqual(r.status_code, 200)
147+
q = PyQuery(r.content)
148+
self.assertEqual(url, q('.nav-tabs .active a')[0].attrib['href'])
149+
self.assertTrue(group.list_archive in unicontent(r))
150+
self.assertTrue('web/%s/current'%group.acronym in unicontent(r))
151+
152+
def test_group_without_mailarch(self):
153+
group = GroupFactory()
154+
group.list_archive = 'https://alienarchive.example.com'
155+
group.save()
156+
url = urlreverse("ietf.group.info.derived_archives",kwargs=dict(acronym=group.acronym))
157+
r = self.client.get(url)
158+
self.assertEqual(r.status_code, 200)
159+
q = PyQuery(r.content)
160+
self.assertFalse(q('.nav-tabs .active'))
161+
self.assertTrue(group.list_archive in unicontent(r))

ietf/group/urls_info_details.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@
2121
(r'^materials/$', 'ietf.group.info.materials', None, "group_materials"),
2222
(r'^materials/new/$', 'ietf.doc.views_material.choose_material_type'),
2323
(r'^materials/new/(?P<doc_type>[\w-]+)/$', 'ietf.doc.views_material.edit_material', { 'action': "new" }, "group_new_material"),
24+
(r'^archives/$', 'ietf.group.info.derived_archives'),
2425
url(r'^email-aliases/$', RedirectView.as_view(pattern_name='ietf.group.info.email',permanent=False),name='old_group_email_aliases'),
2526
)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{% extends "group/group_base.html" %}
2+
{# Copyright The IETF Trust 2016, All Rights Reserved #}
3+
{% load origin %}
4+
5+
{% block title %}Archives{% if group %} for {{group.acronym}}{% endif %}{% endblock %}
6+
7+
{% block group_content %}
8+
{% origin %}
9+
10+
{% if list_acronym %}
11+
12+
<div class="row">
13+
<span class="col-xs-2 col-md-1"><strong>Mailarchive</strong></span><span class="col-xs-8 col-md-8"><a href="{{group.list_archive}}">{{group.list_archive}}</a></span>
14+
</div>
15+
16+
<div class="row">
17+
<span class="col-xs-2 col-md-1"><strong>Mhonarc</strong></span><span class="col-xs-8 col-md-8"><a href="https://www.ietf.org/mail-archive/web/{{list_acronym}}/current/maillist.html">https://www.ietf.org/mail-archive/web/{{list_acronym}}/current/maillist.html</a></span>
18+
</div>
19+
20+
{% else %}
21+
<div class="row">
22+
<strong class="col-xs-2 col-md-1">Archive</strong><span class="col-xs-8 col-md-8"><a href="{{group.list_archive}}">{{group.list_archive}}</a></span>
23+
</div>
24+
{% endif %}
25+
26+
{% endblock %}

0 commit comments

Comments
 (0)