def get_household_list(self, non_response_reporting=False): open_survey = Survey.currently_open_survey(self.investigator.location) page = self.get_from_session('PAGE') self.responseString += "%s\n%s" % ( self.MESSAGES['HOUSEHOLD_LIST'], self.investigator.households_list(page, registered=False, open_survey=open_survey, non_response_reporting=non_response_reporting))
def select_household(self, answer, non_response_reporting=False): try: answer = int(answer) open_survey = Survey.currently_open_survey(self.investigator.location) self.household = self.investigator.all_households(open_survey, non_response_reporting)[answer - 1] self.set_in_session('HOUSEHOLD', self.household) except (ValueError, IndexError) as e: self.responseString += "INVALID SELECTION: "
def render_homepage(self): open_survey = Survey.currently_open_survey(self.investigator.location) answer = self.request['ussdRequestString'].strip() if not self.investigator.has_households(survey=open_survey): self.action = self.ACTIONS['END'] self.responseString = self.MESSAGES['NO_HOUSEHOLDS'] else: self.render_household_or_household_member(answer, open_survey)
def render_homepage(self): open_survey = Survey.currently_open_survey(self.investigator.location) answer = self.request['ussdRequestString'].strip() if not self.investigator.has_households(survey=open_survey): self.action = self.ACTIONS['END'] self.responseString = self.MESSAGES['NO_HOUSEHOLDS'] else: self.render_household_or_household_member(answer, open_survey)
def set_household_form(uid=None, data=None, is_edit=False, instance=None): household_form = {} if not is_edit: household_form['householdHead'] = HouseholdHeadForm(data=data, auto_id='household-%s', label_suffix='') open_survey = Survey.currently_open_survey() household_form['household'] = HouseholdForm(data=data, instance=instance, is_edit=is_edit, uid=uid, survey=open_survey, auto_id='household-%s', label_suffix='') return household_form
def restart_survey(self): answer = self.request['ussdRequestString'].strip() if answer == self.ANSWER['YES']: if self.has_chosen_household_member(): self.household_member.mark_past_answers_as_old() self.render_survey() else: self.render_household_members_list() if answer == self.ANSWER['NO']: self.set_in_session('HOUSEHOLD', None) self.set_in_session('HOUSEHOLD_MEMBER', None) self.household = None self.render_households_list(Survey.currently_open_survey(self.investigator.location)) self.action = self.ACTIONS['REQUEST']
def restart_survey(self): answer = self.request['ussdRequestString'].strip() if answer == self.ANSWER['YES']: if self.has_chosen_household_member(): self.household_member.mark_past_answers_as_old() self.render_survey() else: self.render_household_members_list() if answer == self.ANSWER['NO']: self.set_in_session('HOUSEHOLD', None) self.set_in_session('HOUSEHOLD_MEMBER', None) self.household = None self.render_households_list( Survey.currently_open_survey(self.investigator.location)) self.action = self.ACTIONS['REQUEST']
def create_household(householdform, investigator, valid, uid): is_valid_household = householdform['household'].is_valid() if investigator and is_valid_household: household = householdform['household'].save(commit=False) household.investigator = investigator household.ea = investigator.ea open_survey = Survey.currently_open_survey(investigator.location) household.household_code = LocationCode.get_household_code(investigator) + str(Household.next_uid(open_survey)) if uid: household.uid = uid household.household_code = LocationCode.get_household_code(investigator) + str(uid) household.survey = open_survey household.save() valid['household'] = True return valid
def is_active(self): return self.investigator.was_active_within(self.TIMEOUT_MINUTES) or self.investigator.created_member_within( self.TIMEOUT_MINUTES, Survey.currently_open_survey(self.investigator.location))
def forwards(self, orm): open_survey = Survey.currently_open_survey() if open_survey: for household in orm["survey.household"].objects.all(): household.survey_id = open_survey.id household.save()
def __init__(self, investigator, params): self.investigator = investigator self.params = params self.open_survey = Survey.currently_open_survey(self.investigator.location)
def forwards(self, orm): open_survey = Survey.currently_open_survey() if open_survey: for household in orm["survey.household"].objects.all(): household.survey_id = open_survey.id household.save()
def __init__(self, investigator, params): self.investigator = investigator self.params = params self.open_survey = Survey.currently_open_survey( self.investigator.location)
def is_active(self): return self.investigator.was_active_within( self.TIMEOUT_MINUTES) or self.investigator.created_member_within( self.TIMEOUT_MINUTES, Survey.currently_open_survey(self.investigator.location))