mirror of
https://github.com/postgres/pgweb.git
synced 2025-08-05 18:34:52 +00:00
Add simple API endpoint to activate and deactivate a list
Access is restricted by IP for the list server. Once the migration is done, we should probably remove the endpoint again.
This commit is contained in:
@ -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")
|
||||
|
Reference in New Issue
Block a user