Export list information as json
authorMagnus Hagander <magnus@hagander.net>
Sun, 15 Jan 2012 15:19:48 +0000 (16:19 +0100)
committerMagnus Hagander <magnus@hagander.net>
Sat, 21 Jan 2012 13:50:01 +0000 (14:50 +0100)
This makes it easier to sync information about which lists we have,
and how they are grouped, to external sites (such as the search crawler)

pgweb/lists/views.py
pgweb/urls.py

index 89c5c43b90dd466718845aac11b12730ac74af4b..c624096fc01d1d499c032516be3e2fa4efe1a273 100644 (file)
@@ -5,6 +5,7 @@ from django.contrib.auth.decorators import login_required
 from django.conf import settings
 
 from email.mime.text import MIMEText
+import simplejson as json
 
 from pgweb.util.contexts import NavContext
 from pgweb.util.misc import sendmail
@@ -52,3 +53,19 @@ mail-back anti-spam systems. These are extremely annoying to the list maintainer
 and other members, and you may be automatically unsubscribed."""
        }, NavContext(request, "community"))
 
+def listinfo(request):
+       resp = HttpResponse(mimetype='application/json')
+       groupdata = [ {
+                       'id': g.id,
+                       'name': g.groupname,
+                       } for g in MailingListGroup.objects.all()]
+       listdata = [ {
+                       'id': l.id,
+                       'name': l.listname,
+                       'groupid': l.group_id,
+                       'active': l.active,
+                       'shortdesc': l.shortdesc,
+                       'description': l.description,
+                       } for l in MailingList.objects.all()]
+       json.dump({'groups': groupdata, 'lists': listdata}, resp)
+       return resp
index 3248c2086bfbd469d58819ae6e1ec994cc8f487e..4cd8576acc79a92bba63427b9dc3f74c45e5097f 100644 (file)
@@ -51,6 +51,7 @@ urlpatterns = patterns('',
     (r'^community/contributors/$', 'contributors.views.completelist'),
     (r'^community/lists/$', 'lists.views.root'),
     (r'^community/lists/subscribe/$', 'lists.views.subscribe'),
+    (r'^community/lists/listinfo/$', 'lists.views.listinfo'),
     (r'^community/survey/vote/(\d+)/$', 'survey.views.vote'),
     (r'^community/survey[/\.](\d+)(-.*)?/$', 'survey.views.results'),
        (r'^community/weeklynews/$', 'pwn.views.index'),