Esempio n. 1
0
def count_unreads_and_send_notifications_to_orgs():
    orgs = get_orgs_that_might_need_a_bundle_email_today()
    for org in orgs:
        if org.slug == 'cfa':
            notifications.slack_simple.send("""
There are {all_count} unhandled county-not-listed (CNL)
applications outstanding: {review_link}""".format(
                all_count=AppsService.get_all_unhandled_cnl_apps().count(),
                review_link=external_reverse('intake-app_cnl_index')))
        else:
            emails = org.get_referral_emails()
            unread_count = AppsService.get_unread_apps_per_org_count(org)
            update_count = AppsService.get_needs_update_apps_per_org_count(org)
            all_count = AppsService.get_all_apps_per_org_count(org)
            if unread_count > 0:
                notifications.front_email_daily_app_bundle.send(
                    to=emails,
                    org_name=org.name,
                    unread_count=unread_count,
                    update_count=update_count,
                    all_count=all_count,
                    unread_redirect_link=external_reverse(
                        'intake-unread_email_redirect'),
                    needs_update_redirect_link=external_reverse(
                        'intake-needs_update_email_redirect'),
                    all_redirect_link=external_reverse(
                        'intake-all_email_redirect'))
            notifications.slack_app_bundle_sent.send(
                org_name=org.name,
                emails=emails,
                unread_count=unread_count,
                update_count=update_count,
                all_count=all_count,
            )
Esempio n. 2
0
def count_unreads_and_send_notifications_to_orgs():
    orgs = get_orgs_that_might_need_a_bundle_email_today()
    errors = []
    for org in orgs:
        if org.slug != 'cfa':
            try:
                emails = org.get_referral_emails()
            except Exception as e:
                errors.append(e)
                continue
            unread_count = AppsService.get_unread_apps_per_org_count(org)
            update_count = AppsService.get_needs_update_apps_per_org_count(org)
            all_count = AppsService.get_all_apps_per_org_count(org)
            if unread_count > 0:
                notifications.front_email_daily_app_bundle.send(
                    to=emails,
                    org_name=org.name,
                    unread_count=unread_count,
                    update_count=update_count,
                    all_count=all_count,
                    unread_redirect_link=external_reverse(
                        'intake-unread_email_redirect'),
                    needs_update_redirect_link=external_reverse(
                        'intake-needs_update_email_redirect'),
                    all_redirect_link=external_reverse(
                        'intake-all_email_redirect'))
    if errors:
        raise UnreadNotificationError(errors)
Esempio n. 3
0
 def test_counts_and_notification_args_for_unreads(self, send_email):
     email, org = self.email_and_org()
     make_apps_for(org.slug, count=3, answers={})
     BundlesService.count_unreads_and_send_notifications_to_orgs()
     send_email.assert_called_once_with(
         to=[email],
         org_name=org.name,
         unread_count=3,
         update_count=3,
         all_count=3,
         unread_redirect_link=external_reverse(
             'intake-unread_email_redirect'),
         needs_update_redirect_link=external_reverse(
             'intake-needs_update_email_redirect'),
         all_redirect_link=external_reverse('intake-all_email_redirect'))
Esempio n. 4
0
 def test_counts_and_notification_args_for_unreads(self, send_email):
     email, org = self.email_and_org()
     make_apps_for(org.slug, count=3, answers={})
     BundlesService.count_unreads_and_send_notifications_to_orgs()
     send_email.assert_called_once_with(
             to=[email],
             org_name=org.name,
             unread_count=3,
             update_count=3,
             all_count=3,
             unread_redirect_link=external_reverse(
                 'intake-unread_email_redirect'),
             needs_update_redirect_link=external_reverse(
                 'intake-needs_update_email_redirect'),
             all_redirect_link=external_reverse(
                 'intake-all_email_redirect'))
