How to use the intake.models.FillablePDF.objects.filter 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 / pdf_service.py View on Github external
def fill_pdf_for_application(application_id):
    """Returns a Filled PDF for the given application_id
    Raises an error if no fillable pdf exists or or if it has no file loaded.
    """
    app = models.Application.objects.get(id=application_id)
    fillable_pdf = models.FillablePDF.objects.filter(
        organization_id=app.organization_id).first()
    if not fillable_pdf or not fillable_pdf.pdf:
        raise exceptions.MissingFillablePDFError(
            "{org_name} lacks a pdf to fill for {app}".format(
                org_name=app.organization.name, app=app))
    return models.FilledPDF.create_with_pdf_bytes(
        pdf_bytes=fillable_pdf.fill(app.form_submission),
        original_pdf=fillable_pdf,
        submission=app.form_submission)
github codeforamerica / intake / intake / models / application_bundle.py View on Github external
def should_have_a_pdf(self):
        """Returns `True` if `self.organization` has any `FillablePDF`
        """
        return bool(
            intake.models.FillablePDF.objects.filter(
                organization__bundles=self).count())
github codeforamerica / intake / intake / services / submissions.py View on Github external
def fill_pdfs_for_submission(submission, organizations=None):
    """Checks for and creates any needed `FilledPDF` objects
    """
    if organizations:
        fillables = models.FillablePDF.objects.filter(
            organization_id__in=[org.id for org in organizations])
    else:
        fillables = models.FillablePDF.objects.filter(
            organization__submissions=submission)
    for fillable in fillables:
        fillable.fill_for_submission(submission)
github codeforamerica / intake / intake / services / pdf_service.py View on Github external
def rebuild_pdf_bundle_for_removed_application(application_id):
    app_is_for_org_with_fillable = models.FillablePDF.objects.filter(
        organization__applications__id=application_id).exists()
    if app_is_for_org_with_fillable:
        update_pdf_bundle_for_san_francisco()
github codeforamerica / intake / intake / models.py View on Github external
def fill_pdfs(self):
        """Checks for and creates any needed `FilledPDF` objects
        """
        fillables = FillablePDF.objects.filter(organization__submissions=self)
        for fillable in fillables:
            fillable.fill_for_submission(self)
github codeforamerica / intake / intake / services / submissions.py View on Github external
def fill_pdfs_for_submission(submission, organizations=None):
    """Checks for and creates any needed `FilledPDF` objects
    """
    if organizations:
        fillables = models.FillablePDF.objects.filter(
            organization_id__in=[org.id for org in organizations])
    else:
        fillables = models.FillablePDF.objects.filter(
            organization__submissions=submission)
    for fillable in fillables:
        fillable.fill_for_submission(submission)
github codeforamerica / intake / intake / models.py View on Github external
def should_have_a_pdf(self):
        """Returns `True` if `self.organization` has any `FillablePDF`
        """
        return bool(
            FillablePDF.objects.filter(organization__bundles=self).count())