Skip to content

Commit 6c57fe4

Browse files
committed
Port mailinglists to new schema
- Legacy-Id: 6782
1 parent 26ec475 commit 6c57fe4

5 files changed

Lines changed: 54 additions & 61 deletions

File tree

ietf/mailinglists/tests.py

Lines changed: 30 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,31 @@
1-
# Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
2-
# All rights reserved. Contact: Pasi Eronen <pasi.eronen@nokia.com>
3-
#
4-
# Redistribution and use in source and binary forms, with or without
5-
# modification, are permitted provided that the following conditions
6-
# are met:
7-
#
8-
# * Redistributions of source code must retain the above copyright
9-
# notice, this list of conditions and the following disclaimer.
10-
#
11-
# * Redistributions in binary form must reproduce the above
12-
# copyright notice, this list of conditions and the following
13-
# disclaimer in the documentation and/or other materials provided
14-
# with the distribution.
15-
#
16-
# * Neither the name of the Nokia Corporation and/or its
17-
# subsidiary(-ies) nor the names of its contributors may be used
18-
# to endorse or promote products derived from this software
19-
# without specific prior written permission.
20-
#
21-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22-
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23-
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24-
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25-
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26-
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27-
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28-
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29-
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30-
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31-
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32-
33-
from ietf.utils.test_utils import SimpleUrlTestCase
34-
35-
class MailingListsUrlTestCase(SimpleUrlTestCase):
36-
def testUrls(self):
37-
self.doTestUrls(__file__)
1+
from django.core.urlresolvers import reverse as urlreverse
2+
3+
from pyquery import PyQuery
4+
5+
from ietf.utils.test_utils import TestCase
6+
from ietf.utils.test_data import make_test_data
7+
from ietf.utils.mail import outbox
8+
9+
10+
class MailingListTests(TestCase):
11+
def test_groups(self):
12+
draft = make_test_data()
13+
group = draft.group
14+
url = urlreverse("ietf.mailinglists.views.groups")
15+
16+
# only those with an archive
17+
group.list_archive = ""
18+
group.save()
19+
r = self.client.get(url)
20+
self.assertEqual(r.status_code, 200)
21+
q = PyQuery(r.content)
22+
self.assertEqual(len(q(".group-archives a:contains(\"%s\")" % group.acronym)), 0)
23+
24+
# successful get
25+
group.list_archive = "https://example.com/foo"
26+
group.save()
27+
r = self.client.get(url)
28+
q = PyQuery(r.content)
29+
self.assertEqual(len(q(".group-archives a:contains(\"%s\")" % group.acronym)), 1)
30+
3831

ietf/mailinglists/testurl.list

Lines changed: 0 additions & 4 deletions
This file was deleted.

ietf/mailinglists/urls.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
# Copyright The IETF Trust 2007, All Rights Reserved
22

33
from django.conf.urls.defaults import patterns
4-
from ietf.idtracker.models import IETFWG
54

6-
http_archive_wg_queryset = IETFWG.objects.filter(email_archive__startswith='http')
7-
8-
urlpatterns = patterns('django.views.generic.list_detail',
9-
(r'^wg/$', 'object_list', { 'queryset': http_archive_wg_queryset, 'template_name': 'mailinglists/wgwebmail_list.html' }),
10-
)
11-
urlpatterns += patterns('',
5+
urlpatterns = patterns('',
6+
(r'^wg/$', 'ietf.mailinglists.views.groups'),
127
(r'^nonwg/$', 'django.views.generic.simple.redirect_to', { 'url': 'http://www.ietf.org/list/nonwg.html'}),
138
(r'^nonwg/update/$', 'django.views.generic.simple.redirect_to', { 'url': 'http://www.ietf.org/list/nonwg.html'}),
149
(r'^request/$', 'django.views.generic.simple.redirect_to', { 'url': 'http://www.ietf.org/list/request.html' }),

ietf/mailinglists/views.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,12 @@
11
# Copyright The IETF Trust 2007, All Rights Reserved
22

3+
from ietf.group.models import Group
4+
from django.shortcuts import render_to_response
5+
from django.template import RequestContext
6+
7+
def groups(request):
8+
groups = Group.objects.filter(type__in=("wg", "rg"), list_archive__startswith='http').order_by("acronym")
9+
10+
return render_to_response("mailinglists/group_archives.html", { "groups": groups },
11+
context_instance=RequestContext(request))
12+

ietf/templates/mailinglists/wgwebmail_list.html renamed to ietf/templates/mailinglists/group_archives.html

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,20 @@ <h1>Web-based Working Group E-mail Archives</h1>
1111
charters for more information about the mailing lists and archives
1212
of specific working groups. Charters for active working groups are
1313
available on
14-
the <a href="/wg/">Active
15-
IETF Working Groups</a> Web page. Charters for concluded working
16-
groups are available on
14+
the <a href="/wg/">Active IETF Working Groups</a> Web page.
15+
Charters for concluded working groups are available on
1716
the <a href="http://www.ietf.org/wg/concluded/index.html">Concluded
1817
Working Groups</a> Web page.</p>
1918

20-
<table cellpadding="2" cellspacing="0" border="0">
21-
<tr>
22-
<th style="text-align:left;padding-right:2em;">Acronym</th><th style="text-align:left;">Name</th>
23-
</tr>
24-
{% for wg in object_list|dictsort:"group_acronym.acronym" %}
25-
<tr>
26-
<td><a href="{{ wg.email_archive|escape }}">{{ wg|escape }}</a></td>
27-
<td>{{ wg.group_acronym.name|escape }}</td>
28-
</tr>
29-
{% endfor %}
19+
<table class="group-archives" cellpadding="2" cellspacing="0" border="0">
20+
<tr>
21+
<th style="text-align:left;padding-right:2em;">Acronym</th><th style="text-align:left;">Name</th>
22+
</tr>
23+
{% for group in groups %}
24+
<tr>
25+
<td><a href="{{ group.list_archive }}">{{ group.acronym }}</a></td>
26+
<td>{{ group.name }}</td>
27+
</tr>
28+
{% endfor %}
3029
</table>
3130
{% endblock %}

0 commit comments

Comments
 (0)