Permalink
Browse files

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.
  • Loading branch information...
1 parent 0b4eff9 commit 9633db3a4e8c471d2ef751dac6e9678dea845a29 @mhagander mhagander committed Oct 19, 2013
Showing with 6 additions and 1 deletion.
  1. +6 −1 pgweb/survey/views.py
View
@@ -5,7 +5,7 @@
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)

0 comments on commit 9633db3

Please sign in to comment.