コード例 #1
0
ファイル: bulk_sms.py プロジェクト: EswarSakamuri/mymics
def send(request):
    params = dict(request.POST)
    if valid_parameters(params, request):
        locations = Location.objects.filter(id__in=params['locations'])
        Interviewer.sms_interviewers_in_locations(locations=locations, text=params['text'][0])
        messages.success(request, "Your message has been sent to interviewers.")
    return HttpResponseRedirect(reverse('bulk_sms'))
コード例 #2
0
    def test_should_show_data_only_for_investigators_who_completed_a_selected_batch(self):
        batch = Batch.objects.create(name="Batch 2", survey=self.survey)
        member_group = HouseholdMemberGroup.objects.create(name='group1', order=1)
        question_1 = Question.objects.create(text="some question", answer_type=Question.NUMBER, order=1,
                                             group=member_group)
        question_2 = Question.objects.create(text="some question", answer_type=Question.NUMBER, order=1,
                                             group=member_group)
        self.batch.questions.add(question_1)
        batch.questions.add(question_2)
        batch.open_for_location(self.abim)

        BatchQuestionOrder.objects.create(question=question_1, batch=self.batch, order=1)
        BatchQuestionOrder.objects.create(question=question_2, batch=batch, order=1)

        member_1 = HouseholdMember.objects.create(household=self.household_1, date_of_birth=datetime(2000, 02, 02))
        member_2 = HouseholdMember.objects.create(household=self.household_1, date_of_birth=datetime(2000, 02, 02))

        self.investigator_1.member_answered(question_1, member_1, 1, self.batch)

        data = [self.investigator_1.name, self.investigator_1.mobile_number]
        data.extend([loc.name for loc in self.investigator_1.location_hierarchy().values()])
        investigator_completion = Interviewer.generate_completion_report(self.survey, self.batch)
        self.assertNotIn(data, investigator_completion)

        self.investigator_1.member_answered(question_1, member_2, 1, self.batch)
        investigator_completion = Interviewer.generate_completion_report(self.survey, self.batch)
        self.assertIn(data, investigator_completion)
コード例 #3
0
def send(request):
    params = dict(request.POST)
    if valid_parameters(params, request):
        locations = Location.objects.filter(id__in=params['locations'])
        Interviewer.sms_interviewers_in_locations(locations=locations,
                                                  text=params['text'][0])
        messages.success(request,
                         "Your message has been sent to interviewers.")
    return HttpResponseRedirect(reverse('bulk_sms'))
コード例 #4
0
    def test_should_return_headers_when_generate_report_called(self):
        Interviewer.objects.all().delete()
        data = ['Investigator', 'Phone Number']
        data.extend(LocationType.objects.all().values_list('name', flat=True))

        response = Interviewer.generate_completion_report(self.survey)
        self.assertIn(data, response)
コード例 #5
0
 def compute_for_location(self, location):
     interviewers = Interviewer.lives_under_location(location)
     if self.numerator.is_multichoice():
         return self.compute_multichoice_question_for_interviewers(
             interviewers)
     else:
         return self.compute_numerical_question_for_interviewers(
             interviewers)
コード例 #6
0
 def test_fields(self):
     ss_content = Interviewer()
     fields = [str(item.attname) for item in ss_content._meta.fields]
     self.assertEqual(11, len(fields))
     for field in [
             'id', 'created', 'modified', 'name', 'gender', 'date_of_birth',
             'level_of_education', 'is_blocked', 'ea_id', 'language',
             'weights'
     ]:
         self.assertIn(field, fields)
コード例 #7
0
    def test_should_show_data_only_for_investigators_who_completed_the_survey(self):
        member_group = HouseholdMemberGroup.objects.create(name='group1', order=1)
        question = Question.objects.create(text="some question", answer_type=Question.NUMBER, order=1,
                                           group=member_group)
        self.batch.questions.add(question)
        BatchQuestionOrder.objects.create(question=question, batch=self.batch, order=1)
        member_1 = HouseholdMember.objects.create(household=self.household_1, date_of_birth=datetime(2000, 02, 02))
        member_2 = HouseholdMember.objects.create(household=self.household_1, date_of_birth=datetime(2000, 02, 02))
        member_3 = HouseholdMember.objects.create(household=self.household_2, date_of_birth=datetime(2000, 02, 02))
        self.investigator_1.member_answered(question, member_1, 1, self.batch)
        self.investigator_1.member_answered(question, member_2, 1, self.batch)

        data = [self.investigator_1.name, self.investigator_1.mobile_number]
        data.extend([loc.name for loc in self.investigator_1.location_hierarchy().values()])
        response = Interviewer.generate_completion_report(self.survey)
        self.assertNotIn(data, response)

        self.investigator_1.member_answered(question, member_3, 1, self.batch)
        response = Interviewer.generate_completion_report(self.survey)
        self.assertIn(data, response)
コード例 #8
0
 def test_should_return_data_when_generate_data_called(self):
     data = [self.investigator_1.name, self.investigator_1.mobile_number]
     data.extend([loc.name for loc in self.investigator_1.location_hierarchy().values()])
     response = Interviewer.generate_completion_report(self.survey)
     self.assertIn(data, response)
コード例 #9
0
ファイル: formula.py プロジェクト: EswarSakamuri/mymics
 def compute_for_location(self, location):
     interviewers = Interviewer.lives_under_location(location)
     if self.numerator.is_multichoice():
         return self.compute_multichoice_question_for_interviewers(interviewers)
     else:
         return self.compute_numerical_question_for_interviewers(interviewers)
コード例 #10
0
 def send_message(self):
     investigator = Interviewer(mobile_number=self.mobile_number)
     investigator.backend = Backend.objects.all()[0]
     send(self.text_message(), [investigator])