mirror of
https://github.com/postgres/pgweb.git
synced 2025-07-29 11:59:36 +00:00
Make explicit cache purge on survey votes
It should have been done through the model, but that is somehow not working. Therefor, make an immediate purge of the results to the specific survey that is being voted on.
This commit is contained in:
@ -5,7 +5,7 @@ from django.template.defaultfilters import slugify
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
|
||||
from pgweb.util.contexts import NavContext
|
||||
from pgweb.util.misc import get_client_ip
|
||||
from pgweb.util.misc import get_client_ip, varnish_purge
|
||||
from pgweb.util.helpers import HttpServerError
|
||||
|
||||
from models import Survey, SurveyAnswer, SurveyLock
|
||||
@ -54,5 +54,10 @@ def vote(request, surveyid):
|
||||
setattr(answers, attrname, getattr(answers, attrname)+1)
|
||||
answers.save()
|
||||
|
||||
# Do explicit varnish purge, since it seems that the model doesn't
|
||||
# do it properly. Possibly because of the cute stuff we do with
|
||||
# getattr/setattr above.
|
||||
varnish_purge("/community/survey/%s/" % surveyid)
|
||||
|
||||
return HttpResponseRedirect("/community/survey/%s/" % surveyid)
|
||||
|
||||
|
Reference in New Issue
Block a user