Adds current runinfo to the active request object and fixes a bug in dep_check which led to some answers being read from the database even if they were in the checkdict

EmailTemplateFixes
Denis Krienbühl 2012-01-21 16:03:15 +01:00
parent a2edba3b55
commit 2cda706ac5
2 changed files with 7 additions and 2 deletions

View File

@ -188,7 +188,7 @@ class RunInfo(models.Model):
if not self.cookies:
return default
d = self.get_cookiedict()
return d.get(key, default)
return d.get(key.lower().strip(), default)
def get_cookiedict(self):
if not self.cookies:

View File

@ -212,6 +212,11 @@ def questionnaire(request, runcode=None, qs=None):
transaction.commit()
return HttpResponseRedirect('/')
# let the runinfo have a piggy back ride on the request
# so we can easily use the runinfo in places like the question processor
# without passing it around
request.runinfo = runinfo
if not qs:
# Only change the language to the subjects choice for the initial
# questionnaire page (may be a direct link from an email)
@ -784,7 +789,6 @@ def has_tag(tag, runinfo):
return tag in (t.strip() for t in runinfo.tags.split(','))
def dep_check(expr, runinfo, answerdict):
"""
Given a comma separated question number and expression, determine if the
@ -811,6 +815,7 @@ def dep_check(expr, runinfo, answerdict):
questionnaire = runinfo.questionset.questionnaire
if "," not in expr:
expr = expr + ",yes"
check_questionnum, check_answer = expr.split(",",1)
try:
check_question = Question.objects.get(number=check_questionnum,