Beispiel #1
0
 def post(self, request, *args, **kwargs):
     application_ids = ast.literal_eval(request.POST.get('application_ids'))
     send_text_messages = request.POST.get('send_text_messages')
     common.update_application_statuses(
         application_ids, Application.ApplicationStatus.PAYMENT_CONFIRMED,
         bool(send_text_messages))
     return HttpResponseRedirect(reverse('staff:payments'))
Beispiel #2
0
    def handle(self, *args, **kwargs):
        filename = kwargs['filename']
        status = getattr(Application.ApplicationStatus,
                         kwargs['status'].upper())

        with open(filename, 'r') as f:
            application_ids = [line.strip() for line in f]

        update_application_statuses(application_ids, status)
Beispiel #3
0
 def post(self, request, *args, **kwargs):
     requested_status = self.kwargs.get('status')
     application_ids = ast.literal_eval(request.POST.get('application_ids'))
     filename = 'tmp.csv'
     self.write_payments_csv(filename, requested_status)
     # When a download is requested for APPROVED applications, we update
     # their status to SENT_FOR_PAYMENT. This is a bit of a hack while we
     # still need CSVs to be uploaded for payment manually.
     # See payments user journeys here:
     # https://docs.google.com/document/d/1SbAEaOq-sxkPz1MYm01odUG7ktQEsVS8QklHHtHEEAI/
     if requested_status == Application.ApplicationStatus.APPROVED:
         applications = Application.objects.filter(pk__in=application_ids)
         common.update_application_statuses(
             applications, Application.ApplicationStatus.SENT_FOR_PAYMENT)
     return FileResponse(open(filename, 'rb'))
Beispiel #4
0
    def test_update_application_withTextMessaging(self, language):
        self.trigger_text_messages_mock.reset_mock()

        self.models[0].language = language
        self.models[0].save()
        self.models[1].language = language
        self.models[1].phone_number = '+16666666666'
        self.models[1].save()

        update_application_statuses(
            (self.models[0].application_id, self.models[1].application_id),
            Application.ApplicationStatus.PAYMENT_CONFIRMED)

        self.assertEqual(1, self.trigger_text_messages_mock.call_count)
        self.assertEqual({'+15555555555', '+16666666666'},
                         self.trigger_text_messages_mock.call_args[0][0])
Beispiel #5
0
    def test_update_application_statuses(self, status):
        id_of_applications_to_update = [
            self.models[2].application_id,
            self.models[3].application_id,
            self.models[4].application_id,
        ]

        # Act
        update_application_statuses(id_of_applications_to_update, status)

        for m in self.models:
            m.refresh_from_db()

        # Verify updated models
        self.assertEqual(status, self.models[2].status)
        self.assertEqual(status, self.models[3].status)
        self.assertEqual(status, self.models[4].status)
        # Verify untouched models
        self.assertEqual(Application.ApplicationStatus.APPROVED,
                         self.models[0].status)
        self.assertEqual(Application.ApplicationStatus.NEEDS_REVIEW,
                         self.models[1].status)