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:
Magnus Hagander
2013-10-19 15:09:47 +02:00
parent 0b4eff93e2
commit 9633db3a4e

View File

@ -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)