Skip to content

Commit

Permalink
Merge branch 'develop' into MDS-5792-banner-clarification
Browse files Browse the repository at this point in the history
# Conflicts:
#	services/common/src/constants/enums.ts
#	services/common/src/constants/strings.tsx
  • Loading branch information
henryoforeh-dev committed Mar 5, 2024
2 parents 4b22122 + 5d0ed4a commit 9c8ec9c
Show file tree
Hide file tree
Showing 23 changed files with 164 additions and 84 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/automation_jira-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Check for PR Title for Jira link
uses: gsactions/commit-message-checker@8c8c0d18ba9b1fcfed6e7385fd2bf357dfc8dccb
with:
pattern: '(\W)+(MDS)+-[0-9]+(\W)|(\W)(CHORE|FIX)(\W)'
pattern: '(\W)+(MDS)+-[0-9]+(\W)|(\W)(CHORE|FIX|Snyk)(\W)'
excludeTitle: "false" # optional: this excludes the title of a pull request
excludeDescription: "true" # optional: this excludes the description body of a pull request
checkAllCommitMessages: "false" # optional: this checks all commits associated with a pull request
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
INSERT INTO mine_report_submission_status_code
(mine_report_submission_status_code, description, display_order, active_ind, create_user, update_user)
VALUES
('NON', 'Report Requested', 1, TRUE, 'system-mds', 'system-mds');
30 changes: 16 additions & 14 deletions services/common/src/components/reports/ReportDetailsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {
REPORT_REGULATORY_AUTHORITY_ENUM,
IMine,
IEmliContact,
MINE_REPORT_SUBMISSION_CODES,
} from "../..";
import RenderAutoSizeField from "../forms/RenderAutoSizeField";
import { BaseViewInput } from "../forms/BaseInput";
Expand Down Expand Up @@ -67,8 +68,8 @@ import { fetchEMLIContactsByRegion } from "@mds/common/redux/actionCreators/mine
import { getEMLIContactsByRegion } from "@mds/common/redux/selectors/minespaceSelector";
import { useParams } from "react-router-dom";

