How to use the intake.services.applications_service function in intake

To help you get started, we’ve selected a few intake examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github codeforamerica / intake / intake / services / bundles.py View on Github external
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:
github codeforamerica / intake / intake / services / bundles.py View on Github external
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)
github codeforamerica / intake / intake / views / admin_views.py View on Github external
tabs = [
        {
            'url': reverse('intake-app_unread_index'),
            'label': 'Unread',
            'count': AppsService.get_unread_apps_per_org_count(organization),
            'is_active': False},
        {
            'url': reverse('intake-app_needs_update_index'),
            'label': 'Needs Status Update',
            'count': AppsService.get_needs_update_apps_per_org_count(
                organization),
            'is_active': False},
        {
            'url': reverse('intake-app_all_index'),
            'label': 'All',
            'count': AppsService.get_all_apps_per_org_count(organization),
            'is_active': False}
    ]

    active_tab_count = activate_tab_by_label(tabs, active_tab)

    return tabs, active_tab_count
github codeforamerica / intake / intake / views / prebuilt_pdf_bundle_views.py View on Github external
def get_context_data(self):
        context = super().get_context_data()
        context['organization'] = self.organization
        context['app_count'] = AppsService.get_valid_application_ids_from_set(
            self.app_ids).count()
        # check for fillable pdfs
        needs_prebuilt = self.organization.pdfs.count() > 0
        if needs_prebuilt:
            context['pdf_url'] = query_params.get_url_for_ids(
                'intake-pdf_bundle_file_view', self.app_ids)
        else:
            context['pdf_url'] = query_params.get_url_for_ids(
                'intake-pdf_printout_for_apps', self.app_ids)
        AppsService.handle_apps_opened(self, self.app_ids)
        MessagesService.flash_success(
            self.request, get_multiple_apps_read_flash(context['app_count']))
        return context
github codeforamerica / intake / intake / services / pdf_service.py View on Github external
def update_pdf_bundle_for_san_francisco():
    """Gets or creates a PrebuiltPDFBundle for San Francisco
        links it to all the unread applications
        and rebuilds the PDF
    """
    sf_pubdef = Organization.objects.get(slug='sf_pubdef')
    unread_apps = AppsService.get_unread_applications_for_org(sf_pubdef)
    if unread_apps.count() > 0:
        app_ids = [app.id for app in unread_apps]
        pdf_bundle = get_prebuilt_pdf_bundle_for_app_id_set(app_ids)
        if not pdf_bundle:
            pdf_bundle = create_new_pdf_bundle_for_apps(sf_pubdef, unread_apps)
        return pdf_bundle
github codeforamerica / intake / intake / views / admin_views.py View on Github external
models.FormSubmission, pk=int(submission_id))
        if not request.user.profile.should_have_access_to(submission):
            return self.not_allowed()
        pdf = submission.filled_pdfs.first()
        if not pdf:
            no_pdf_str = \
                "No prefilled pdf was made for submission: %s" % submission.pk
            notifications.slack_simple.send(no_pdf_str)
            fillables = models.FillablePDF.objects
            if not request.user.is_staff:
                org = request.user.profile.organization
                fillables = fillables.filter(
                    organization=org)
            fillable_pdf = fillables.first()
            pdf = fillable_pdf.fill_for_submission(submission)
        apps = AppsService.filter_to_org_if_not_staff(
            submission.applications.all(), request.user)
        AppsService.handle_apps_opened(self, apps)
        response = HttpResponse(pdf.pdf, content_type='application/pdf')
        return response
github codeforamerica / intake / intake / views / prebuilt_pdf_bundle_views.py View on Github external
def get_context_data(self):
        context = super().get_context_data()
        context['organization'] = self.organization
        context['app_count'] = AppsService.get_valid_application_ids_from_set(
            self.app_ids).count()
        # check for fillable pdfs
        needs_prebuilt = self.organization.pdfs.count() > 0
        if needs_prebuilt:
            context['pdf_url'] = query_params.get_url_for_ids(
                'intake-pdf_bundle_file_view', self.app_ids)
        else:
            context['pdf_url'] = query_params.get_url_for_ids(
                'intake-pdf_printout_for_apps', self.app_ids)
        AppsService.handle_apps_opened(self, self.app_ids)
        MessagesService.flash_success(
            self.request, get_multiple_apps_read_flash(context['app_count']))
        return context
github codeforamerica / intake / intake / views / admin_views.py View on Github external
def get_context_data(self, *args, **kwargs):
        context = super().get_context_data(*args, **kwargs)
        context['results'] = \
            AppsService.get_applications_needing_updates_for_org_user(
                self.request.user, self.request.GET.get('page'))
        context['app_index_tabs'], count = get_tabs_for_org_user(
            self.request.user.profile.organization,
            'Needs Status Update')
        if count == 0:
            context['no_results'] = "You have updated all applications!"
        else:
            context['no_results'] = None
        context['print_all_link'] = None
        context['csv_download_link'] = None
        context['app_index_scope_title'] = \
            "{} Applications Need Status Updates".format(count)
        return context
github codeforamerica / intake / intake / views / app_detail_views.py View on Github external
def get_context_data(self, *args, **kwargs):
        context = super().get_context_data(*args, **kwargs)
        apps = context['applications']
        status_updates = \
            AppsService.get_serialized_application_history_events(
                apps[0], self.request.user)
        context.update(status_updates=status_updates)
        return context
github codeforamerica / intake / intake / views / admin_views.py View on Github external
def get_tabs_for_org_user(organization, active_tab):
    tabs = [
        {
            'url': reverse('intake-app_unread_index'),
            'label': 'Unread',
            'count': AppsService.get_unread_apps_per_org_count(organization),
            'is_active': False},
        {
            'url': reverse('intake-app_needs_update_index'),
            'label': 'Needs Status Update',
            'count': AppsService.get_needs_update_apps_per_org_count(
                organization),
            'is_active': False},
        {
            'url': reverse('intake-app_all_index'),
            'label': 'All',
            'count': AppsService.get_all_apps_per_org_count(organization),
            'is_active': False}
    ]

    active_tab_count = activate_tab_by_label(tabs, active_tab)

    return tabs, active_tab_count