Skip to content

Commit

Permalink
Merge pull request #539 from awf-dbca/misc-fixes-8
Browse files Browse the repository at this point in the history
Misc fixes
  • Loading branch information
preranaandure authored Feb 12, 2025
2 parents 751df10 + c07ba02 commit 65c9a14
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 37 deletions.
2 changes: 2 additions & 0 deletions mooringlicensing/components/payments_ml/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ def generate_line_item(application_type, fee_amount_adjusted, fee_constructor, i
vessel_rego_no = v_rego_no
if not vessel_rego_no and instance.vessel_details and instance.vessel_details.vessel:
vessel_rego_no = instance.vessel_details.vessel.rego_no
if not vessel_rego_no:
vessel_rego_no = instance.rego_no
if not vessel_rego_no:
# We want to show something rather than empty string
vessel_rego_no = 'no vessel'
Expand Down
7 changes: 7 additions & 0 deletions mooringlicensing/components/proposals/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1608,6 +1608,13 @@ def proposed_approval(self, request, details):

if not mooring_id and not check_mooring_ids and self.application_type.code == "aua":
raise serializers.ValidationError("No mooring provided")

if self.application_type.code == "mla":
mooring = self.allocated_mooring
if (self.vessel_length > mooring.vessel_size_limit or
self.vessel_draft > mooring.vessel_draft_limit or
(self.vessel_weight > mooring.vessel_weight_limit and mooring.vessel_weight_limit > 0)):
raise serializers.ValidationError("Proposed vessel dimensions are not compatible with the mooring")

self.proposed_issuance_approval = {
'current_date': current_date.strftime('%d/%m/%Y'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
required=""
/>
</div>
<div v-else class="col-sm-2">
<div v-if="companyOwner" class="col-sm-2">
<input
:readonly="readonly"
type="number"
Expand All @@ -98,7 +98,6 @@
required=""
/>
</div>

</div>
<div class="row form-group">
<label for="" class="col-sm-3 control-label">Name as shown on DoT registration papers</label>
Expand Down Expand Up @@ -383,7 +382,6 @@ export default {
}
else if (this.vesselOwnership.proposal_id){
url = '/api/proposal/' + this.vesselOwnership.proposal_id + '/hull_identification_number_document/'
console.log(url)
}
return url
},
Expand All @@ -407,13 +405,11 @@ export default {
},
methods: {
emitVesselLength: function () {
console.log('in emitVesselLength')
this.$nextTick(() => {
this.$emit("updateVesselLength", this.vesselLength)
});
},
vesselChanged: async function () {
console.log('in vesselChanged')
let vesselChanged = false
let vesselOwnershipChanged = false
Expand Down Expand Up @@ -488,7 +484,6 @@ export default {
if (this.individualOwner && this.vessel.id) {
const url = api_endpoints.lookupIndividualOwnership(this.vessel.id);
const res = await this.$http.post(url);
console.log({ res })
if (res.body) {
let vesselOwnership = Object.assign({}, res.body);
vesselOwnership.individual_owner = true;
Expand Down Expand Up @@ -582,7 +577,6 @@ export default {
vm.readCompanyName();
},
readCompanyName: function () {
console.log('in readCompanyName()')
this.$nextTick(() => {
let vm = this;
if (vm.vessel.vessel_ownership && vm.vessel.vessel_ownership.company_ownership && vm.vessel.vessel_ownership.company_ownership.company) {
Expand All @@ -606,7 +600,6 @@ export default {
placeholder: "",
tags: allow_add_new_vessel,
createTag: function (tag) {
console.log({tag})
return {
id: tag.term,
text: tag.term,
Expand All @@ -627,31 +620,26 @@ export default {
},
processResults: function(data, params){ // This function is called after the results are returned.
// Mainly used for modifying the items before being displayed.
console.log({data})
return {
results: data.results, // This is the array of items to be displayed
}
}
},
templateSelection: function (data) {
console.log("in templateSelection()");
return vm.validateRegoNo(data.text);
},
}).
on("select2:select", function (e) {
console.log("in select2:select handler");
if (!e.params.data.selected) {
e.preventDefault();
e.stopPropagation();
return false;
}
let data = e.params.data;
console.log({ data })
vm.$nextTick(async () => {
let max_length = 0
if (!data.tag) {
var error_status = null;
console.log("fetch existing vessel");
// fetch draft/approved vessel
try {
await vm.lookupVessel(data.id);
Expand All @@ -678,13 +666,10 @@ export default {
await vm.parseVesselOwnershipList(res);
const res_for_length = await vm.$http.get(`${api_endpoints.proposal}${vm.proposal.id}/get_max_vessel_length_for_aa_component?vid=${data.id}`);
console.log('aa component')
console.log(res_for_length.body.max_length)
vm.max_vessel_length_for_aa_component = res_for_length.body.max_length
}
} else {
console.log("new vessel");
const validatedRego = vm.validateRegoNo(data.id);
vm.vessel = Object.assign({},
Expand All @@ -704,7 +689,6 @@ export default {
});
}).
on("select2:unselect", function (e) {
console.log("in select2:unselect handler");
var selected = $(e.currentTarget);
vm.vessel.rego_no = '';
vm.vessel = Object.assign({},
Expand All @@ -718,7 +702,6 @@ export default {
});
}).
on("select2:open", function (e) {
console.log("in select2:open handler");
const searchField = $(".select2-search__field")
// move focus to select2 field
searchField[0].focus();
Expand All @@ -735,7 +718,6 @@ export default {
vm.readRegoNo();
},
parseVesselOwnershipList: async function (res) {
console.log('in parseVesselOwnershipList()')
let vm = this;
let individualOwner = false;
let companyOwner = false;
Expand Down Expand Up @@ -769,24 +751,19 @@ export default {
});
},
readRegoNo: function () {
console.log('in readRegoNo()')
let vm = this;
console.log('%cvm.vessel.rego_no: ' + vm.vessel.rego_no, 'color: #993300')
if (vm.vessel.rego_no) {
var option = new Option(vm.vessel.rego_no, vm.vessel.rego_no, true, true);
$(vm.$refs.vessel_rego_nos).append(option).trigger('change');
console.log('%coption appended', 'color: #993300')
}
},
fetchVesselTypes: async function () {
console.log('in fetchVesselTypes()')
const response = await this.$http.get(api_endpoints.vessel_types_dict);
for (let vessel_type of response.body) {
this.vesselTypes.push(vessel_type)
}
},
lookupCompanyOwnership: async function (id) {
console.log('in lookupCompanyOwnership()')
const url = api_endpoints.lookupCompanyOwnership(id);
const payload = {
"vessel_id": this.vessel.id,
Expand All @@ -800,12 +777,11 @@ export default {
},
lookupVessel: async function (id) {
console.log('in looupVessel()')
const url = api_endpoints.lookupVessel(id);
await this.fetchReadonlyVesselCommon(url);
},
fetchDraftData: function () {
console.log('in fetchDraftData()')
console.log('fetchDraftData');
this.vessel.rego_no = this.proposal.rego_no;
this.vessel.id = this.proposal.vessel_id;
let vessel_details = {};
Expand All @@ -820,7 +796,6 @@ export default {
this.readOwnershipFromProposal();
},
readOwnershipFromProposal: function () {
console.log('in readOwnershipFromProposal()')
let vessel_ownership = {};
vessel_ownership.percentage = this.proposal.percentage;
vessel_ownership.individual_owner = this.proposal.individual_owner;
Expand All @@ -838,8 +813,6 @@ export default {
}
},
fetchReadonlyVesselCommon: async function (url) {
console.log('in fetchReadonlyVesselCommon()')
console.log({ url })
const res = await this.$http.get(url);
const vesselData = res.body;
// read in vessel ownership data from Proposal if in Draft status
Expand All @@ -865,17 +838,12 @@ export default {
mounted: function () {
let consoleColour = 'color: #000099'
this.$nextTick(async () => {
console.log('in mounted nextTick()')
await this.fetchVesselTypes();
if (this.proposal){
console.log('%cPerform fetchDraftData', consoleColour)
// fetches vessel data from proposal (saved as draft)
await this.fetchDraftData();
} else if (!this.proposal) {
console.log('%cPerform fetchReadonlyVesselCommon', consoleColour)
// route.params.vessel_id in this case is a vesselownership id
const url = api_endpoints.lookupVesselOwnership(this.$route.params.vessel_id);
this.fetchReadonlyVesselCommon(url);
Expand Down Expand Up @@ -918,14 +886,40 @@ export default {
if (!this.proposal.rego_no && res && res.body && !res.body.vessel_ownership.end_date) {
try {
Object.assign(this.vessel, res.body);
console.log('res.body has been assigned to the this.vessel.')
this.vessel.id = res.body.id;
this.vessel.rego_no = res.body.rego_no;
console.log(res.body)
this.vessel.vessel_ownership.percentage = res.body.vessel_ownership.percentage;
this.vessel.vessel_ownership.created = res.body.vessel_ownership.created;
this.vessel.vessel_ownership.dot_name = res.body.vessel_ownership.dot_name;
this.vessel.vessel_ownership.end_name = res.body.vessel_ownership.end_name;
this.vessel.vessel_ownership.id = res.body.vessel_ownership.id;
this.vessel.vessel_ownership.start_date = res.body.vessel_ownership.start_date;
this.vessel.vessel_ownership.updated = res.body.vessel_ownership.updated;
this.vessel.vessel_ownership.vessel = res.body.vessel_ownership.vessel;
this.vessel.vessel_ownership.individual_owner = res.body.vessel_ownership.individual_owner;
this.vessel.vessel_ownership.owner = res.body.vessel_ownership.owner;
this.vessel.vessel_ownership.proposal_id = res.body.vessel_ownership.proposal_id;
this.vessel.vessel_details.berth_mooring = res.body.vessel_details.berth_mooring;
this.vessel.vessel_details.created = res.body.vessel_details.created;
this.vessel.vessel_details.id = res.body.vessel_details.id;
this.vessel.vessel_details.read_only = res.body.vessel_details.read_only;
this.vessel.vessel_details.updated = res.body.vessel_details.updated;
this.vessel.vessel_details.vessel = res.body.vessel_details.vessel;
this.vessel.vessel_details.vessel_beam = res.body.vessel_details.vessel_beam;
this.vessel.vessel_details.vessel_draft = res.body.vessel_details.vessel_draft;
this.vessel.vessel_details.vessel_length = res.body.vessel_details.vessel_length;
this.vessel.vessel_details.vessel_name = res.body.vessel_details.vessel_name;
this.vessel.vessel_details.vessel_type = res.body.vessel_details.vessel_type;
this.vessel.vessel_details.vessel_type_display = res.body.vessel_details.vessel_type_display;
this.vessel.vessel_details.vessel_weight = res.body.vessel_details.vessel_weight;
const payload = {
id: this.vessel.id,
tag: false,
selected: true,
}
console.log('trigger select2:select.')
$(vm.$refs.vessel_rego_nos).trigger({
type: 'select2:select',
params: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
<div class="col-sm-12">
<button v-if="hasAssessorMode" @click.prevent="addRequirement()" style="margin-bottom:10px;" class="btn btn-primary pull-right">Add Condition</button>
</div>
<div class="col-sm-12">
<datatable ref="requirements_datatable" :id="'requirements-datatable-'+_uid" :dtOptions="requirement_options" :dtHeaders="requirement_headers"/>
</div>
</form>
</div>
<RequirementDetail
Expand Down

0 comments on commit 65c9a14

Please sign in to comment.