const RenderContacts: FC<any> = ({ fields, isEditMode, mineSpaceEdit }) => {
const canEdit = isEditMode && !mineSpaceEdit;
const RenderContacts: FC<any> = ({ fields, isEditMode, mineSpaceEdit, hasSubmissions }) => {
const canEdit = isEditMode && (!mineSpaceEdit || !hasSubmissions);
return (
<div>
{fields.map((contact, index) => (
Expand Down Expand Up @@ -149,6 +150,7 @@ const ReportDetailsForm: FC<ReportDetailsFormProps> = ({
const {
mine_report_category = "",
mine_report_definition_guid = "",
mine_report_submission_status_code,
documents = [],
report_type,
permit_condition_category_code,
Expand Down Expand Up @@ -184,6 +186,7 @@ const ReportDetailsForm: FC<ReportDetailsFormProps> = ({
const isPRR = report_type === REPORT_TYPE_CODES.PRR;
const isMS = system === SystemFlagEnum.ms;

const hasSubmissions = mine_report_submission_status_code !== MINE_REPORT_SUBMISSION_CODES.NON;
// minespace users are only allowed to add documents
const mineSpaceEdit = isMS && initialValues?.mine_report_guid && isEditMode;

Expand Down Expand Up @@ -263,9 +266,7 @@ const ReportDetailsForm: FC<ReportDetailsFormProps> = ({
useEffect(() => {
if (system === SystemFlagEnum.core) {
const selection = mineReportDefinition?.compliance_articles[0]?.cim_or_cpo;
dispatch(
change(FORM.VIEW_EDIT_REPORT, "report_for", selection ? selection : "Not specified")
);
dispatch(change(FORM.VIEW_EDIT_REPORT, "report_for", selection ?? "Not specified"));
}
}, [mineReportDefinition, !formValues?.report_for]);

Expand Down Expand Up @@ -505,7 +506,7 @@ const ReportDetailsForm: FC<ReportDetailsFormProps> = ({
id="description_comment"
name="description_comment"
label="Report Description"
disabled={mineSpaceEdit}
disabled={mineSpaceEdit && hasSubmissions}
placeholder={`Example: "Mine X's Annual Reclamation Report, as per section 10.4.4. Spatial files included."`}
props={{ maximumCharacters: 500, rows: 3 }}
component={RenderAutoSizeField}
Expand Down Expand Up @@ -555,7 +556,7 @@ const ReportDetailsForm: FC<ReportDetailsFormProps> = ({
name="submitter_name"
label="Submitter Name"
placeholder="Enter name"
disabled={mineSpaceEdit}
disabled={mineSpaceEdit && hasSubmissions}
required={isMS}
component={RenderField}
validate={isMS ? [required] : []}
Expand All @@ -568,7 +569,7 @@ const ReportDetailsForm: FC<ReportDetailsFormProps> = ({
name="submitter_email"
label="Submitter Email"
placeholder="Enter email"
disabled={mineSpaceEdit}
disabled={mineSpaceEdit && hasSubmissions}
component={RenderField}
required={isMS}
validate={isMS ? [required, email] : [email]}
Expand Down Expand Up @@ -602,11 +603,11 @@ const ReportDetailsForm: FC<ReportDetailsFormProps> = ({
<FieldArray
name="mine_report_contacts"
component={RenderContacts}
props={{ isEditMode, mineSpaceEdit }}
props={{ isEditMode, mineSpaceEdit, hasSubmissions }}
/>
</Col>
<Col span={24}>
{isEditMode && !mineSpaceEdit && (
{isEditMode && (!mineSpaceEdit || !hasSubmissions) && (
<Button
type="primary"
className="btn-sm-padding"
Expand Down Expand Up @@ -640,11 +641,11 @@ const ReportDetailsForm: FC<ReportDetailsFormProps> = ({
<ReportFileUpload
mineGuid={mineGuid}
isProponent={system === SystemFlagEnum.ms}
documents={documents}
documents={documents ?? []}
updateDocuments={updateDocuments}
/>
)}
<ReportFilesTable documents={documents} />
{(hasSubmissions || documents) && <ReportFilesTable documents={documents} />}
</Col>
{system === SystemFlagEnum.core && (
<AuthorizationWrapper permission={coreViewAllPermission} showToolTip={false}>
Expand All @@ -658,8 +659,9 @@ const ReportDetailsForm: FC<ReportDetailsFormProps> = ({
<strong>
These comments are for internal staff only and will not be shown to proponents.
</strong>
Add comments to this report submission for future reference. Anything written in
these comments may be requested under FOIPPA. Keep it professional and concise.
&nbsp;Add comments to this report submission for future reference. Anything
written in these comments may be requested under FOIPPA. Keep it professional and
concise.
</Typography.Paragraph>
<MinistryCommentPanel
renderEditor={true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const submissionSlice = createAppSlice({
async (payload: IMineReportSubmission, thunkApi) => {
const headers = createRequestHeader();
thunkApi.dispatch(showLoading());
const successMessage = payload.mine_report_guid
const successMessage = payload.mine_report_submission_guid
? "Report successfully resubmitted"
: "Successfully created new report submission";

Expand Down
1 change: 1 addition & 0 deletions services/common/src/constants/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export enum MINE_REPORT_SUBMISSION_CODES {
REC = "REC",
ACC = "ACC",
INI = "INI",
NON = "NON",
WTD = "WTD",
}

Expand Down
5 changes: 3 additions & 2 deletions services/common/src/constants/strings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,8 @@ export const PARTY_APPOINTMENT_STATUS = {
};

export const ESUP_DOCUMENT_GENERATED_TYPES = {
LET: "Explosives Storage and Use Permit",
PER: "Permit Enclosed Letter",
PER: "Explosives Storage and Use Permit",
LET: "Permit Enclosed Letter",
};

export const BC_TIMEZONE_NAMES = ["Canada/Pacific", "Canada/Mountain", "Canada/Yukon"];
Expand Down Expand Up @@ -409,5 +409,6 @@ export const MINE_REPORT_STATUS_HASH = {
[MINE_REPORT_SUBMISSION_CODES.REC]: "Changes Received",
[MINE_REPORT_SUBMISSION_CODES.ACC]: "Accepted",
[MINE_REPORT_SUBMISSION_CODES.INI]: "Received",
[MINE_REPORT_SUBMISSION_CODES.NON]: "Report Requested",
[MINE_REPORT_SUBMISSION_CODES.WTD]: "Withdrawn",
};
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ export interface IMineReport {
mine_name: string;
submitter_name: string;
submitter_email: string;
mine_report_submission_status?: MINE_REPORT_SUBMISSION_CODES;
mine_report_status_code: MINE_REPORT_SUBMISSION_CODES;
}
13 changes: 9 additions & 4 deletions services/core-api/app/api/mines/reports/models/mine_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from sqlalchemy.ext.associationproxy import association_proxy
from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy.orm import validates
from sqlalchemy import select, and_, desc
from sqlalchemy import select, and_, desc, func, literal
from app.api.mines.reports.models.mine_report_contact import MineReportContact
from app.api.mines.reports.models.mine_report_submission import MineReportSubmission
from app.api.mines.reports.models.mine_report_submission_status_code import MineReportSubmissionStatusCode
Expand Down Expand Up @@ -80,18 +80,23 @@ def mine_report_status_code(self):
if self.mine_report_submissions:
return self.mine_report_submissions[-1].mine_report_submission_status_code
else:
return None
return "NON"

@hybrid_property
def report_type(self):
return "PRR" if self.permit_condition_category_code else "CRR"

@hybrid_property
def report_name(self):
return self.mine_report_definition_report_name if self.mine_report_definition_report_name else self.permit_condition_category_description

@mine_report_status_code.expression
def mine_report_status_code(cls):
return select([
return func.coalesce(select([
MineReportSubmission.mine_report_submission_status_code
]).where(MineReportSubmission.mine_report_id == cls.mine_report_id).order_by(
desc(MineReportSubmission.mine_report_submission_id)).limit(1).as_scalar()
desc(MineReportSubmission.mine_report_submission_id)).limit(1).as_scalar(),
literal("NON"))

@hybrid_property
def mine_report_status_description(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,43 @@ def create_initial_mine_report(request_data, permit_id=None, mine_report_definit
)
mine_report.save()
return mine_report

# case when report has been requested
@staticmethod
def create_initial_submission_from_minespace(request_data, report_documents):
mine_report = MineReport.find_by_mine_report_guid(request_data.get('mine_report_guid'))
mine_report_id = getattr(mine_report, "mine_report_id")

report_submission = MineReportSubmission(
create_timestamp=getattr(mine_report, "create_timestamp"),
description_comment=request_data.get("description_comment", None),
due_date=getattr(mine_report, "due_date"),
documents=report_documents,
mine_guid=getattr(mine_report, "mine_guid"),
mine_report_definition_id=getattr(mine_report, "mine_report_definition_id"),
mine_report_id=mine_report_id,
mine_report_submission_status_code="INI",
permit_condition_category_code=getattr(mine_report, "permit_condition_category_code"),
permit_id=getattr(mine_report, "permit_id"),
received_date=request_data.get("received_date", None),
submission_date=datetime.utcnow(),
submission_year=getattr(mine_report, "submission_year"),
submitter_email=request_data.get("submitter_email", None),
submitter_name=request_data.get("submitter_name", None),
)
mine_report_contacts = ReportSubmissionResource.get_mine_report_submission_contacts(
request_data.get('mine_report_contacts'), mine_report_id, report_submission.mine_report_submission_id)
report_submission.mine_report_contacts = mine_report_contacts

report_submission.save()
return report_submission

# not for first submission, for subsequent
@staticmethod
def create_submission_from_minespace(mine_report_guid, request_data, report_documents):
previous_submission = MineReportSubmission.find_latest_by_mine_report_guid(str(mine_report_guid))
if not previous_submission or request_data.get('mine_report_submission_status_code') == "NON":
return ReportSubmissionResource.create_initial_submission_from_minespace(request_data, report_documents)
mine_report_submission_status_code = "NRQ"

report_submission = MineReportSubmission(
Expand All @@ -123,6 +155,7 @@ def create_submission_from_minespace(mine_report_guid, request_data, report_docu
submitter_email=getattr(previous_submission, "submitter_email"),
submitter_name=getattr(previous_submission, "submitter_name"),
)

report_submission.save()
return report_submission

Expand All @@ -143,6 +176,7 @@ def post(self):
self.parser.add_argument('mine_report_definition_guid', type=str, location='json')
self.parser.add_argument('mine_report_id', type=str, location='json')
self.parser.add_argument('mine_report_guid', type=str, location='json')
self.parser.add_argument('mine_report_submission_guid', type=str, location='json')
self.parser.add_argument('mine_report_submission_status_code', type=str, location='json')
self.parser.add_argument('permit_condition_category_code', type=str, location='json')
self.parser.add_argument('permit_guid', type=str, location='json')
Expand All @@ -161,6 +195,7 @@ def post(self):

mine_guid = data.get('mine_guid', None)
mine_report_guid = data.get('mine_report_guid', None)
mine_report_submission_guid = data.get('mine_report_submission_guid', None)
mine_report_id = data.get('mine_report_id', None)
permit_condition_category_code = data.get('permit_condition_category_code', None)
documents = data.get('documents', [])
Expand All @@ -176,22 +211,23 @@ def post(self):
mine_report_definition_id = None
permit_id = None

is_first_submission = False if mine_report_guid else True

create_initial_report = False if mine_report_guid else True
is_first_submission = False if mine_report_submission_guid else True

if is_code_required_report:
mine_report_definition_id = self.get_check_mine_report_definition_id(mine_report_definition_guid)
else:
permit_id = self.get_check_permit_id(permit_condition_category_code, permit_guid, mine_guid)

report_documents = ReportSubmissionResource.get_updated_documents(documents, is_proponent, mine_guid)

if is_first_submission:
if create_initial_report:
mine_report = self.create_initial_mine_report(data, permit_id, mine_report_definition_id)
mine_report_guid = mine_report.mine_report_guid
mine_report_id = mine_report.mine_report_id

# MS user only allowed to add documents
if is_proponent and not is_first_submission:
# MS user only allowed to add documents unless new report has been requested
if is_proponent and not create_initial_report:
return self.create_submission_from_minespace(mine_report_guid, data, report_documents)

create_timestamp = None
Expand Down Expand Up @@ -259,6 +295,11 @@ def get(self):

if (latest_submission == True):
submission = MineReportSubmission.find_latest_by_mine_report_guid(mine_report_guid)
if not submission:
report = MineReport.find_by_mine_report_guid(mine_report_guid)
# different names for same property
report.mine_report_submission_status_code = "NON"
return report
return submission

return MineReportSubmission.find_by_mine_report_guid(mine_report_guid)
1 change: 1 addition & 0 deletions services/core-api/app/api/mines/response_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,7 @@ def format(self, value):
fields.String,
'mine_report_contacts':
fields.List(fields.Nested(MINE_REPORT_CONTACT_MODEL)),
'mine_report_status_code': fields.String,
})

MINE_REPORT_DEFINITION_CATEGORIES = api.model('MineReportDefinitionCategoriesModel', {
Expand Down
2 changes: 1 addition & 1 deletion services/core-api/app/api/services/traction_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def revoke_credential(self,connection_id, rev_reg_id, cred_rev_id, comment):
"rev_reg_id":rev_reg_id,
"cred_rev_id":cred_rev_id,
"notify": True,
"publish": False
"publish": True
}
revoke_resp = requests.post(revoke_credential_url, json=payload,headers=self.get_headers())
assert revoke_resp.status_code == 200, f"revoke_resp={revoke_resp.json()}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ def post(self, party_guid: str):

traction_svc = TractionService()
revoke_resp = traction_svc.revoke_credential(party.active_digital_wallet_connection.connection_id,credential_exchange.rev_reg_id, credential_exchange.cred_rev_id, data["comment"])

current_app.logger.info(f"traction revocation response={revoke_resp}")
return revoke_resp
Loading

0 comments on commit 9c8ec9c

Please sign in to comment.