コード例 #1
0
def _convert_document(party, document_type, application_id, editable):
    document = party.get("document")

    if not document:
        return default_na(None)

    if document["safe"] is None:
        return "Processing"

    if not document["safe"]:
        return convert_to_link(
            f"/applications/{application_id}/{document_type}/{party['id']}/document/attach/",
            Parties.Documents.VIRUS)

    if editable:
        return convert_to_link(
            f"/applications/{application_id}/{document_type}/{party['id']}/document/download",
            "Download",
            include_br=True,
        ) + convert_to_link(
            f"/applications/{application_id}/{document_type}/{party['id']}/document/delete",
            Parties.Documents.DELETE)
    else:
        return convert_to_link(
            f"/applications/{application_id}/{document_type}/{party['id']}/document/download",
            Parties.Documents.DOWNLOAD,
            include_br=True,
        )
コード例 #2
0
def convert_party(party, application, editable):
    if not party:
        return {}

    has_clearance = application["case_type"]["sub_type"]["key"] == F680

    data = {
        "Name":
        party["name"],
        "Type":
        party["sub_type_other"]
        if party["sub_type_other"] else party["sub_type"]["value"],
        "Clearance level":
        None,
        "Descriptors":
        party.get("descriptors"),
        "Address":
        get_address(party),
        "Website":
        convert_to_link(party["website"]),
    }

    if party["type"] == "third_party":
        data["Role"] = party.get("role_other") if party.get(
            "role_other") else party.get("role").get("value")

    if application["case_type"]["sub_type"]["key"] != OPEN:
        if party.get("document"):
            document_type = party[
                "type"] if party["type"] != "end_user" else "end-user"
            document = _convert_document(party, document_type,
                                         application["id"], editable)
        else:
            document = convert_to_link(
                reverse_lazy(
                    f"applications:{party['type']}_attach_document",
                    kwargs={
                        "pk": application["id"],
                        "obj_pk": party["id"]
                    },
                ),
                "Attach document",
            )

        data["Document"] = document

    if has_clearance:
        data["Clearance level"] = party["clearance_level"].get(
            "value") if party["clearance_level"] else None
    else:
        data.pop("Clearance level")
        # Only display descriptors on third parties for non F680 applications
        if party["type"] != "third_party" and not data.get("Descriptors"):
            data.pop("Descriptors")

    return data
コード例 #3
0
def _get_supporting_documentation(supporting_documentation, application_id):
    return [{
        "File name":
        convert_to_link(
            reverse_lazy("applications:download_additional_document",
                         kwargs={
                             "pk": application_id,
                             "obj_pk": document["id"]
                         }),
            document["name"],
        ),
        "Description":
        default_na(document["description"]),
    } for document in supporting_documentation]
コード例 #4
0
def _convert_standard_application(application,
                                  editable=False,
                                  is_summary=False):
    converted_app = {
        convert_to_link(
            reverse_lazy(f"applications:good_detail_summary",
                         kwargs={"pk": application["id"]}),
            applications.ApplicationSummaryPage.GOODS,
        ):
        _convert_goods(application["goods"]),
        applications.ApplicationSummaryPage.END_USE_DETAILS:
        _get_end_use_details(application),
        applications.ApplicationSummaryPage.ROUTE_OF_GOODS:
        _get_route_of_goods(application),
        **({
            applications.ApplicationSummaryPage.TEMPORARY_EXPORT_DETAILS:
            _get_temporary_export_details(application),
        } if _is_application_export_type_temporary(application) else {}),
        applications.ApplicationSummaryPage.GOODS_LOCATIONS:
        _convert_goods_locations(application["goods_locations"]),
        applications.ApplicationSummaryPage.END_USER:
        convert_party(application["end_user"], application, editable),
        **({
            applications.ApplicationSummaryPage.ULTIMATE_END_USERS: [
                convert_party(party, application, editable) for party in application["ultimate_end_users"]
            ],
        } if has_incorporated_goods(application) else {}),
        applications.ApplicationSummaryPage.CONSIGNEE:
        convert_party(application["consignee"], application, editable),
        applications.ApplicationSummaryPage.THIRD_PARTIES: [
            convert_party(party, application, editable)
            for party in application["third_parties"]
        ],
        applications.ApplicationSummaryPage.SUPPORTING_DOCUMENTATION:
        _get_supporting_documentation(application["additional_documents"],
                                      application["id"]),
    }

    return converted_app
コード例 #5
0
def _convert_attachable_document(address, attach_address, document, editable):
    if not document and editable:
        return convert_to_link(attach_address, Parties.Documents.ATTACH)

    return convert_to_link(address, "Download")