Esempio n. 5
0
def count_unreads_and_send_notifications_to_orgs():
    orgs = get_orgs_that_might_need_a_bundle_email_today()
    for org in orgs:
        if org.slug == 'cfa':
            pass
        else:
            emails = org.get_referral_emails()
            unread_count = AppsService.get_unread_apps_per_org_count(org)
            update_count = AppsService.get_needs_update_apps_per_org_count(org)
            all_count = AppsService.get_all_apps_per_org_count(org)
            if unread_count > 0:
                notifications.front_email_daily_app_bundle.send(
                    to=emails,
                    org_name=org.name,
                    unread_count=unread_count,
                    update_count=update_count,
                    all_count=all_count,
                    unread_redirect_link=external_reverse(
                        'intake-unread_email_redirect'),
                    needs_update_redirect_link=external_reverse(
                        'intake-needs_update_email_redirect'),
                    all_redirect_link=external_reverse(
                        'intake-all_email_redirect'))
Esempio n. 6
0
def create_bundles_and_send_notifications_to_orgs():
    orgs = get_orgs_that_might_need_a_bundle_email_today()
    for org in orgs:
        emails = org.get_referral_emails()
        subs = list(SubmissionsService.get_unopened_submissions_for_org(org))
        if subs:
            bundle = create_bundle_from_submissions(subs, organization=org)
            bundle_url = bundle.get_external_url()
            notifications.front_email_daily_app_bundle.send(
                to=emails,
                count=len(subs),
                bundle_url=bundle_url,
                app_index_url=external_reverse('intake-app_index'))
            notifications.slack_app_bundle_sent.send(
                submissions=subs,
                emails=emails,
                bundle_url=bundle_url,
            )
Esempio n. 7
0
 def test_render_front_email_daily_app_bundle(self):
     expected_subject = \
         "current time: Online applications to Clear My Record"
     # TODO: just check that the templates are handed the proper context
     expected_body = ("As of current time, you have one unopened "
                      "application to Clear My Record.\n\n"
                      "You can review and print them at this link:\n    "
                      "something.com/applications/bundle/1/")
     request = Mock()
     current_time = Mock(return_value='current time')
     content = notifications.front_email_daily_app_bundle.render(
         count=1,
         request=request,
         current_local_time=current_time,
         bundle_url="something.com/applications/bundle/1/")
     app_index_url = external_reverse('intake-app_index')
     self.assertIn(expected_body, content.body)
     self.assertIn(app_index_url, content.body)
     self.assertEqual(expected_subject, content.subject)
Esempio n. 8
0
 def test_render_front_email_daily_app_bundle(self):
     expected_subject = \
         "current time: Online applications to Clear My Record"
     # TODO: just check that the templates are handed the proper context
     expected_body = ("As of current time, you have one unopened "
                      "application to Clear My Record.\n\n"
                      "You can review and print them at this link:\n    "
                      "something.com/applications/bundle/1/")
     request = Mock()
     current_time = Mock(return_value='current time')
     content = notifications.front_email_daily_app_bundle.render(
         count=1,
         request=request,
         current_local_time=current_time,
         bundle_url="something.com/applications/bundle/1/"
     )
     app_index_url = external_reverse('intake-app_index')
     self.assertIn(expected_body, content.body)
     self.assertIn(app_index_url, content.body)
     self.assertEqual(expected_subject, content.subject)
Esempio n. 9
0
def follow_unreads_link_in_email(context):
    expected_unreads_link = external_reverse('intake-unread_email_redirect')
    context.test.assertIn(
        expected_unreads_link, context.test.unreads_email['body'])
    path = reverse('intake-unread_email_redirect')
    context.browser.get(urljoin(context.test.live_server_url, path))
Esempio n. 10
0
def follow_new_cnl_app_slack_link(context):
    expected_cnl_link = external_reverse('intake-app_cnl_index')
    context.test.assertIn(expected_cnl_link, context.test.new_cnl_app_slack)
    path = reverse('intake-app_cnl_index')
    context.browser.get(urljoin(context.test.live_server_url, path))