本文整理汇总了Python中survey.models.Survey.currently_open_survey方法的典型用法代码示例。如果您正苦于以下问题:Python Survey.currently_open_survey方法的具体用法?Python Survey.currently_open_survey怎么用?Python Survey.currently_open_survey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类survey.models.Survey
的用法示例。
在下文中一共展示了Survey.currently_open_survey方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_household_list
# 需要导入模块: from survey.models import Survey [as 别名]
# 或者: from survey.models.Survey import currently_open_survey [as 别名]
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))
示例2: select_household
# 需要导入模块: from survey.models import Survey [as 别名]
# 或者: from survey.models.Survey import currently_open_survey [as 别名]
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: "
示例3: render_homepage
# 需要导入模块: from survey.models import Survey [as 别名]
# 或者: from survey.models.Survey import currently_open_survey [as 别名]
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)
示例4: set_household_form
# 需要导入模块: from survey.models import Survey [as 别名]
# 或者: from survey.models.Survey import currently_open_survey [as 别名]
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
示例5: restart_survey
# 需要导入模块: from survey.models import Survey [as 别名]
# 或者: from survey.models.Survey import currently_open_survey [as 别名]
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']
示例6: create_household
# 需要导入模块: from survey.models import Survey [as 别名]
# 或者: from survey.models.Survey import currently_open_survey [as 别名]
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
示例7: is_active
# 需要导入模块: from survey.models import Survey [as 别名]
# 或者: from survey.models.Survey import currently_open_survey [as 别名]
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))
示例8: __init__
# 需要导入模块: from survey.models import Survey [as 别名]
# 或者: from survey.models.Survey import currently_open_survey [as 别名]
def __init__(self, investigator, params):
self.investigator = investigator
self.params = params
self.open_survey = Survey.currently_open_survey(self.investigator.location)
示例9: forwards
# 需要导入模块: from survey.models import Survey [as 别名]
# 或者: from survey.models.Survey import currently_open_survey [as 别名]
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()