From 507c3603a28b323e5385f73faa9e3d474343c30b Mon Sep 17 00:00:00 2001 From: katsufumi shibata Date: Mon, 20 Nov 2023 11:45:32 +0800 Subject: [PATCH 1/5] Add waive-the-fee checkbox to the Sticker Replacement modal --- mooringlicensing/components/approvals/api.py | 7 ++++-- .../common/sticker_replacement_modal.vue | 24 ++++++++++++++++--- .../internal/stickers/dashboard.vue | 4 +++- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/mooringlicensing/components/approvals/api.py b/mooringlicensing/components/approvals/api.py index b46e8076d..023a7f9ec 100755 --- a/mooringlicensing/components/approvals/api.py +++ b/mooringlicensing/components/approvals/api.py @@ -1197,13 +1197,16 @@ def record_lost(self, request, *args, **kwargs): def request_replacement(self, request, *args, **kwargs): # internal sticker = self.get_object() - data = request.data + # data = request.data + data = {} # Update Sticker action data['sticker'] = sticker.id data['action'] = 'Request replacement' data['user'] = request.user.id - serializer = StickerActionDetailSerializer(data=request.data) + data['waive_the_fee'] = request.data.get('waive_the_fee', False) + data['reason'] = request.data.get('details', {}).get('reason', '') + serializer = StickerActionDetailSerializer(data=data) serializer.is_valid(raise_exception=True) details = serializer.save() diff --git a/mooringlicensing/frontend/mooringlicensing/src/components/common/sticker_replacement_modal.vue b/mooringlicensing/frontend/mooringlicensing/src/components/common/sticker_replacement_modal.vue index ed8a0dcda..ed9f59baf 100755 --- a/mooringlicensing/frontend/mooringlicensing/src/components/common/sticker_replacement_modal.vue +++ b/mooringlicensing/frontend/mooringlicensing/src/components/common/sticker_replacement_modal.vue @@ -33,9 +33,18 @@
- - - +
+
+ + Waive the fee + +
+
+ + + +
+
@@ -70,6 +79,7 @@ export default { errorString: '', //successString: '', //success:false, + waive_the_fee: false, } }, computed: { @@ -108,6 +118,13 @@ export default { return '---' } }, + showWaiveFeeCheckbox: function(){ + let show = false + if (this.action === 'request_replacement'){ + show = true + } + return show + }, showDateOfLost: function(){ if (this.action === 'record_lost'){ return true @@ -137,6 +154,7 @@ export default { "details": vm.details, "sticker": vm.sticker, "action": vm.action, + "waive_the_fee": vm.waive_the_fee, }) }, cancel:function () { diff --git a/mooringlicensing/frontend/mooringlicensing/src/components/internal/stickers/dashboard.vue b/mooringlicensing/frontend/mooringlicensing/src/components/internal/stickers/dashboard.vue index f01d37b9d..d3558e529 100644 --- a/mooringlicensing/frontend/mooringlicensing/src/components/internal/stickers/dashboard.vue +++ b/mooringlicensing/frontend/mooringlicensing/src/components/internal/stickers/dashboard.vue @@ -48,9 +48,11 @@ export default { this.$refs.modal_details.isModalOpen = true }, sendData: function(params){ + console.log({params}) let vm = this let action = params.action - vm.$http.post(helpers.add_endpoint_json(api_endpoints.stickers, params.sticker.id + '/' + action), params.details).then( + // vm.$http.post(helpers.add_endpoint_json(api_endpoints.stickers, params.sticker.id + '/' + action), params.details).then( + vm.$http.post(helpers.add_endpoint_json(api_endpoints.stickers, params.sticker.id + '/' + action), params).then( res => { if (action == 'request_replacement'){ // Sticker replacement requires payments From b2c491339ad3432b1fd1a4bec16c466f9d5f92ca Mon Sep 17 00:00:00 2001 From: katsufumi shibata Date: Mon, 20 Nov 2023 12:55:34 +0800 Subject: [PATCH 2/5] Copy mooring related documents even when renewal. --- mooringlicensing/components/proposals/models.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/mooringlicensing/components/proposals/models.py b/mooringlicensing/components/proposals/models.py index 816c1d447..0c524fafa 100644 --- a/mooringlicensing/components/proposals/models.py +++ b/mooringlicensing/components/proposals/models.py @@ -2077,6 +2077,16 @@ def renew_approval(self,request): proposal.previous_application = self proposal.proposed_issuance_approval= None + from mooringlicensing.components.approvals.models import MooringLicence + if self.approval.child_obj.code == MooringLicence.code: + # proposal.allocated_mooring = self.approval.child_obj.mooring + + # Copy links to the documents so that the documents are shown on the amendment application form + self.copy_proof_of_identity_documents(proposal) + self.copy_mooring_report_documents(proposal) + self.copy_written_proof_documents(proposal) + self.copy_signed_licence_agreement_documents(proposal) + req=self.requirements.all().exclude(is_deleted=True) from copy import deepcopy if req: @@ -2091,12 +2101,6 @@ def renew_approval(self,request): r.id = None r.district_proposal=None r.save() - # Create a log entry for the proposal - # self.log_user_action(ProposalUserAction.ACTION_RENEW_PROPOSAL.format(self.id), request) - - # Create a log entry for the organisation - # applicant_field = getattr(self, self.applicant_field) - # applicant_field.log_user_action(ProposalUserAction.ACTION_RENEW_PROPOSAL.format(self.id), request) #Log entry for approval from mooringlicensing.components.approvals.models import ApprovalUserAction From 1ecc5649a314eae1803232b76285049d651e39b3 Mon Sep 17 00:00:00 2001 From: katsufumi shibata Date: Tue, 21 Nov 2023 09:38:25 +0800 Subject: [PATCH 3/5] Fix a bug where null vessel renewal ML application cannot be submitted --- .../components/proposals/serializers.py | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/mooringlicensing/components/proposals/serializers.py b/mooringlicensing/components/proposals/serializers.py index 62577d289..f96428abd 100644 --- a/mooringlicensing/components/proposals/serializers.py +++ b/mooringlicensing/components/proposals/serializers.py @@ -44,7 +44,7 @@ from mooringlicensing.components.users.serializers import UserAddressSerializer from rest_framework import serializers from mooringlicensing.helpers import is_internal -from mooringlicensing.settings import PROPOSAL_TYPE_NEW +from mooringlicensing.settings import PROPOSAL_TYPE_AMENDMENT, PROPOSAL_TYPE_NEW, PROPOSAL_TYPE_RENEWAL # logger = logging.getLogger('mooringlicensing') logger = logging.getLogger(__name__) @@ -760,32 +760,40 @@ class Meta: read_only_fields=('id',) def validate(self, data): + logger.info(f'Validating the proposal: [{self.instance}]...') custom_errors = {} - #ignore_insurance_check=self.context.get("ignore_insurance_check") proposal = Proposal.objects.get(id=self.context.get("proposal_id")) - ignore_insurance_check = data.get("keep_existing_vessel") and proposal.proposal_type.code != 'new' + ignore_insurance_check = data.get("keep_existing_vessel") and proposal.proposal_type.code != PROPOSAL_TYPE_NEW + if self.context.get("action") == 'submit': if ignore_insurance_check: pass else: - insurance_choice = data.get("insurance_choice") - vessel_length = proposal.vessel_details.vessel_applicable_length - if not insurance_choice: - custom_errors["Insurance Choice"] = "You must make an insurance selection" - elif vessel_length > Decimal("6.4") and insurance_choice not in ['ten_million', 'over_ten']: - custom_errors["Insurance Choice"] = "Insurance selected is insufficient for your nominated vessel" - #if not data.get("insurance_choice"): - # custom_errors["Insurance Choice"] = "You must make an insurance selection" - if not self.instance.insurance_certificate_documents.all(): - custom_errors["Insurance Certificate"] = "Please attach" + renewal_or_amendment_application_with_vessel = proposal.proposal_type.code in [PROPOSAL_TYPE_RENEWAL, PROPOSAL_TYPE_AMENDMENT,] and proposal.vessel_details + new_application = proposal.proposal_type.code == PROPOSAL_TYPE_NEW + if renewal_or_amendment_application_with_vessel or new_application: + logger.info(f'This proposal: [{self.instance}] is a new proposal or a renewal/amendment proposal with a vessel.') + insurance_choice = data.get("insurance_choice") + vessel_length = proposal.vessel_details.vessel_applicable_length + if not insurance_choice: + custom_errors["Insurance Choice"] = "You must make an insurance selection" + elif vessel_length > Decimal("6.4") and insurance_choice not in ['ten_million', 'over_ten']: + custom_errors["Insurance Choice"] = "Insurance selected is insufficient for your nominated vessel" + if not self.instance.insurance_certificate_documents.all(): + custom_errors["Insurance Certificate"] = "Please attach" + else: + logger.info(f'This proposal: [{self.instance}] is a renewal/amendment proposal without a vessel.') + pass # electoral roll validation if 'silent_elector' not in data.keys(): custom_errors["Electoral Roll"] = "You must complete this section" elif data.get("silent_elector"): if not self.instance.electoral_roll_documents.all(): custom_errors["Silent Elector"] = "You must provide evidence of this" + if custom_errors.keys(): raise serializers.ValidationError(custom_errors) + return data From 9b7853c4486b9e4418bd95e3401c134459f970e6 Mon Sep 17 00:00:00 2001 From: katsufumi shibata Date: Tue, 21 Nov 2023 14:35:49 +0800 Subject: [PATCH 4/5] Fix a few minor bugs. Fix a bug where Proposed Decision box does not show any mooring info when renewal --- .../components/proposals/models.py | 7 +++--- .../src/components/common/vessels.vue | 24 +++++++++---------- .../src/components/external/proposal.vue | 6 ++--- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/mooringlicensing/components/proposals/models.py b/mooringlicensing/components/proposals/models.py index 0c524fafa..b847edde6 100644 --- a/mooringlicensing/components/proposals/models.py +++ b/mooringlicensing/components/proposals/models.py @@ -509,8 +509,9 @@ def get_previous_vessel_ownerships(self): while True: if proposal.previous_application: - if proposal.previous_application.vessel_ownership.excludable(proposal): - vessel_ownerships.append(proposal.previous_application.vessel_ownership) + if proposal.previous_application.vessel_ownership: + if proposal.previous_application.vessel_ownership.excludable(proposal): + vessel_ownerships.append(proposal.previous_application.vessel_ownership) if get_out_of_loop: break @@ -2079,7 +2080,7 @@ def renew_approval(self,request): from mooringlicensing.components.approvals.models import MooringLicence if self.approval.child_obj.code == MooringLicence.code: - # proposal.allocated_mooring = self.approval.child_obj.mooring + proposal.allocated_mooring = self.approval.child_obj.mooring # Copy links to the documents so that the documents are shown on the amendment application form self.copy_proof_of_identity_documents(proposal) diff --git a/mooringlicensing/frontend/mooringlicensing/src/components/common/vessels.vue b/mooringlicensing/frontend/mooringlicensing/src/components/common/vessels.vue index 8433f8bfe..0fb6b14ca 100755 --- a/mooringlicensing/frontend/mooringlicensing/src/components/common/vessels.vue +++ b/mooringlicensing/frontend/mooringlicensing/src/components/common/vessels.vue @@ -418,9 +418,18 @@ export default { await this.$nextTick(() => { // do not perform check if no previous application vessel if (!this.previousApplicationVesselDetails || !this.previousApplicationVesselOwnership) { - return + if ( + Number(this.vesselDetails.vessel_draft) || + Number(this.vesselDetails.vessel_length) || + (this.vesselDetails.vessel_name && this.vesselDetails.vessel_name.trim()) || + this.vesselDetails.vessel_type || + Number(this.vesselDetails.vessel_weight) || + Number(this.vesselOwnership.percentage) || + this.vessel.new_vessel + ) { + vesselChanged = true; + } } else { - if ( Number(this.vesselDetails.vessel_draft) != Number(this.previousApplicationVesselDetails.vessel_draft) || Number(this.vesselDetails.vessel_length) != Number(this.previousApplicationVesselDetails.vessel_length) || @@ -438,7 +447,6 @@ export default { if (this.vesselOwnership.individual_owner) { // Company ownership --> Individual ownership vesselOwnershipChanged = true - console.log('%cCompanyOwnership --> IndividualOwnership', consoleColour) } else { if (this.vesselOwnership.company_ownership) { if (this.previousApplicationVesselOwnership.company_ownership.company && this.vesselOwnership.company_ownership.company) { @@ -446,7 +454,6 @@ export default { if (this.previousApplicationVesselOwnership.company_ownership.company.name.trim() !== this.vesselOwnership.company_ownership.company.name.trim()) { // Company name changed vesselOwnershipChanged = true - console.log('%cCompany name changed', consoleColour) } } } @@ -454,7 +461,6 @@ export default { if (Number(this.previousApplicationVesselOwnership.company_ownership.percentage) !== Number(this.vesselOwnership.company_ownership.percentage)) { // Company percentage changed vesselOwnershipChanged = true - console.log('%cCompanyOwnership percentage changed', consoleColour) } } } @@ -463,26 +469,19 @@ export default { if (!this.vesselOwnership.individual_owner) { // Individual ownership --> Company ownership vesselOwnershipChanged = true - console.log('%c IndividualOwnership --> CompanyOwnership', consoleColour) } } } - console.log('vesselChanged: ' + vesselChanged) - console.log('vesselOwnershipChanged: ' + vesselOwnershipChanged) }) - console.log("%cemit vesselChanged from the vessels.vue", consoleColour) await this.$emit("vesselChanged", vesselChanged) const missingVessel = this.vessel.rego_no ? false : true; await this.$emit("noVessel", missingVessel) - console.log('%cemit updateVesselOwnershipChanged from the vessels.vue', consoleColour) await this.$emit("updateVesselOwnershipChanged", vesselOwnershipChanged) //return vesselChanged; }, addToTemporaryDocumentCollectionList(temp_doc_id) { - console.log('in addToTemporaryDocumentCollectionList') - console.log({ temp_doc_id }) this.temporary_document_collection_id = temp_doc_id; }, /* @@ -490,7 +489,6 @@ export default { }, */ retrieveIndividualOwner: async function () { - console.log("in retrieveIndividualOwner()") if (this.individualOwner && this.vessel.id) { const url = api_endpoints.lookupIndividualOwnership(this.vessel.id); const res = await this.$http.post(url); diff --git a/mooringlicensing/frontend/mooringlicensing/src/components/external/proposal.vue b/mooringlicensing/frontend/mooringlicensing/src/components/external/proposal.vue index 1d6039cbb..1f53e6300 100755 --- a/mooringlicensing/frontend/mooringlicensing/src/components/external/proposal.vue +++ b/mooringlicensing/frontend/mooringlicensing/src/components/external/proposal.vue @@ -118,7 +118,7 @@ Date: Tue, 21 Nov 2023 16:01:19 +0800 Subject: [PATCH 5/5] Fix a minor bug for buttons --- .../src/components/common/vessels.vue | 43 ++++++++++++++----- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/mooringlicensing/frontend/mooringlicensing/src/components/common/vessels.vue b/mooringlicensing/frontend/mooringlicensing/src/components/common/vessels.vue index 0fb6b14ca..d655f7e24 100755 --- a/mooringlicensing/frontend/mooringlicensing/src/components/common/vessels.vue +++ b/mooringlicensing/frontend/mooringlicensing/src/components/common/vessels.vue @@ -22,16 +22,31 @@
- +
- +
@@ -52,7 +67,8 @@
-
+ +
- +
@@ -334,13 +357,13 @@ export default { return retVal; }, companyOwner: function () { - if (this.vessel && this.vessel.vessel_ownership && this.vessel.vessel_ownership.individual_owner === false) { + if (this.vessel && this.vessel.vessel_ownership && this.vessel.vessel_ownership.individual_owner == false) { return true; } return false }, individualOwner: function () { - if (this.vessel && this.vessel.vessel_ownership && this.vessel.vessel_ownership.individual_owner) { + if (this.vessel && this.vessel.vessel_ownership && this.vessel.vessel_ownership.individual_owner == true) { return true; } return false