Beispiel #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,
        )
Beispiel #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"] == "end_user":
        data["Signatory name"] = party.get("signatory_name_euu")

    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(
                    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
Beispiel #3
0
def _get_supporting_documentation(supporting_documentation, application_id):
    return [{
        "File name":
        convert_to_link(
            reverse("applications:download_additional_document",
                    kwargs={
                        "pk": application_id,
                        "obj_pk": document["id"]
                    }),
            document["name"],
        ),
        "Description":
        default_na(document["description"]),
    } for document in supporting_documentation]
Beispiel #4
0
def _convert_standard_application(application,
                                  editable=False,
                                  is_summary=False):
    strings = applications.ApplicationSummaryPage
    pk = application["id"]
    url = reverse(f"applications:good_detail_summary", kwargs={"pk": pk})
    converted = {
        convert_to_link(url, strings.GOODS):
        convert_goods_on_application(application["goods"]),
        strings.END_USE_DETAILS:
        _get_end_use_details(application),
        strings.ROUTE_OF_GOODS:
        _get_route_of_goods(application),
        strings.GOODS_LOCATIONS:
        _convert_goods_locations(application["goods_locations"]),
        strings.END_USER:
        convert_party(application["end_user"], application, editable),
        strings.CONSIGNEE:
        convert_party(application["consignee"], application, editable),
        strings.THIRD_PARTIES: [
            convert_party(item, application, editable)
            for item in application["third_parties"]
        ],
        strings.SUPPORTING_DOCUMENTATION:
        _get_supporting_documentation(application["additional_documents"], pk),
    }
    if _is_application_export_type_temporary(application):
        converted[
            strings.TEMPORARY_EXPORT_DETAILS] = _get_temporary_export_details(
                application)
    if has_incorporated_goods(application):
        ultimate_end_users = [
            convert_party(item, application, editable)
            for item in application["ultimate_end_users"]
        ]
        converted[strings.ULTIMATE_END_USERS] = ultimate_end_users
    return converted
Beispiel #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")