本文整理汇总了Python中questionnaire.services.users.UserQuestionnaireService.required_sections_answered方法的典型用法代码示例。如果您正苦于以下问题:Python UserQuestionnaireService.required_sections_answered方法的具体用法?Python UserQuestionnaireService.required_sections_answered怎么用?Python UserQuestionnaireService.required_sections_answered使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类questionnaire.services.users.UserQuestionnaireService
的用法示例。
在下文中一共展示了UserQuestionnaireService.required_sections_answered方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from questionnaire.services.users import UserQuestionnaireService [as 别名]
# 或者: from questionnaire.services.users.UserQuestionnaireService import required_sections_answered [as 别名]
def post(self, request, *args, **kwargs):
user_country = self.request.user.user_profile.country
questionnaire = Questionnaire.objects.get(id=self.kwargs['questionnaire_id'])
user_questionnaire = UserQuestionnaireService(user_country, questionnaire)
if not user_questionnaire.required_sections_answered():
return self._reload_section_with_required_answers_errors(request, user_questionnaire, *args, **kwargs)
return self._submit_answers(request, user_questionnaire, *args, **kwargs)
示例2: test_should_return_invalid_section_answers_and_the_corresponding_formset
# 需要导入模块: from questionnaire.services.users import UserQuestionnaireService [as 别名]
# 或者: from questionnaire.services.users.UserQuestionnaireService import required_sections_answered [as 别名]
def test_should_return_invalid_section_answers_and_the_corresponding_formset(self):
data = self.data.copy()
old_primary = MultiChoiceAnswer.objects.create(response=self.option1, question=self.question1, **self.initial)
old_answer_1 = NumericalAnswer.objects.create(response=int(data['Number-0-response']), question=self.question2, **self.initial)
old_answer_2 = NumericalAnswer.objects.create(response=int(data['Number-1-response']), question=self.question3, **self.initial)
answer_group = AnswerGroup.objects.create(grouped_question=self.question_group)
answer_group.answer.add(old_primary, old_answer_1, old_answer_2)
required_question = Question.objects.create(text='required', UID='C00330', answer_type='Number', is_required=True)
self.question_group.question.add(required_question)
QuestionGroupOrder.objects.create(question_group=self.question_group, question=required_question, order=4)
user_service = UserQuestionnaireService(self.user.user_profile.country, self.questionnaire)
self.assertFalse(user_service.required_sections_answered())
self.assertEqual(self.section_1, user_service.unanswered_section)
示例3: post
# 需要导入模块: from questionnaire.services.users import UserQuestionnaireService [as 别名]
# 或者: from questionnaire.services.users.UserQuestionnaireService import required_sections_answered [as 别名]
def post(self, request, *args, **kwargs):
questionnaire = Questionnaire.objects.get(status=Questionnaire.PUBLISHED)
user_questionnaire = UserQuestionnaireService(self.request.user, questionnaire)
if not user_questionnaire.required_sections_answered():
return self._reload_section_with_required_answers_errors(request, user_questionnaire, *args, **kwargs)
return self._submit_answers(request, user_questionnaire, *args, **kwargs)