diff --git a/pgweb/lists/views.py b/pgweb/lists/views.py index f8e2e685..827d6708 100644 --- a/pgweb/lists/views.py +++ b/pgweb/lists/views.py @@ -1,5 +1,5 @@ -from django.shortcuts import render_to_response -from django.http import HttpResponse +from django.shortcuts import render_to_response, get_object_or_404 +from django.http import HttpResponse, HttpResponseForbidden from django.views.decorators.csrf import csrf_exempt from django.conf import settings @@ -67,3 +67,17 @@ def listinfo(request): } for l in MailingList.objects.all()] json.dump({'groups': groupdata, 'lists': listdata}, resp) return resp + +# Temporary API endpoint +def activate(request): + if not request.META['REMOTE_ADDR'] in settings.LIST_ACTIVATORS: + return HttpResponseForbidden() + listname = request.GET['listname'] + active = (request.GET['active'] == '1') + + l = get_object_or_404(MailingList, listname=listname) + if l.active == active: + return HttpResponse("Not changed") + l.active = active + l.save() + return HttpResponse("Changed") diff --git a/pgweb/settings.py b/pgweb/settings.py index 8fa0a334..a443c7ae 100644 --- a/pgweb/settings.py +++ b/pgweb/settings.py @@ -169,6 +169,7 @@ FRONTEND_SERVERS=() # A tuple containing the FTP_MASTERS=() # A tuple containing the *IP addresses* of all machines # trusted to upload ftp structure data VARNISH_PURGERS=() # Extra servers that can do varnish purges through our queue +LIST_ACTIVATORS=() # Servers that can activate lists ARCHIVES_SEARCH_SERVER="archives.postgresql.org" # Where to post REST request for archives search FRONTEND_SMTP_RELAY="magus.postgresql.org" # Where to relay user generated email diff --git a/pgweb/urls.py b/pgweb/urls.py index bf57d551..4321c40b 100644 --- a/pgweb/urls.py +++ b/pgweb/urls.py @@ -50,6 +50,7 @@ urlpatterns = patterns('', (r'^community/lists/$', RedirectView.as_view(url='/list/', permanent=True)), (r'^community/lists/subscribe/$', 'pgweb.lists.views.subscribe'), (r'^community/lists/listinfo/$', 'pgweb.lists.views.listinfo'), + (r'^community/lists/activate/$', 'pgweb.lists.views.activate'), (r'^community/survey/vote/(\d+)/$', 'pgweb.survey.views.vote'), (r'^community/survey[/\.](\d+)(-.*)?/$', 'pgweb.survey.views.results'), (r'^community/user-groups/$', 'pgweb.pugs.views.index'),