Adds questionnaire to RunInfoHistory (with foreign key)
parent
57eb0af4d4
commit
314ea0d788
|
@ -109,7 +109,8 @@
|
||||||
- fields: {
|
- fields: {
|
||||||
completed: 2009-05-16,
|
completed: 2009-05-16,
|
||||||
runid: 'test:test',
|
runid: 'test:test',
|
||||||
subject: 1
|
subject: 1,
|
||||||
|
questionnaire: 1,
|
||||||
}
|
}
|
||||||
model: questionnaire.runinfohistory
|
model: questionnaire.runinfohistory
|
||||||
pk: 1
|
pk: 1
|
||||||
|
|
|
@ -209,10 +209,19 @@ class RunInfoHistory(models.Model):
|
||||||
subject = models.ForeignKey(Subject)
|
subject = models.ForeignKey(Subject)
|
||||||
runid = models.CharField(max_length=32)
|
runid = models.CharField(max_length=32)
|
||||||
completed = models.DateField()
|
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):
|
def __unicode__(self):
|
||||||
return "%s: %s on %s" % (self.runid, self.subject, self.completed)
|
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:
|
class Meta:
|
||||||
verbose_name_plural = 'Run Info History'
|
verbose_name_plural = 'Run Info History'
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ def add_answer(runinfo, question, answer_dict):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def check_parser(runinfo):
|
def check_parser(runinfo, exclude=[]):
|
||||||
depparser = BooleanParser(dep_check, runinfo, {})
|
depparser = BooleanParser(dep_check, runinfo, {})
|
||||||
tagparser = BooleanParser(has_tag, runinfo)
|
tagparser = BooleanParser(has_tag, runinfo)
|
||||||
|
|
||||||
|
@ -92,6 +92,9 @@ def check_parser(runinfo):
|
||||||
"iftag": lambda v: v and tagparser.parse(v)
|
"iftag": lambda v: v and tagparser.parse(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for ex in exclude:
|
||||||
|
del fnmap[ex]
|
||||||
|
|
||||||
def satisfies_checks(checks):
|
def satisfies_checks(checks):
|
||||||
checks = parse_checks(checks)
|
checks = parse_checks(checks)
|
||||||
|
|
||||||
|
@ -295,6 +298,7 @@ def questionnaire(request, runcode=None, qs=None):
|
||||||
hist.subject = runinfo.subject
|
hist.subject = runinfo.subject
|
||||||
hist.runid = runinfo.runid
|
hist.runid = runinfo.runid
|
||||||
hist.completed = datetime.now()
|
hist.completed = datetime.now()
|
||||||
|
hist.questionnaire = questionnaire
|
||||||
hist.save()
|
hist.save()
|
||||||
|
|
||||||
questionnaire_done.send(sender=None, runinfo=runinfo,
|
questionnaire_done.send(sender=None, runinfo=runinfo,
|
||||||
|
|
Loading…
Reference in New Issue