mirror of
https://github.com/postgres/pgweb.git
synced 2025-08-01 15:54:53 +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")
|
||||
|
@ -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
|
||||
|
||||
|
@ -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'),
|
||||
|
Reference in New Issue
Block a user