Skip to content

Commit

Permalink
Merge branch 'develop' into mds-5456-now-doc-delete-bug
Browse files Browse the repository at this point in the history
  • Loading branch information
asinn134 committed Oct 11, 2023
2 parents 417d3c7 + 8cbe36b commit 16b5449
Show file tree
Hide file tree
Showing 36 changed files with 1,708 additions and 478 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ ms:

extra:
@echo "+\n++ Building tertiary services ...\n+"
@docker-compose $(DC_FILE) up -d minespace docgen-api
@docker-compose $(DC_FILE) up -d docgen-api

# Simply for legacy support, this command will be retired shortly
fe:
Expand Down
2 changes: 2 additions & 0 deletions services/common/src/utils/featureFlag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ export enum Feature {
DOCUMENTS_REPLACE_FILE = "major_project_replace_file",
MAJOR_PROJECT_ALL_DOCUMENTS = "major_project_all_documents",
MAJOR_PROJECT_DECISION_PACKAGE = "major_project_decision_package",
ESUP_PERMIT_AMENDMENT = "esup_permit_amendment",
FLAGSMITH = "flagsmith",
TSF_V2 = "tsf_v2",
ONE_WINDOW_FOR_CREATING_NEW_OR_HISTORICAL_ESUP = "one_window_for_creating_new_or_historical_esup",
}

export const initializeFlagsmith = async (flagsmithUrl, flagsmithKey) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ def insert_images(doc, template_data):
raise Exception('Image data is not a valid Base64 string')

image_bytes = io.BytesIO(image_data)
width = Inches(image['width']) if image['width'] else None
height = Inches(image['height']) if image['height'] else None
width = Inches(image['width']) if image['width'] else Inches(7.5)
height = Inches(image['height']) if image['height'] else Inches(11)
paragraph.clear()
run = paragraph.add_run()
run.add_picture(image_bytes, width=width, height=height)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ def process_magazines(magazines, updated_magazines, type):
if explosives_permit_magazine_id:
magazine = ExplosivesPermitMagazine.find_by_explosives_permit_magazine_id(
explosives_permit_magazine_id)
magazine.update_from_data(magazine_data)
if magazine:
magazine.update_from_data(magazine_data)
else:
magazine = ExplosivesPermitMagazine.create_from_data(type, magazine_data)
magazines.append(magazine)
Expand Down Expand Up @@ -352,3 +353,9 @@ def find_by_mine_guid(cls, mine_guid):
def find_by_explosives_permit_guid(cls, explosives_permit_guid):
return cls.query.filter_by(
explosives_permit_guid=explosives_permit_guid, deleted_ind=False).one_or_none()

@classmethod
def find_permit_number_by_explosives_permit_id(cls, explosives_permit_id):
obj = cls.query.filter_by(
explosives_permit_id=explosives_permit_id, deleted_ind=False).one_or_none()
return obj.permit_number if obj else None
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from sqlalchemy.schema import Sequence

from app.api.mines.documents.models.mine_document import MineDocument
from app.api.mines.explosives_permit.models.explosives_permit import ExplosivesPermit
from app.api.mines.explosives_permit.models.explosives_permit_document_type import ExplosivesPermitDocumentType

