def handle(self, *args, **options):
     call_command('flush', interactive=False)
     self.stdout.write(
         self.style.SUCCESS("Destroyed all existing data"))
     call_command('load_essential_data')
     self.stdout.write(
         self.style.SUCCESS(
             "Loaded organizations, counties, groups, & permissions "
             "from fixtures"))
     create_seed_users()
     self.stdout.write(
         self.style.SUCCESS("Created fake user profiles"))
     serialize_seed_users()
     self.stdout.write(
         self.style.SUCCESS(
             "Saved to mock_profiles fixture"))
     fillable_pdf()
     self.stdout.write(
         self.style.SUCCESS(
             "Load fake fillable pdf"))
     build_seed_submissions()
     self.stdout.write(
         self.style.SUCCESS(
             "Created fake submissions, bundles, and transfers "
             "and saved them to fixture files"))
     for app_id in Application.objects.filter(
                 organization__slug='sf_pubdef'
             ).values_list('id', flat=True):
         fill_pdf_for_application(app_id)
     update_pdf_bundle_for_san_francisco()
     self.stdout.write(
         self.style.SUCCESS(
             "Pre-filled PDFs for San Francisco, including pdf bundle of "
             "unread apps"))
Exemple #2
0
 def handle(self, *args, **options):
     call_command('flush', interactive=False)
     self.stdout.write(self.style.SUCCESS("Destroyed all existing data"))
     call_command('load_essential_data')
     self.stdout.write(
         self.style.SUCCESS(
             "Loaded organizations, counties, groups, & permissions "
             "from fixtures"))
     create_seed_users()
     self.stdout.write(self.style.SUCCESS("Created fake user profiles"))
     serialize_seed_users()
     self.stdout.write(self.style.SUCCESS("Saved to mock_profiles fixture"))
     fillable_pdf()
     self.stdout.write(self.style.SUCCESS("Load fake fillable pdf"))
     build_seed_submissions()
     self.stdout.write(
         self.style.SUCCESS(
             "Created fake submissions, bundles, and transfers "
             "and saved them to fixture files"))
     for app_id in Application.objects.filter(
             organization__slug='sf_pubdef').values_list('id', flat=True):
         fill_pdf_for_application(app_id)
     update_pdf_bundle_for_san_francisco()
     self.stdout.write(
         self.style.SUCCESS(
             "Pre-filled PDFs for San Francisco, including pdf bundle of "
             "unread apps"))
Exemple #3
0
 def test_creates_pdf_bundle_if_no_prebuilts(self, get_unread_apps):
     apps = factories.make_apps_for_sf()
     get_unread_apps.return_value = factories.apps_queryset(apps)
     prebuilt_count = models.PrebuiltPDFBundle.objects.count()
     self.assertEqual(0, prebuilt_count)
     PDFService.update_pdf_bundle_for_san_francisco()
     prebuilt_count = models.PrebuiltPDFBundle.objects.count()
     self.assertEqual(1, prebuilt_count)
Exemple #4
0
def add_application_pdfs(application_id):
    # imports of intake services should be called inside of tasks to prevent
    # circular imports
    # note: this is a really bad sign for this code,
    # no reason it should be this complex
    from intake.services import pdf_service
    pdf_service.fill_pdf_for_application(application_id)
    pdf_service.update_pdf_bundle_for_san_francisco()
 def test_creates_pdf_bundle_if_no_prebuilts(self, get_unread_apps):
     apps = factories.make_apps_for_sf()
     get_unread_apps.return_value = factories.apps_queryset(apps)
     prebuilt_count = models.PrebuiltPDFBundle.objects.count()
     self.assertEqual(0, prebuilt_count)
     PDFService.update_pdf_bundle_for_san_francisco()
     prebuilt_count = models.PrebuiltPDFBundle.objects.count()
     self.assertEqual(1, prebuilt_count)
Exemple #6
0
 def test_if_unread_set_has_a_match(self, create_bundle, get_unread_apps):
     apps = factories.make_apps_for_sf()
     prebuilt = factories.PrebuiltPDFBundleFactory()
     prebuilt.applications.add(*apps)
     get_unread_apps.return_value = factories.apps_queryset(apps)
     result = PDFService.update_pdf_bundle_for_san_francisco()
     self.assertEqual(result, prebuilt)
     create_bundle.assert_not_called()
 def test_if_unread_set_has_a_match(self, create_bundle, get_unread_apps):
     apps = factories.make_apps_for_sf()
     prebuilt = factories.PrebuiltPDFBundleFactory()
     prebuilt.applications.add(*apps)
     get_unread_apps.return_value = factories.apps_queryset(apps)
     result = PDFService.update_pdf_bundle_for_san_francisco()
     self.assertEqual(result, prebuilt)
     create_bundle.assert_not_called()
Exemple #8
0
 def test_creates_pdf_bundle_if_no_match(self, get_unread_apps):
     matching_apps = factories.make_apps_for_sf()
     not_matching_apps = factories.make_apps_for_sf()
     prebuilt = factories.PrebuiltPDFBundleFactory()
     prebuilt.applications.add(*matching_apps)
     all_apps = matching_apps + not_matching_apps
     get_unread_apps.return_value = factories.apps_queryset(all_apps)
     result = PDFService.update_pdf_bundle_for_san_francisco()
     self.assertNotEqual(result, prebuilt)
     self.assertEqual(set(all_apps), set(result.applications.all()))
 def test_creates_pdf_bundle_if_no_match(self, get_unread_apps):
     matching_apps = factories.make_apps_for_sf()
     not_matching_apps = factories.make_apps_for_sf()
     prebuilt = factories.PrebuiltPDFBundleFactory()
     prebuilt.applications.add(*matching_apps)
     all_apps = matching_apps + not_matching_apps
     get_unread_apps.return_value = factories.apps_queryset(all_apps)
     result = PDFService.update_pdf_bundle_for_san_francisco()
     self.assertNotEqual(result, prebuilt)
     self.assertEqual(set(all_apps), set(result.applications.all()))
Exemple #10
0
 def test_if_no_unread(self, get_unread_apps):
     get_unread_apps.return_value = factories.apps_queryset([])
     PDFService.update_pdf_bundle_for_san_francisco()
Exemple #11
0
 def test_if_sf_doesnt_exist(self):
     Organization.objects.filter(slug='sf_pubdef').delete()
     with self.assertRaises(ObjectDoesNotExist):
         PDFService.update_pdf_bundle_for_san_francisco()
 def test_if_no_unread(self, get_unread_apps):
     get_unread_apps.return_value = factories.apps_queryset([])
     PDFService.update_pdf_bundle_for_san_francisco()
 def test_if_sf_doesnt_exist(self):
     Organization.objects.filter(slug='sf_pubdef').delete()
     with self.assertRaises(ObjectDoesNotExist):
         PDFService.update_pdf_bundle_for_san_francisco()
Exemple #14
0
def add_application_pdfs(application_id):
    # imports of intake services should be called inside of tasks to prevent
    # circular imports
    import intake.services.pdf_service as PDFService
    PDFService.fill_pdf_for_application(application_id)
    PDFService.update_pdf_bundle_for_san_francisco()