def on_submission(self, request, **kwargs): copied_request = request.POST.copy() is_pv_graded = copied_request.get("is_pv_graded", "").lower() == "yes" is_software_technology = copied_request.get("item_category") in [ "group3_software", "group3_technology" ] is_firearm = copied_request.get("type") == "firearms" is_firearms_core = copied_request.get( "type") in FIREARM_AMMUNITION_COMPONENT_TYPES is_firearms_accessory = copied_request.get( "type") == "firearms_accessory" is_firearms_software_tech = copied_request.get("type") in [ "software_related_to_firearms", "technology_related_to_firearms", ] self.forms = add_good_form_group( request, is_pv_graded, is_software_technology, is_firearm, is_firearms_core, is_firearms_accessory, is_firearms_software_tech, base_form_back_link=reverse("goods:goods"), ) # we require the form index of the last form in the group, not the total number number_of_forms = len(self.forms.get_forms()) - 1 if int(self.request.POST.get("form_pk")) == number_of_forms: self.action = post_goods
def init(self, request, **kwargs): self.draft_pk = str(kwargs["pk"]) self.forms = add_good_form_group( request=request, draft_pk=self.draft_pk, application=self.application, ) self.show_section_upload_form = False
def on_submission(self, request, **kwargs): copied_request = request.POST.copy() is_pv_graded = copied_request.get("is_pv_graded", "") == "yes" is_software_technology = copied_request.get("item_category") in [ "group3_software", "group3_technology" ] is_firearm = copied_request.get("type") == "firearms" is_firearms_core = copied_request.get( "type") in FIREARM_AMMUNITION_COMPONENT_TYPES is_firearms_accessory = copied_request.get( "type") == "firearms_accessory" is_firearms_software_tech = copied_request.get("type") in [ "software_related_to_firearms", "technology_related_to_firearms", ] firearm_act_status = copied_request.get( "is_covered_by_firearm_act_section_one_two_or_five", "") selected_section = copied_request.get("firearms_act_section", "") self.covered_by_firearms_act = firearm_act_status == "Yes" self.certificate_not_required = firearm_act_status == "No" or firearm_act_status == "Unsure" self.show_section_upload_form = self.covered_by_firearms_act and ( selected_section == "firearms_act_section1" or selected_section == "firearms_act_section2") self.forms = add_good_form_group( request, is_pv_graded, is_software_technology, is_firearm, is_firearms_core, is_firearms_accessory, is_firearms_software_tech, draft_pk=self.draft_pk, base_form_back_link=reverse("applications:goods", kwargs={"pk": self.kwargs["pk"]}), ) # we require the form index of the last form in the group, not the total number number_of_forms = len(self.forms.get_forms()) - 1 if int(self.request.POST.get("form_pk")) == number_of_forms: if self.show_section_upload_form: firearms_data_id = f"post_{request.session['lite_api_user_id']}_{self.draft_pk}" session_data = copied_request.dict() if "control_list_entries[]" in copied_request: session_data[ "control_list_entries"] = copied_request.getlist( "control_list_entries[]") del session_data["control_list_entries[]"] request.session[firearms_data_id] = session_data elif self.certificate_not_required: self.action = post_goods else: self.action = post_goods
def on_submission(self, request, **kwargs): copied_request = request.POST.copy() is_pv_graded = copied_request.get("is_pv_graded", "").lower() == "yes" is_software_technology = copied_request.get("item_category") in ["group3_software", "group3_technology"] ( is_firearm, is_firearm_ammunition_or_component, is_firearms_accessory, is_firearms_software_or_tech, ) = get_firearms_subcategory(copied_request.get("type")) self.forms = add_good_form_group( request, is_pv_graded=is_pv_graded, is_software_technology=is_software_technology, is_firearm=is_firearm, is_firearm_ammunition_or_component=is_firearm_ammunition_or_component, is_firearms_accessory=is_firearms_accessory, is_firearms_software_or_tech=is_firearms_software_or_tech, base_form_back_link=reverse("goods:goods"), )
def init(self, request, **kwargs): self.draft_pk = str(kwargs["pk"]) self.forms = add_good_form_group(request, draft_pk=self.draft_pk) self.action = validate_good self.show_section_upload_form = False
def init(self, request, **kwargs): self.forms = add_good_form_group(request) self.action = validate_good
def init(self, request, **kwargs): self.forms = add_good_form_group(request)
def on_submission(self, request, **kwargs): copied_request = request.POST.copy() is_pv_graded = copied_request.get("is_pv_graded", "") == "yes" is_software_technology = copied_request.get("item_category") in [ "group3_software", "group3_technology" ] ( is_firearm, is_firearm_ammunition_or_component, is_firearms_accessory, is_firearms_software_or_tech, ) = get_firearms_subcategory(copied_request.get("type")) is_rfd = copied_request.get("is_registered_firearm_dealer" ) == "True" or has_valid_rfd_certificate( self.application) firearm_act_status = copied_request.get( "is_covered_by_firearm_act_section_one_two_or_five", "") selected_section = copied_request.get("firearms_act_section", "") self.covered_by_firearms_act = firearm_act_status == "Yes" self.certificate_not_required = firearm_act_status == "No" or firearm_act_status == "Unsure" if is_rfd and self.covered_by_firearms_act: selected_section = "firearms_act_section5" show_serial_numbers_form = True if copied_request.get("has_identification_markings") == "False": show_serial_numbers_form = False if firearm_act_status == "Yes": self.show_section_upload_form = is_firearm_certificate_needed( application=self.application, selected_section=selected_section) self.forms = add_good_form_group( request=request, is_pv_graded=is_pv_graded, is_software_technology=is_software_technology, is_firearm=is_firearm, is_firearm_ammunition_or_component= is_firearm_ammunition_or_component, is_firearms_accessory=is_firearms_accessory, is_firearms_software_or_tech=is_firearms_software_or_tech, draft_pk=self.draft_pk, base_form_back_link=reverse("applications:goods", kwargs={"pk": self.kwargs["pk"]}), application=self.application, show_serial_numbers_form=show_serial_numbers_form, is_rfd=is_rfd, ) if self.form_pk == self.number_of_forms: if self.show_section_upload_form: firearms_data_id = f"post_{request.session['lite_api_user_id']}_{self.draft_pk}" session_data = copied_request.dict() if "control_list_entries[]" in copied_request: session_data[ "control_list_entries"] = copied_request.getlist( "control_list_entries[]") del session_data["control_list_entries[]"] if "firearms_act_section" not in session_data: session_data["firearms_act_section"] = selected_section request.session[firearms_data_id] = session_data