Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Base64 image and TODOs addressed #491

Merged
merged 9 commits into from
Dec 2, 2024
30 changes: 1 addition & 29 deletions mooringlicensing/components/approvals/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ def get_moorings(self, request, *args, **kwargs):
continue
return Response(moorings)

@detail_route(methods=['POST'], detail=True, permission_classes=[InternalApprovalPermission]) #TODO need specific group perm?
@detail_route(methods=['POST'], detail=True, permission_classes=[InternalApprovalPermission])
@basic_exception_handler
def swap_moorings(self, request, *args, **kwargs):
with transaction.atomic():
Expand Down Expand Up @@ -1585,34 +1585,6 @@ def lookup_dcv_vessel(self, request, *args, **kwargs):
dcv_vessel_data = serializer.data
return Response(dcv_vessel_data)

#TODO review - should be fine as is provided that DCV vessels do not move between users (which they currently cannot)
# also appears to only be used by an unimplemented template
@detail_route(methods=['POST',], detail=True)
@basic_exception_handler
def find_related_admissions(self, request, *args, **kwargs):
vessel = self.get_object()
selected_date_str = request.data.get("selected_date")
selected_date = None
if selected_date_str:
selected_date = datetime.strptime(selected_date_str, '%d/%m/%Y').date()
admissions = DcvAdmission.objects.filter(dcv_vessel=vessel)
serializer = LookupDcvAdmissionSerializer(admissions, many=True)
return Response(serializer.data)

#TODO review - should be fine as is provided that DCV vessels do not move between users (which they currently cannot)
# also appears to only be used by an unimplemented template
@detail_route(methods=['POST',], detail=True)
@basic_exception_handler
def find_related_permits(self, request, *args, **kwargs):
vessel = self.get_object()
selected_date_str = request.data.get("selected_date")
selected_date = None
if selected_date_str:
selected_date = datetime.strptime(selected_date_str, '%d/%m/%Y').date()
admissions = DcvPermit.objects.filter(dcv_vessel=vessel)
serializer = LookupDcvPermitSerializer(admissions, many=True)
return Response(serializer.data)


