Adds questionnaire to RunInfoHistory (with foreign key)

EmailTemplateFixes
Denis Krienbühl 2012-01-04 16:22:18 +01:00
parent 57eb0af4d4
commit 314ea0d788
3 changed files with 16 additions and 2 deletions

View File

@ -109,7 +109,8 @@
- fields: {
completed: 2009-05-16,
runid: 'test:test',
subject: 1
subject: 1,
questionnaire: 1,
}
model: questionnaire.runinfohistory
pk: 1

View File

@ -209,10 +209,19 @@ class RunInfoHistory(models.Model):
subject = models.ForeignKey(Subject)
runid = models.CharField(max_length=32)
completed = models.DateField()
tags = models.TextField(
blank=True,
help_text=u"Tags used on this run, separated by commas"
)
questionnaire = models.ForeignKey(Questionnaire)
def __unicode__(self):
return "%s: %s on %s" % (self.runid, self.subject, self.completed)
def answers(self):
"Returns the query for the answers."
return Answer.objects.filter(subject=self.subject, runid=self.runid)
class Meta:
verbose_name_plural = 'Run Info History'

View File

@ -81,7 +81,7 @@ def add_answer(runinfo, question, answer_dict):
return True
def check_parser(runinfo):
def check_parser(runinfo, exclude=[]):
depparser = BooleanParser(dep_check, runinfo, {})
tagparser = BooleanParser(has_tag, runinfo)
@ -92,6 +92,9 @@ def check_parser(runinfo):
"iftag": lambda v: v and tagparser.parse(v)
}
for ex in exclude:
del fnmap[ex]
def satisfies_checks(checks):
checks = parse_checks(checks)
@ -295,6 +298,7 @@ def questionnaire(request, runcode=None, qs=None):
hist.subject = runinfo.subject
hist.runid = runinfo.runid
hist.completed = datetime.now()
hist.questionnaire = questionnaire
hist.save()
questionnaire_done.send(sender=None, runinfo=runinfo,