def dispatch(self, request, *args, **kwargs): self.application_id = str(kwargs["pk"]) self.application = get_application(request, self.application_id) self.case_id = self.application["case"] return super(ApplicationSummary, self).dispatch(request, *args, **kwargs)
def init(self, request, **kwargs): self.object_pk = kwargs["pk"] application = get_application(request, self.object_pk) self.form = goods_type_form(request, application.sub_type) self.action = post_goods_type self.success_url = reverse_lazy("applications:goods_types", kwargs={"pk": self.object_pk})
def init(self, request, **kwargs): self.object_pk = kwargs["pk"] self.application = get_application(request, self.object_pk) has_clearance = self.application["case_type"]["sub_type"][ "key"] == F680 clearance_options = get_pv_gradings( request, convert_to_options=True) if has_clearance else None if self.party_type == "end_user": self.forms = self.form( request, self.application, self.strings, self.back_url, clearance_options=clearance_options, is_end_user=True, ) else: self.forms = self.form( request, self.application, self.strings, self.back_url, clearance_options=clearance_options, ) self.data = {"type": self.party_type}
def init(self, request, **kwargs): self.object_pk = kwargs["pk"] application = get_application(self.request, self.object_pk) good, _ = get_good(request, kwargs["good_pk"]) self.form = good_on_application_form(request, good, application["case_type"]["sub_type"], self.object_pk) self.action = post_good_on_application self.success_url = reverse_lazy("applications:goods", kwargs={"pk": self.object_pk})
def init(self, request, **kwargs): self.object_pk = kwargs["pk"] self.data = get_application(request, self.object_pk) self.form = told_by_an_official_form(self.object_pk) self.action = put_application self.success_url = reverse_lazy("applications:task_list", kwargs={"pk": self.object_pk})
def get(self, request, **kwargs): application_id = str(kwargs["pk"]) application = get_application(request, application_id) is_permanent_app = is_application_export_type_permanent(application) if application["end_user"]: kwargs = { "pk": application_id, "obj_pk": application["end_user"]["id"] } context = { "application": application, "title": EndUserPage.TITLE, "edit_url": reverse_lazy("applications:edit_end_user", kwargs=kwargs), "remove_url": reverse_lazy("applications:remove_end_user", kwargs=kwargs), "answers": convert_party( party=application["end_user"], application=application, editable=application["status"]["value"] == "draft", ), "highlight": ["Document"] if (is_permanent_app and application.sub_type != OPEN and not application["end_user"]["document"]) else {}, } return render(request, "applications/end-user.html", context) else: return redirect( reverse_lazy("applications:add_end_user", kwargs={"pk": application_id}))
def init(self, request, **kwargs): self.object_pk = kwargs["pk"] application = get_application(request, self.object_pk) self.form = surrender_application_confirmation(application, self.object_pk) self.action = validate_surrender_application_and_update_case_status self.success_url = reverse_lazy("applications:application", kwargs={"pk": self.object_pk})
def dispatch(self, request, *args, **kwargs): self.application_id = str(kwargs["pk"]) self.application = get_application(request, self.application_id) self.case_id = self.application["case"] self.view_type = kwargs.get("type") return super(ApplicationDetail, self).dispatch(request, *args, **kwargs)
def get(self, request, **kwargs): application_id = kwargs["pk"] application = get_application(request, application_id) context = { "application": application, } return render(request, "applications/submit.html", context)
def init(self, request, **kwargs): self.object_pk = kwargs["pk"] application = get_application(request, self.object_pk) self.form = withdraw_application_confirmation(application, self.object_pk) self.action = validate_withdraw_application self.success_url = reverse_lazy("applications:application", kwargs={"pk": self.object_pk})
def init(self, request, **kwargs): self.object_pk = kwargs["pk"] application = get_application(request, self.object_pk) self.data, _ = get_external_locations_on_draft(request, self.object_pk) self.form = external_locations_form(request, application.type_reference) self.action = post_external_locations_on_draft self.success_url = reverse_lazy("applications:location", kwargs={"pk": self.object_pk})
def init(self, request, **kwargs): self.object_pk = kwargs["pk"] pv_grading_options = get_pv_gradings(request, convert_to_options=True) self.form = clearance_level_form(application_id=kwargs["pk"], options=pv_grading_options) self.action = put_application self.success_url = reverse_lazy("applications:task_list", kwargs={"pk": self.object_pk}) application = get_application(request, self.object_pk) self.data = {"clearance_level": application["clearance_level"]}
def init(self, request, **kwargs): self.object_pk = kwargs["pk"] application = get_application(request, self.object_pk) location_type = request.POST.get("location_type", None) self.forms = new_external_location_form(request, application.type_reference, location_type) self.action = post_external_locations self.success_url = reverse_lazy("applications:location", kwargs={"pk": self.object_pk})
def get(self, request, **kwargs): application_id = str(kwargs["pk"]) application = get_application(request, application_id) context = { "application_id": application_id, "goods": application["goods"], "application_status_draft": application["status"]["key"] in ["draft", APPLICANT_EDITING], } return render(request, "applications/goods/goods-detail-summary.html", context)
def on_submission(self, request, **kwargs): application = get_application(request, self.object_pk) has_clearance = application["case_type"]["sub_type"]["key"] == F680 if not has_clearance: self.forms = self.form(request, application, self.strings, self.back_url) if int(self.request.POST.get("form_pk")) == len(self.forms.forms) - 1: self.action = self.post_action else: self.action = self.validate_action
def get(self, request, **kwargs): application_id = kwargs["pk"] application = get_application(request, application_id) context = { "application": application, "answers": { **convert_application_to_check_your_answers(application) } } return render(request, "applications/check-your-answers.html", context)
def get(self, request, **kwargs): application_id = str(kwargs["pk"]) application = get_application(request, application_id) ultimate_end_users = get_ultimate_end_users(request, application_id) context = { "application": application, "ultimate_end_users": ultimate_end_users, } return render(request, "applications/parties/ultimate-end-users.html", context)
def application(request, pk): data, status_code = get_application(request, str(pk)) if status_code is not 200: raise HttpResponse(status=status_code) context = { 'data': data, 'title': data.get("application").get("name"), } return render(request, 'applications/application.html', context)
def get(self, request, **kwargs): application_id = str(kwargs["pk"]) data = get_application(request, application_id) if data.get("status") and data.get("status").get( "key") == APPLICANT_EDITING: return redirect( reverse_lazy("applications:task_list", kwargs={"pk": application_id})) return form_page(request, edit_type_form(application_id))
def get(self, request, **kwargs): application_id = str(kwargs["pk"]) application = get_application(request, application_id) context = { "application": application, "third_parties": application["third_parties"], "has_clearance": application["case_type"]["sub_type"]["key"] == F680, } return render(request, "applications/parties/third-parties.html", context)
def get_form_data(self, request): application = get_application(request, self.object_pk) data = {} if application["is_shipped_waybill_or_lading"] is not None: data["is_shipped_waybill_or_lading"] = application[ "is_shipped_waybill_or_lading"] if application["non_waybill_or_lading_route_details"]: data["non_waybill_or_lading_route_details"] = application[ "non_waybill_or_lading_route_details"] return data
def init(self, request, **kwargs): self.object_pk = kwargs["pk"] application = get_application(request, self.object_pk) self.forms = temporary_export_details_form() self.action = put_temporary_export_details self.data = self._parse_temporary_export_details(application) self.success_url = reverse_lazy("applications:task_list", kwargs={"pk": self.object_pk}) self.summary_list_title = strings.SummaryList.TITLE self.summary_list_notice_title = "" self.summary_list_notice_text = "" self.summary_list_button = generic.SAVE_AND_RETURN self.validate_only_until_final_submission = False
def init(self, request, **kwargs): self.object_pk = kwargs["pk"] application = get_application(request, self.object_pk) if application.status == "submitted" and not application[ "goods_locations"]["type"] == "sites": raise Http404 self.data, _ = get_sites_on_draft(request, self.object_pk) self.form = sites_form(request, application.type_reference) self.action = post_sites_on_draft self.success_url = reverse_lazy("applications:location", kwargs={"pk": self.object_pk})
def get(self, request, **kwargs): """ List all goods relating to the application """ draft_id = str(kwargs["pk"]) application = get_application(request, draft_id) goods = get_application_goods(request, draft_id) exhibition = application["case_type"]["sub_type"]["key"] == EXHIBITION context = {"goods": goods, "application": application, "exhibition": exhibition} if not exhibition: context["goods_value"] = get_total_goods_value(goods) return render(request, "applications/goods/index.html", context)
def init(self, request, **kwargs): self.object_pk = str(kwargs["pk"]) application = get_application(request, self.object_pk) self.form = f680_details_form(request, self.object_pk) self.action = put_application_with_clearance_types self.data = { "types": [ f680_clearance_type["name"]["key"] for f680_clearance_type in application["types"] ] } self.success_url = reverse_lazy("applications:task_list", kwargs={"pk": self.object_pk})
def dispatch(self, request, *args, **kwargs): self.application_id = str(kwargs["pk"]) self.application = get_application(request, self.application_id) self.goods = self.application["goods_types"] self.countries = get_application_countries(request, self.application_id) # Prevent minor edits from accessing this page if get_application_edit_type( self.application) == ApplicationEditTypes.MINOR_EDIT: raise Http404 return super(GoodsTypeCountries, self).dispatch(request, *args, **kwargs)
def get(self, request, **kwargs): """ Display application submit success page This page is accessed one of two ways: 1. Successful submission of an application 2. From a bookmark or link - this is intentional as some users will want to save the page as evidence """ application_id = kwargs["pk"] application = get_application(request, application_id) if application.status in ["draft", "applicant_editing"]: raise Http404 return application_success_page(request, application["reference_code"])
def post(self, request, **kwargs): draft_id = str(kwargs["pk"]) application = get_application(request, draft_id) is_permanent_application = is_application_export_type_permanent( application) form = get_upload_page( request.path, draft_id, is_permanent_application=is_permanent_application) try: request.upload_handlers.insert(0, S3FileUploadHandler(request)) files = request.FILES except Exception: # noqa return error_page( request, strings.applications.AttachDocumentPage.UPLOAD_FAILURE_ERROR) # Only validate documents if there are any present or are mandatory in the following cases: # standard permanent application end user section, additional documents section if (files or ("/end-user" in request.path and is_application_export_type_permanent(application)) or "additional-document" in request.path): logging.info(self.request) data, error = add_document_data(request) if error: return form_page(request, form, extra_data={"draft_id": draft_id}, errors={"documents": [error]}) action = document_switch(request.path)["attach"] if len(signature(action).parameters) == 3: _, status_code = action(request, draft_id, data) if status_code == HTTPStatus.CREATED: return get_homepage(request, draft_id) else: _, status_code = action(request, draft_id, kwargs["obj_pk"], data) if status_code == HTTPStatus.CREATED: return get_homepage(request, draft_id, kwargs["obj_pk"]) return error_page( request, strings.applications.AttachDocumentPage.UPLOAD_FAILURE_ERROR) return get_homepage(request, draft_id)
def init(self, request, **kwargs): self.object_pk = kwargs["pk"] application = get_application(request, self.object_pk) self.form = confirm_form( title=strings.applications.DeleteApplicationPage.TITLE, confirmation_name="choice", summary=draft_summary(application), back_link_text=strings.applications.DeleteApplicationPage. BACK_TEXT, yes_label=strings.applications.DeleteApplicationPage.YES_LABEL, no_label=strings.applications.DeleteApplicationPage.NO_LABEL, submit_button_text=strings.applications.DeleteApplicationPage. SUBMIT_BUTTON, back_url=request.GET.get("return_to"), side_by_side=True, ) self.action = validate_delete_draft
def init(self, request, **kwargs): self.object_pk = kwargs["pk"] application = get_application(request, self.object_pk) self.form = which_location_form(self.object_pk, application.sub_type) self.action = validate_and_update_goods_location_choice self.data = { "choice": Locations.DEPARTED if application.get("have_goods_departed") else "" } if application.status == "submitted": if application["goods_locations"]: return reverse_lazy("applications:location", kwargs={"pk": self.object_pk}) elif application["sites"]: return reverse_lazy("applications:existing_sites", kwargs={"pk": self.object_pk})