Skip to content

Commit 0c1105f

Browse files
committed
Added a page that lists all the advertised non-wg mailing lists, based
on data fetched from mailman by a cronjob running the import_mailman_listinfo managemnt command. Fixes issue ietf-tools#2438. - Legacy-Id: 14587
1 parent 2687c8d commit 0c1105f

6 files changed

Lines changed: 83 additions & 8 deletions

File tree

ietf/mailinglists/management/commands/import_mailman_listinfo.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,13 @@ def note(msg):
3737
for name in names:
3838
mlist = MailList.MailList(name, lock=False)
3939
note("List: %s" % mlist.internal_name())
40+
sys.exit()
4041
if mlist.advertised:
4142
description = mlist.description.decode('latin1')[:256]
42-
mmlist, created = List.objects.get_or_create(name=mlist.real_name, description=description, advertised=mlist.advertised)
43+
mmlist, created = List.objects.get_or_create(name=mlist.real_name)
44+
mmlist.description = description
45+
mmlist.advertised = mlist.advertised
46+
mmlist.save()
4347
# The following calls return lowercased addresses
4448
members = mlist.getRegularMemberKeys() + mlist.getDigestMemberKeys()
4549
members = [ m for m in members if mlist.getDeliveryStatus(m) == MemberAdaptor.ENABLED ]

ietf/mailinglists/models.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# Copyright The IETF Trust 2016, All Rights Reserved
22

3-
from django.db import models
3+
4+
from django.conf import settings
45
from django.core.validators import validate_email
6+
from django.db import models
57

68
from ietf.person.models import Person
79

@@ -11,6 +13,8 @@ class List(models.Model):
1113
advertised = models.BooleanField(default=True)
1214
def __unicode__(self):
1315
return "<List: %s>" % self.name
16+
def info_url(self):
17+
return settings.MAILING_LIST_INFO_URL % {'list_addr': self.name }
1418

1519
class Subscribed(models.Model):
1620
time = models.DateTimeField(auto_now_add=True)

ietf/mailinglists/tests.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
# Copyright The IETF Trust 2016, All Rights Reserved
2+
# -*- coding: utf-8 -*-
3+
from __future__ import unicode_literals, print_function
4+
5+
from pyquery import PyQuery
26

37
from django.urls import reverse as urlreverse
48

5-
from pyquery import PyQuery
9+
import debug # pyflakes:ignore
610

11+
from ietf.mailinglists.factories import ListFactory
712
from ietf.utils.test_utils import TestCase
813
from ietf.utils.test_data import make_test_data
914

@@ -30,3 +35,15 @@ def test_groups(self):
3035
self.assertEqual(len(q("#content a:contains(\"%s\")" % group.acronym)), 1)
3136

3237

38+
def test_nonwg(self):
39+
lists = ListFactory.create_batch(7)
40+
url = urlreverse("ietf.mailinglists.views.nonwg")
41+
42+
r = self.client.get(url)
43+
for l in lists:
44+
if l.advertised:
45+
self.assertContains(r, l.name)
46+
self.assertContains(r, l.description)
47+
else:
48+
self.assertNotContains(r, l.name, html=True)
49+
self.assertNotContains(r, l.description, html=True)

ietf/mailinglists/urls.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
from ietf.utils.urls import url
77

88
urlpatterns = [
9-
url(r'^wg/$', views.groups),
10-
url(r'^nonwg/$', RedirectView.as_view(url='https://www.ietf.org/list/nonwg.html', permanent=True)),
11-
url(r'^nonwg/update/$', RedirectView.as_view(url='https://www.ietf.org/list/nonwg.html', permanent=True)),
12-
url(r'^request/$', RedirectView.as_view(url='https://www.ietf.org/list/request.html', permanent=True)),
9+
url(r'^wg/?$', views.groups),
10+
url(r'^nonwg/?$', views.nonwg),
11+
url(r'^nonwg/update/?$', RedirectView.as_view(url='https://www.ietf.org/list/nonwg.html', permanent=True)),
12+
url(r'^request/?$', RedirectView.as_view(url='https://www.ietf.org/list/request.html', permanent=True)),
1313
]

ietf/mailinglists/views.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,33 @@
11
# Copyright The IETF Trust 2007, All Rights Reserved
22

3-
from ietf.group.models import Group
3+
import re
4+
45
from django.shortcuts import render
56

7+
import debug # pyflakes:ignore
8+
9+
from ietf.group.models import Group
10+
from ietf.mailinglists.models import List
11+
612
def groups(request):
713
groups = Group.objects.filter(type__in=("wg", "rg", "ag"), list_archive__startswith='http').order_by("acronym")
814

915
return render(request, "mailinglists/group_archives.html", { "groups": groups } )
1016

17+
def nonwg(request):
18+
groups = Group.objects.filter(type__in=("wg", "rg")).order_by("acronym")
19+
20+
#urls = [ g.list_archive for g in groups if '.ietf.org' in g.list_archive ]
21+
22+
wg_lists = set()
23+
for g in groups:
24+
wg_lists.add(g.acronym)
25+
match = re.search(r'^(https?://mailarchive.ietf.org/arch/(browse/|search/\?email-list=))(?P<name>[^/]*)/?$', g.list_archive)
26+
if match:
27+
wg_lists.add(match.group('name').lower())
28+
29+
lists = List.objects.filter(advertised=True)
30+
#debug.show('lists.count()')
31+
lists = lists.exclude(name__in=wg_lists).order_by('name')
32+
#debug.show('lists.count()')
33+
return render(request, "mailinglists/nonwg.html", { "lists": lists } )
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{% extends "base.html" %}
2+
{# Copyright The IETF Trust 2015, All Rights Reserved #}
3+
{% load origin %}
4+
5+
{% block title %}Non-Working Group email lists{% endblock %}
6+
7+
{% block content %}
8+
{% origin %}
9+
<h1>Non-Working Group email lists</h1>
10+
11+
<table class="table table-condensed table-striped">
12+
<thead>
13+
<tr>
14+
<th>Name</th><th>Description</th><th>List Info</th>
15+
</tr>
16+
</thead>
17+
<tbody>
18+
{% for list in lists %}
19+
<tr>
20+
<td>{{ list.name.lower }}</td>
21+
<td>{{ list.description }}</td>
22+
<td><a href="{{ list.info_url }}">{{ list.info_url.lower }}</a></td>
23+
</tr>
24+
{% endfor %}
25+
</tbody>
26+
</table>
27+
{% endblock %}

0 commit comments

Comments
 (0)