From 6c57fe496f941749c2972f469703bce98aa0a55a Mon Sep 17 00:00:00 2001 From: Ole Laursen Date: Tue, 3 Dec 2013 18:55:26 +0000 Subject: [PATCH] Port mailinglists to new schema - Legacy-Id: 6782 --- ietf/mailinglists/tests.py | 63 +++++++++---------- ietf/mailinglists/testurl.list | 4 -- ietf/mailinglists/urls.py | 9 +-- ietf/mailinglists/views.py | 10 +++ ...gwebmail_list.html => group_archives.html} | 25 ++++---- 5 files changed, 52 insertions(+), 59 deletions(-) delete mode 100644 ietf/mailinglists/testurl.list rename ietf/templates/mailinglists/{wgwebmail_list.html => group_archives.html} (57%) diff --git a/ietf/mailinglists/tests.py b/ietf/mailinglists/tests.py index 043584ea0..83659a9f6 100644 --- a/ietf/mailinglists/tests.py +++ b/ietf/mailinglists/tests.py @@ -1,38 +1,31 @@ -# Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. Contact: Pasi Eronen -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials provided -# with the distribution. -# -# * Neither the name of the Nokia Corporation and/or its -# subsidiary(-ies) nor the names of its contributors may be used -# to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +from django.core.urlresolvers import reverse as urlreverse -from ietf.utils.test_utils import SimpleUrlTestCase +from pyquery import PyQuery + +from ietf.utils.test_utils import TestCase +from ietf.utils.test_data import make_test_data +from ietf.utils.mail import outbox + + +class MailingListTests(TestCase): + def test_groups(self): + draft = make_test_data() + group = draft.group + url = urlreverse("ietf.mailinglists.views.groups") + + # only those with an archive + group.list_archive = "" + group.save() + r = self.client.get(url) + self.assertEqual(r.status_code, 200) + q = PyQuery(r.content) + self.assertEqual(len(q(".group-archives a:contains(\"%s\")" % group.acronym)), 0) + + # successful get + group.list_archive = "https://example.com/foo" + group.save() + r = self.client.get(url) + q = PyQuery(r.content) + self.assertEqual(len(q(".group-archives a:contains(\"%s\")" % group.acronym)), 1) -class MailingListsUrlTestCase(SimpleUrlTestCase): - def testUrls(self): - self.doTestUrls(__file__) diff --git a/ietf/mailinglists/testurl.list b/ietf/mailinglists/testurl.list deleted file mode 100644 index 2e9153518..000000000 --- a/ietf/mailinglists/testurl.list +++ /dev/null @@ -1,4 +0,0 @@ -200 /list/wg/ -301 /list/nonwg/ -301 /list/nonwg/update/ -301 /list/request/ diff --git a/ietf/mailinglists/urls.py b/ietf/mailinglists/urls.py index 2787cf30e..9795b63de 100644 --- a/ietf/mailinglists/urls.py +++ b/ietf/mailinglists/urls.py @@ -1,14 +1,9 @@ # Copyright The IETF Trust 2007, All Rights Reserved from django.conf.urls.defaults import patterns -from ietf.idtracker.models import IETFWG -http_archive_wg_queryset = IETFWG.objects.filter(email_archive__startswith='http') - -urlpatterns = patterns('django.views.generic.list_detail', - (r'^wg/$', 'object_list', { 'queryset': http_archive_wg_queryset, 'template_name': 'mailinglists/wgwebmail_list.html' }), -) -urlpatterns += patterns('', +urlpatterns = patterns('', + (r'^wg/$', 'ietf.mailinglists.views.groups'), (r'^nonwg/$', 'django.views.generic.simple.redirect_to', { 'url': 'http://www.ietf.org/list/nonwg.html'}), (r'^nonwg/update/$', 'django.views.generic.simple.redirect_to', { 'url': 'http://www.ietf.org/list/nonwg.html'}), (r'^request/$', 'django.views.generic.simple.redirect_to', { 'url': 'http://www.ietf.org/list/request.html' }), diff --git a/ietf/mailinglists/views.py b/ietf/mailinglists/views.py index a4b306690..75cb7335e 100644 --- a/ietf/mailinglists/views.py +++ b/ietf/mailinglists/views.py @@ -1,2 +1,12 @@ # Copyright The IETF Trust 2007, All Rights Reserved +from ietf.group.models import Group +from django.shortcuts import render_to_response +from django.template import RequestContext + +def groups(request): + groups = Group.objects.filter(type__in=("wg", "rg"), list_archive__startswith='http').order_by("acronym") + + return render_to_response("mailinglists/group_archives.html", { "groups": groups }, + context_instance=RequestContext(request)) + diff --git a/ietf/templates/mailinglists/wgwebmail_list.html b/ietf/templates/mailinglists/group_archives.html similarity index 57% rename from ietf/templates/mailinglists/wgwebmail_list.html rename to ietf/templates/mailinglists/group_archives.html index 5f1471f9c..54f07377f 100644 --- a/ietf/templates/mailinglists/wgwebmail_list.html +++ b/ietf/templates/mailinglists/group_archives.html @@ -11,21 +11,20 @@ charters for more information about the mailing lists and archives of specific working groups. Charters for active working groups are available on - the Active - IETF Working Groups Web page. Charters for concluded working - groups are available on + the Active IETF Working Groups Web page. + Charters for concluded working groups are available on the Concluded Working Groups Web page.

- - - - -{% for wg in object_list|dictsort:"group_acronym.acronym" %} - - - - -{% endfor %} +
AcronymName
{{ wg|escape }}{{ wg.group_acronym.name|escape }}
+ + + + {% for group in groups %} + + + + + {% endfor %}
AcronymName
{{ group.acronym }}{{ group.name }}
{% endblock %}