from app.api.mines.explosives_permit_amendment.models.explosives_permit_amendment_document_xref import \
Expand Down Expand Up @@ -84,7 +85,6 @@ def create(cls,
description,
issue_date,
expiry_date,
permit_number,
issuing_inspector_party_guid,
mine_manager_mine_party_appt_id,
permittee_mine_party_appt_id,
Expand All @@ -107,7 +107,6 @@ def create(cls,
application_number = ExplosivesPermitAmendment.get_next_application_number()
received_timestamp = datetime.utcnow()
is_closed = False
permit_number = None
issue_date = None
expiry_date = None
if is_closed:
Expand All @@ -117,6 +116,8 @@ def create(cls,
closed_reason = None
closed_timestamp = None

permit_number = ExplosivesPermit.find_permit_number_by_explosives_permit_id(explosives_permit_id)

explosives_permit_amendment = cls(
permit_guid=permit_guid,
explosives_permit_id=explosives_permit_id,
Expand Down Expand Up @@ -175,6 +176,7 @@ def find_by_explosives_permit_amendment_guid(cls, explosives_permit_amendment_gu
explosives_permit_amendment_guid=explosives_permit_amendment_guid, deleted_ind=False).one_or_none()

def update(self,
explosives_permit_id,
permit_guid,
now_application_guid,
issuing_inspector_party_guid,
Expand Down Expand Up @@ -327,8 +329,8 @@ def create_issued_permit():
)
return ExplosivesPermitAmendmentDocumentResource.generate_explosives_permit_document(
token, True, False, False)
if self.application_status == 'REC' and application_status == 'APP':
self.permit_number = ExplosivesPermitAmendment.get_next_permit_number()

permit_number = ExplosivesPermit.find_permit_number_by_explosives_permit_id(explosives_permit_id)
create_permit_enclosed_letter()
create_issued_permit()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
from app.api.mines.explosives_permit_amendment.models.explosives_permit_amendment import ExplosivesPermitAmendment
class ExplosivesPermitAmendmentResource(Resource, UserMixin):
parser = CustomReqparser()
parser.add_argument(
'explosives_permit_id',
type=str,
store_missing=False,
required=False,
)
parser.add_argument(
'explosives_permit_guid',
type=str,
Expand Down Expand Up @@ -180,6 +186,7 @@ def put(self,mine_guid, explosives_permit_amendment_guid):
data = self.parser.parse_args()

explosives_permit_amendment.update(
data.get('explosives_permit_id'),
data.get('permit_guid'), data.get('now_application_guid'),
data.get('issuing_inspector_party_guid'), data.get('mine_manager_mine_party_appt_id'),
data.get('permittee_mine_party_appt_id'), data.get('application_status'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,6 @@ class ExplosivesPermitAmendmentListResource(Resource, UserMixin):
store_missing=False,
required=False,
)
parser.add_argument(
'permit_number',
type=str,
store_missing=False,
required=False,
)
parser.add_argument(
'detonator_magazines',
type=list,
Expand Down Expand Up @@ -159,7 +153,6 @@ def post(self, mine_guid):
data.get('latitude'), data.get('longitude'),
data.get('description'), data.get('issue_date'),
data.get('expiry_date'),
data.get('permit_number'),
data.get('issuing_inspector_party_guid'),
data.get('mine_manager_mine_party_appt_id'),
data.get('permittee_mine_party_appt_id'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,8 @@ def post(self):
else: # raise BadRequest(f"not a active connection")
traction_svc = TractionService()
response = traction_svc.offer_mines_act_permit(active_connections[0].connection_id, attributes)
map_vc = PartyVerifiableCredentialMinesActPermit(cred_exch_id = response["cred_exch_id"],party_guid = party_guid, permit_amendment_guid=permit_amendment_guid)
map_vc = PartyVerifiableCredentialMinesActPermit(cred_exch_id = response["credential_exchange_id"],party_guid = party_guid, permit_amendment_guid=permit_amendment_guid)
map_vc.save()



return response

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

PRESENT_PROOF = "present_proof"
CONNECTIONS = "connections"
CREDENTIAL_OFFER = "credential_offer"
CREDENTIAL_OFFER = "issue_credential"

class VerifiableCredentialWebhookResource(Resource, UserMixin):
@api.doc(description='Endpoint to recieve webhooks from Traction.', params={})
Expand All @@ -28,7 +28,7 @@ def post(self, topic):
vc_conn.save()
current_app.logger.debug(f"Updated party_vc_conn invitation_id={invitation_id} with state={new_state}")
if topic == CREDENTIAL_OFFER:
cred_exch_id = request.args.get("cred_exch_id")
cred_exch_id = request.args.get("credential_exchange_id")
cred_exch_record = PartyVerifiableCredentialMinesActPermit.query.unbound_unsafe().filter_by(cred_exch_id=cred_exch_id).first()
assert cred_exch_record
new_state = request.args["state"]
Expand Down
1 change: 1 addition & 0 deletions services/core-api/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,7 @@ class Params:
mine_manager_mine_party_appt_id = factory.SelfAttribute('mine_manager.mine_party_appt_id')
permittee_mine_party_appt_id = factory.SelfAttribute('permittee.mine_party_appt_id')

explosives_permit_id = factory.Faker('random_int', min=1000, max=9999)
originating_system = 'Core'
application_number = factory.Faker('sentence', nb_words=1)
received_timestamp = TODAY
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
from tests.factories import ExplosivesPermitAmendmentFactory, create_mine_and_permit, MinePartyAppointmentFactory, \
ExplosivesPermitFactory
import json

def test_post_explosives_permit_amendment_application(test_client, db_session, auth_headers):
mine, permit = create_mine_and_permit()
mine_manager = MinePartyAppointmentFactory(mine=mine)
permittee = MinePartyAppointmentFactory(mine=mine)
explosives_permit = ExplosivesPermitFactory()
data = {
'explosives_permit_id': explosives_permit.explosives_permit_id,
'originating_system':
'Core',
'permit_guid':
str(permit.permit_guid),
'mine_manager_mine_party_appt_id':
mine_manager.mine_party_appt_id,
'permittee_mine_party_appt_id':
permittee.mine_party_appt_id,
'application_date':
'2021-07-12',
'description':
'Other Information.',
'latitude':
'54',
'longitude':
'40',
'explosive_magazines': [{
'type_no': '1',
'tag_no': '1',
'construction': '1',
'quantity': '1',
'latitude': '1',
'longitude': '1',
'distance_road': '1',
'distance_dwelling': '1',
'length': '1',
'width': '1',
'height': '1'
}],
'detonator_magazines': [{
'type_no': '1',
'tag_no': '1',
'construction': '1',
'quantity': '1',
'longitude': '1',
'latitude': '1',
'detonator_type': '1',
'distance_road': '1',
'distance_dwelling': '1',
'width': '1',
'height': '1',
'length': '1'
}]
}

post_resp = test_client.post(
f'/mines/{mine.mine_guid}/explosives-permits-amendment',
json=data,
headers=auth_headers['full_auth_header'])

assert post_resp.status_code == 201
assert len(mine.explosives_permits_amendments) == 1

post_data = json.loads(post_resp.data.decode())
assert post_data['explosives_permit_id'] != None
assert post_data['mine_guid'] == str(mine.mine_guid)
assert post_data['permit_guid'] == data['permit_guid']
assert post_data['application_status'] == 'REC'
assert post_data['application_number'] != None
assert post_data['received_timestamp'] != None
assert post_data['is_closed'] == False
assert post_data['permit_number'] == None
assert post_data['issue_date'] == None
assert post_data['expiry_date'] == None
assert len(post_data['explosive_magazines']) == len(data['explosive_magazines'])
assert len(post_data['detonator_magazines']) == len(data['detonator_magazines'])
15 changes: 15 additions & 0 deletions services/core-web/src/assets/icons/violet-edit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from "react";
import Icon from "@ant-design/icons";

const EditSvg = () => (
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M21.1784 8.88387L8.55161 21.5079L4.20485 21.9886C2.94506 22.1281 1.8728 21.0656 2.01224 19.7965L2.49307 15.4507L15.1198 2.82664C16.2209 1.72576 18 1.72576 19.0963 2.82664L21.1736 4.9034C22.2747 6.00428 22.2747 7.7878 21.1784 8.88387ZM16.4277 10.3693L13.634 7.57628L4.70011 16.5131L4.3491 19.6523L7.48896 19.3013L16.4277 10.3693ZM19.5435 6.53789L17.4663 4.46113C17.2692 4.26403 16.947 4.26403 16.7547 4.46113L15.2689 5.94659L18.0626 8.73965L19.5483 7.25418C19.7407 7.05228 19.7407 6.73499 19.5435 6.53789Z"
fill="#5e46a1"
/>
</svg>
);

const VioletEditIcon = (props) => <Icon component={EditSvg} {...props} />;

export default VioletEditIcon;
Loading

0 comments on commit 16b5449

Please sign in to comment.