datatracker/ietf/mailinglists/views.py
Henrik Levkowetz 7f462b330b Added view caching of the non-wg list index.
- Legacy-Id: 14601
2018-01-31 18:02:54 +00:00

38 lines
1.3 KiB
Python

# Copyright The IETF Trust 2007, All Rights Reserved
import re
from django.shortcuts import render
from django.views.decorators.cache import cache_page
import debug # pyflakes:ignore
from ietf.group.models import Group
from ietf.mailinglists.models import List
def groups(request):
groups = Group.objects.filter(type__in=("wg", "rg", "ag"), list_archive__startswith='http').order_by("acronym")
return render(request, "mailinglists/group_archives.html", { "groups": groups } )
# we run the import_mailman_listinfo command via cron once per hour; we can
# safely cache this for some time.
@cache_page(15*60)
def nonwg(request):
groups = Group.objects.filter(type__in=("wg", "rg")).order_by("acronym")
#urls = [ g.list_archive for g in groups if '.ietf.org' in g.list_archive ]
wg_lists = set()
for g in groups:
wg_lists.add(g.acronym)
match = re.search(r'^(https?://mailarchive.ietf.org/arch/(browse/|search/\?email-list=))(?P<name>[^/]*)/?$', g.list_archive)
if match:
wg_lists.add(match.group('name').lower())
lists = List.objects.filter(advertised=True)
#debug.show('lists.count()')
lists = lists.exclude(name__in=wg_lists).order_by('name')
#debug.show('lists.count()')
return render(request, "mailinglists/nonwg.html", { "lists": lists } )