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 4ed83dd7fc
This commit is contained in:
commit
e4ce370e39
|
@ -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,
|
||||
}))
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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<doc_type>[\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'),
|
||||
)
|
||||
|
|
26
ietf/templates/group/derived_archives.html
Normal file
26
ietf/templates/group/derived_archives.html
Normal file
|
@ -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 %}
|
||||
|
||||
<div class="row">
|
||||
<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>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<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>
|
||||
</div>
|
||||
|
||||
{% else %}
|
||||
<div class="row">
|
||||
<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>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
Loading…
Reference in a new issue