コード例 #1
0
 def get_initial(self):
     initial = super().get_initial()
     intro, body = TransferService.render_application_transfer_message(
         form_submission=self.submission,
         author=self.author,
         to_organization=self.to_organization,
         from_organization=self.from_organization)
     self.message_intro = intro
     initial.update(to_organization=self.to_organization,
                    sent_message=body,
                    next_url=self.next_url)
     return initial
コード例 #2
0
 def get_initial(self):
     initial = super().get_initial()
     intro, body = TransferService.render_application_transfer_message(
         form_submission=self.submission,
         author=self.author,
         to_organization=self.to_organization,
         from_organization=self.from_organization)
     self.message_intro = intro
     initial.update(
         to_organization=self.to_organization,
         sent_message=body,
         next_url=self.next_url)
     return initial
コード例 #3
0
 def test_can_transfer_successfully(self, front):
     user = self.be_apubdef_user()
     self.assertEqual(
         0,
         models.ApplicationTransfer.objects.filter(
             new_application__form_submission_id=self.sub.id).distinct().
         count())
     # perform the transfer
     response = self.post()
     # check the response
     self.assertRedirects(response,
                          reverse('intake-app_index'),
                          fetch_redirect_response=False)
     # check for resulting database objects
     transfers = models.ApplicationTransfer.objects.filter(
         new_application__form_submission_id=self.sub.id).distinct()
     self.assertEqual(transfers.count(), 1)
     transfer = transfers.first()
     self.assertEqual(transfer.new_application.organization, self.to_org)
     self.assertEqual(transfer.status_update.application.organization,
                      self.from_org)
     self.assertEqual(transfer.status_update.author, user)
     self.assertEqual(transfer.reason, "because of subspace interference")
     sub_orgs = list(self.sub.organizations.all())
     self.assertIn(self.from_org, sub_orgs)
     self.assertIn(self.to_org, sub_orgs)
     self.assertTrue(transfer.status_update.application.was_transferred_out)
     self.assertTrue(transfer.status_update.notification)
     notification = transfer.status_update.notification
     self.assertTrue(transfer.status_update.notification.contact_info)
     sub = transfer.status_update.application.form_submission
     intro, default_body = \
         TransferService.render_application_transfer_message(
             form_submission=sub,
             author=user,
             to_organization=self.to_org,
             from_organization=self.from_org)
     expected_base_message = "\n\n".join([intro, default_body])
     expected_sent_message = "\n\n".join(
         [intro, "we are sending you to the other place"])
     self.assertEqual(notification.base_message, expected_base_message)
     self.assertEqual(notification.sent_message, expected_sent_message)
     self.assertDictEqual(notification.contact_info,
                          sub.get_usable_contact_info())
     self.assertEqual(len(front.mock_calls), 1)
     front.assert_called_once_with(notification.contact_info,
                                   expected_sent_message,
                                   subject="Update from Clear My Record",
                                   sender_profile=user.profile)
コード例 #4
0
 def test_can_transfer_successfully(self, front):
     user = self.be_apubdef_user()
     self.assertEqual(
         0,
         models.ApplicationTransfer.objects.filter(
             new_application__form_submission_id=self.sub.id
         ).distinct().count())
     # perform the transfer
     response = self.post()
     # check the response
     self.assertRedirects(
         response, reverse('intake-app_index'),
         fetch_redirect_response=False)
     # check for resulting database objects
     transfers = models.ApplicationTransfer.objects.filter(
         new_application__form_submission_id=self.sub.id).distinct()
     self.assertEqual(transfers.count(), 1)
     transfer = transfers.first()
     self.assertEqual(transfer.new_application.organization, self.to_org)
     self.assertEqual(
         transfer.status_update.application.organization, self.from_org)
     self.assertEqual(transfer.status_update.author, user)
     self.assertEqual(transfer.reason, "because of subspace interference")
     sub_orgs = list(self.sub.organizations.all())
     self.assertIn(self.from_org, sub_orgs)
     self.assertIn(self.to_org, sub_orgs)
     self.assertTrue(transfer.status_update.application.was_transferred_out)
     self.assertTrue(transfer.status_update.notification)
     notification = transfer.status_update.notification
     self.assertTrue(transfer.status_update.notification.contact_info)
     sub = transfer.status_update.application.form_submission
     intro, default_body = \
         TransferService.render_application_transfer_message(
             form_submission=sub,
             author=user,
             to_organization=self.to_org,
             from_organization=self.from_org)
     expected_base_message = "\n\n".join([intro, default_body])
     expected_sent_message = "\n\n".join(
         [intro, "we are sending you to the other place"])
     self.assertEqual(notification.base_message, expected_base_message)
     self.assertEqual(notification.sent_message, expected_sent_message)
     self.assertDictEqual(
         notification.contact_info, sub.get_usable_contact_info())
     self.assertEqual(len(front.mock_calls), 1)
     front.assert_called_once_with(
         notification.contact_info, expected_sent_message,
         subject="Update from Clear My Record")
コード例 #5
0
 def test_sees_expected_message(self):
     user = self.be_apubdef_user()
     response = self.client.get(self.url)
     expected_intro, expected_body = \
         TransferService.render_application_transfer_message(
             form_submission=self.sub,
             author=user,
             to_organization=self.to_org,
             from_organization=self.from_org)
     self.assertContains(response, escape(expected_intro))
     self.assertContains(response, escape(expected_body))
     self.assertIn(self.to_org.name, expected_body)
     self.assertIn(self.from_org.name, expected_intro)
     self.assertIn(user.profile.name, expected_intro)
     self.assertContains(response, 'following message will be')
     self.assertContains(response, 'to the applicant')
コード例 #6
0
 def test_sees_expected_message(self):
     user = self.be_apubdef_user()
     response = self.client.get(self.url)
     expected_intro, expected_body = \
         TransferService.render_application_transfer_message(
             form_submission=self.sub,
             author=user,
             to_organization=self.to_org,
             from_organization=self.from_org)
     self.assertContains(response, escape(expected_intro))
     self.assertContains(response, escape(expected_body))
     self.assertIn(self.to_org.name, expected_body)
     self.assertIn(self.from_org.name, expected_intro)
     self.assertIn(user.profile.name, expected_intro)
     self.assertContains(response, 'following message will be')
     self.assertContains(response, 'to the applicant')