def choices(self): if self.type == 'sameas': return self.sameas().choices() res = None if 'samechoicesas' in parse_checks(self.checks): number_to_grab_from = parse_checks(self.checks)['samechoicesas'] choicesource = Question.objects.get(number=number_to_grab_from, questionset__questionnaire=self.questionset.questionnaire) if not choicesource == None: res = Choice.objects.filter(question=choicesource).order_by('sortid') else: res = Choice.objects.filter(question=self).order_by('sortid') return res
def getcheckdict(self): """getcheckdict returns a dictionary of the values in self.checks""" if hasattr(self, "__checkdict_cached"): return self.__checkdict_cached try: self.__checkdict_cached = d = parse_checks(self.sameas().checks or "") except ParseException: raise Exception("Error Parsing Checks for Question %s: %s" % (self.number, self.sameas().checks)) return d
def getcheckdict(self): """getcheckdict returns a dictionary of the values in self.checks""" if(hasattr(self, '__checkdict_cached')): return self.__checkdict_cached try: self.__checkdict_cached = d = parse_checks(self.sameas().checks or '') except ParseException: raise Exception("Error Parsing Checks for Question %s: %s" % ( self.number, self.sameas().checks)) return d
def getcheckdict(self): """getcheckdict returns a dictionary of the values in self.checks""" if(hasattr(self, '__checkdict_cached')): return self.__checkdict_cached try: self.__checkdict_cached = d = parse_checks(self.sameas().checks or '') except ParseException, e: logging.exception("Error Parsing Checks for Question %s: %s" % ( self.number, self.sameas().checks)) raise Exception("Error Parsing Checks for Question %s: %s" % ( self.number, self.sameas().checks))
def sameas(self): if self.type == 'sameas': try: kwargs = {} for check, value in parse_checks(self.checks): if check == 'sameasid': kwargs['id'] = value break elif check == 'sameas': kwargs['number'] = value kwargs['questionset__questionnaire'] = self.questionset.questionnaire break self.__sameas = res = getattr(self, "__sameas", Question.objects.get(**kwargs)) return res except Question.DoesNotExist: return Question(type='comment') # replace with something benign return self
def sameas(self): if self.type == "sameas": try: kwargs = {} for check, value in parse_checks(self.checks): if check == "sameasid": kwargs["id"] = value break elif check == "sameas": kwargs["number"] = value kwargs["questionset__questionnaire"] = self.questionset.questionnaire break self.__sameas = res = getattr(self, "__sameas", Question.objects.get(**kwargs)) return res except Question.DoesNotExist: # replace with something benign return Question(type="comment") return self