class DcvAdmissionFilterBackend(DatatablesFilterBackend):
def filter_queryset(self, request, queryset, view):
Expand Down
7 changes: 1 addition & 6 deletions mooringlicensing/components/approvals/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,6 @@ def send_approval_reinstate_email_notification(approval, request):
'public_url': get_public_url(request),
'approval': approval,
'recipient': approval.applicant_obj,
'details': '', # TODO add details
}
all_ccs = []
msg = email.send(proposal.applicant_obj.email, cc=all_ccs, context=context)
Expand Down Expand Up @@ -879,8 +878,4 @@ def send_aup_revoked_due_to_relinquishment_email(request, authorised_user_permit
if msg:
sender = request.user if request else settings.DEFAULT_FROM_EMAIL
_log_approval_email(msg, approval, sender=sender, attachments=attachments)
_log_user_email(msg, approval.applicant_obj, proposal.applicant_obj, sender=sender)

# 39
# email to account holder with authentication link to complete login process
# TODO: can we overwrite this template served by the ledger?
_log_user_email(msg, approval.applicant_obj, proposal.applicant_obj, sender=sender)
11 changes: 0 additions & 11 deletions mooringlicensing/components/approvals/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1344,14 +1344,6 @@ def manage_stickers(self, proposal):
# Check if a new sticker needs to be created
create_new_sticker = True
if proposal.proposal_type.code == PROPOSAL_TYPE_AMENDMENT:
#NOTE: business requirement are such that even a major length/ownership change does not warrant a new sticker (TODO: confirm this, remove commented code if True)
#if proposal.vessel_ownership == proposal.previous_application.vessel_ownership:
#next_colour = Sticker.get_vessel_size_colour_by_length(proposal.vessel_length)
#current_colour = Sticker.get_vessel_size_colour_by_length(proposal.previous_application.vessel_length)
#if current_colour == next_colour:
# This is the only case where there is no new sticker to be created
#create_new_sticker = False
#TODO confirm below
if proposal.vessel_ownership != proposal.previous_application.vessel_ownership:
if proposal.vessel_ownership.vessel == proposal.previous_application.vessel_ownership.vessel:
create_new_sticker = False
Expand Down Expand Up @@ -3335,9 +3327,6 @@ def delete_documents(sender, instance, *args, **kwargs):
continue

import reversion
#TODO review all reversion registrations and applied revision mixins - some records do not require history or should only be recorded via a main record
#for example - AgeGroup is a reference field and does need history
#another example - ApprovalLogEntry records never change and only need to be tracked via Approval (if at all)
reversion.register(WaitingListOfferDocument, follow=[])
reversion.register(RenewalDocument, follow=['renewal_document'])
reversion.register(AuthorisedUserSummaryDocument, follow=['approvals'])
Expand Down
9 changes: 6 additions & 3 deletions mooringlicensing/components/approvals/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@

from django.core.files.base import ContentFile

from mooringlicensing.doctopdf import create_dcv_permit_pdf_tytes, create_dcv_admission_pdf_bytes, \
create_approval_doc_bytes, create_renewal_doc_bytes
from mooringlicensing.doctopdf import (
create_dcv_permit_pdf_tytes,
create_dcv_admission_pdf_bytes,
create_approval_doc_bytes,
)


def create_dcv_permit_document(dcv_permit):
Expand Down Expand Up @@ -53,7 +56,7 @@ def create_approval_doc(approval):

def create_renewal_doc(approval, proposal):
# create bytes
contents_as_bytes = create_renewal_doc_bytes(approval)
contents_as_bytes = create_approval_doc_bytes(approval)

filename = 'renewal-{}-{}.pdf'.format(approval.lodgement_number, proposal.lodgement_number)
from mooringlicensing.components.approvals.models import RenewalDocument
Expand Down
17 changes: 10 additions & 7 deletions mooringlicensing/components/main/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@

from mooringlicensing.components.approvals.models import (
Sticker, AnnualAdmissionPermit, AuthorisedUserPermit,
MooringLicence, Approval, WaitingListAllocation
MooringLicence, Approval, WaitingListAllocation, ApprovalHistory
)
from mooringlicensing.components.approvals.serializers import ListApprovalSerializer
from mooringlicensing.components.proposals.email import send_sticker_printing_batch_email
from mooringlicensing.components.proposals.models import (
MooringBay,
Expand All @@ -30,8 +29,6 @@
from copy import deepcopy
import logging

from mooringlicensing.components.users.serializers import ProposalApplicantSerializer

logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -301,8 +298,15 @@ def sticker_export():
logger.info('Sticker: {} details added to the spreadsheet'.format(sticker.number))
updates.append(sticker.number)

#TODO review and implement (or remove)
#new_approval_history_entry.stickers.add(sticker)
new_approval_history_entry = ApprovalHistory.objects.create(
vessel_ownership=sticker.approval.current_proposal.vessel_ownership,
approval=sticker.approval,
proposal=sticker.approval.current_proposal,
start_date=sticker.approval.issue_date,
approval_letter=sticker.approval.licence_document,
)
new_approval_history_entry.stickers.add(sticker)
new_approval_history_entry.save()

except Exception as e:
err_msg = 'Error adding sticker: {} details to spreadsheet.'.format(sticker.number)
Expand Down Expand Up @@ -379,7 +383,6 @@ def get_client_ip(request):
ip = request.META.get('REMOTE_ADDR')
return ip

#TODO review - do we still need DoT information?
def get_dot_vessel_information(request,json_string):
DOT_URL=settings.DOT_URL
paramGET=json_string.replace("\n", "")
Expand Down
2 changes: 0 additions & 2 deletions mooringlicensing/components/proposals/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,6 @@ def send_approver_approve_decline_email_notification(request, proposal):
log_proposal_email(msg, proposal, sender)
return msg

# TODO: #4


def send_amendment_email_notification(amendment_request, request, proposal):
# 5
Expand Down
15 changes: 0 additions & 15 deletions mooringlicensing/components/proposals/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,6 @@ def start_date(self):

@property
def end_date(self):
#TODO either fix this or fix expiry date being set to this when renewing without vessel...
end_date = None
application_fee = self.get_main_application_fee()
print(application_fee)
Expand Down Expand Up @@ -2322,7 +2321,6 @@ def mooring_changed(self, request=None):

class ProposalApplicant(RevisionedMixin):
email_user_id = models.IntegerField(null=True, blank=True)
#TODO: ideally this should be referenced by the proposal, not the other way around (no reason for a proposal to have multiple proposal applicants)
proposal = models.OneToOneField(Proposal, null=True, blank=True, on_delete=models.SET_NULL, related_name="proposal_applicant")

# Name, etc
Expand Down Expand Up @@ -4151,11 +4149,6 @@ class Meta:
verbose_name_plural = "Moorings"
app_label = 'mooringlicensing'

#TODO does not appear to be in use but may be needed? review
@property
def specification_display(self):
return self.get_mooring_bookings_mooring_specification_display()

def log_user_action(self, action, request):
return MooringUserAction.log_action(self, action, request.user.id)

Expand Down Expand Up @@ -4651,12 +4644,6 @@ def applicable_percentage(self):
else:
return self.percentage

#TODO does not appear to be used but may still be needed - review
@property
def company_ownership_latest(self):
if self.company_ownerships.count():
return self.company_ownerships.order_by('created').last()

@property
def individual_owner(self):
if self.get_latest_company_ownership():
Expand Down Expand Up @@ -5151,8 +5138,6 @@ def delete_documents(sender, instance, *args, **kwargs):
document.delete()

import reversion

#TODO review all reversion registrations and applied revision mixins - some records do not require history or should only be recorded via a main record
reversion.register(ProposalDocument)
reversion.register(ProposalType, follow=['proposal_set',])
reversion.register(Proposal, follow=['proposal_applicant'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,6 @@ <H4>Hover over button to see help text.</H4>
<div class="row">
<button type="submit" name="script" value="export_to_mooring_booking" {% if export_to_mooring_booking == 'true' %}style="color:green" {% endif %} title="Export to Mooring Booking">Run Script 'export_to_mooring_booking'</button>
</div>
<div class="row">
<button type="submit" name="script" value="import_lotus_notes" {% if import_lotus_notes == 'true' %}style="color:green" {% endif %} title="Import Lotus Notes">Run Script 'import_lotus_notes'</button>
</div>
<div class="row">
<button type="submit" name="script" value="check_proposal_endorsements" {% if check_proposal_endorsements == 'true' %}style="color:green" {% endif %} title="Check Proposal Endorsements">Run Script 'check_proposal_endorsements'</button>
</div>
Expand Down
1 change: 0 additions & 1 deletion mooringlicensing/components/proposals/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,6 @@ def get_fee_amount_adjusted(proposal, fee_item_being_applied, vessel_length):
fee_amount_adjusted = 0 if fee_amount_adjusted <= 0 else fee_amount_adjusted
else:
if proposal.does_accept_null_vessel:
# TODO: We don't charge for this application but when new replacement vessel details are provided,calculate fee and charge it (investigate if this has been done or not)
fee_amount_adjusted = 0
else:
msg = 'The application fee admin data might have not been set up correctly. Please contact the Rottnest Island Authority.'
Expand Down
7 changes: 1 addition & 6 deletions mooringlicensing/doctopdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,4 @@ def create_approval_doc_bytes(approval):
file_contents = f.read()
os.remove(new_doc_file)
os.remove(new_pdf_file)
return file_contents


# TODO: renewal specific data
def create_renewal_doc_bytes(approval):
return create_approval_doc_bytes(approval)
return file_contents
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,6 @@ export default {
return result;
},
'createdCell': function (cell) {
//TODO why this is not working?
// the call to popover is done in the 'draw' event
$(cell).popover();
}
},
Expand Down Expand Up @@ -204,8 +202,6 @@ export default {
return result;
},
'createdCell': function (cell) {
//TODO why this is not working?
// the call to popover is done in the 'draw' event
$(cell).popover();
}
},
Expand Down Expand Up @@ -242,8 +238,6 @@ export default {
return result;
},
'createdCell': function (cell) {
//TODO why this is not working?
// the call to popover is done in the 'draw' event
$(cell).popover();
}
},
Expand Down Expand Up @@ -275,8 +269,6 @@ export default {
return result;
},
'createdCell': function (cell) {
//TODO why this is not working?
// the call to popover is done in the 'draw' event
$(cell).popover();
}
},
Expand Down
Loading
Loading