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

[CHORE] remove obsolete orgbook issuer #3295

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 44 additions & 70 deletions services/core-api/app/api/mines/namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
)
from app.api.mines.compliance.resources.compliance import MineComplianceSummaryResource
from app.api.mines.documents.resources.mine_document_bundle import (
MineDocumentBundleResource,
)
MineDocumentBundleResource, )
from app.api.mines.documents.resources.mine_document_resource import (
DocumentUploadStatusResource,
MineDocumentArchiveResource,
Expand All @@ -23,25 +22,20 @@
MineDocumentVersionUploadResource,
)
from app.api.mines.explosives_permit.resources.explosives_permit import (
ExplosivesPermitResource,
)
ExplosivesPermitResource, )
from app.api.mines.explosives_permit.resources.explosives_permit_document_type import (
ExplosivesPermitDocumentGenerateResource,
ExplosivesPermitDocumentTypeListResource,
ExplosivesPermitDocumentTypeResource,
)
from app.api.mines.explosives_permit.resources.explosives_permit_document_upload import (
ExplosivesPermitDocumentUploadResource,
)
ExplosivesPermitDocumentUploadResource, )
from app.api.mines.explosives_permit.resources.explosives_permit_list import (
ExplosivesPermitListResource,
)
ExplosivesPermitListResource, )
from app.api.mines.explosives_permit_amendment.resources.explosives_permit_amendment import (
ExplosivesPermitAmendmentResource,
)
ExplosivesPermitAmendmentResource, )
from app.api.mines.explosives_permit_amendment.resources.explosives_permit_amendment_list import (
ExplosivesPermitAmendmentListResource,
)
ExplosivesPermitAmendmentListResource, )
from app.api.mines.external_authorizations.resources.epic_resource import EPICResource
from app.api.mines.incidents.resources.mine_incident_document import (
MineIncidentDocumentListResource,
Expand All @@ -59,12 +53,10 @@
from app.api.mines.mine.resources.mine_basicinfo import MineBasicInfoResource
from app.api.mines.mine.resources.mine_commodity_code import MineCommodityCodeResource
from app.api.mines.mine.resources.mine_disturbance_code import (
MineDisturbanceCodeResource,
)
MineDisturbanceCodeResource, )
from app.api.mines.mine.resources.mine_map import MineMapResource
from app.api.mines.mine.resources.mine_tenure_type_code import (
MineTenureTypeCodeResource,
)
MineTenureTypeCodeResource, )
from app.api.mines.mine.resources.mine_type import (
MineTypeListResource,
MineTypeResource,
Expand All @@ -78,11 +70,9 @@
PermitResource,
)
from app.api.mines.permits.permit.resources.permit_document_upload import (
PermitDocumentUploadInitializationResource,
)
PermitDocumentUploadInitializationResource, )
from app.api.mines.permits.permit.resources.permit_status_code import (
PermitStatusCodeResource,
)
PermitStatusCodeResource, )
from app.api.mines.permits.permit_amendment.resources.permit_amendment import (
PermitAmendmentListResource,
PermitAmendmentResource,
Expand All @@ -91,53 +81,41 @@
PermitAmendmentDocumentListResource,
PermitAmendmentDocumentResource,
)
from app.api.mines.permits.permit_amendment.resources.permit_amendment_vc import (
PermitAmendmentVCResource,
)
from app.api.mines.permits.permit_conditions.resources.permit_condition_category_resource import (
PermitConditionCategoryResource,
)
PermitConditionCategoryResource, )
from app.api.mines.permits.permit_conditions.resources.permit_condition_type_resource import (
PermitConditionTypeResource,
)
PermitConditionTypeResource, )
from app.api.mines.permits.permit_conditions.resources.permit_conditions_resource import (
PermitConditionsListResource,
PermitConditionsResource,
)
from app.api.mines.permits.permit_conditions.resources.standard_permit_conditions_list_resource import (
StandardPermitConditionsListResource,
)
StandardPermitConditionsListResource, )
from app.api.mines.permits.permit_conditions.resources.standard_permit_conditions_resource import (
StandardPermitConditionsResource,
)
StandardPermitConditionsResource, )
from app.api.mines.permits.permit_extraction.resources.permit_condition_extraction_resource import (
PermitConditionExtractionProgressResource,
PermitConditionExtractionResource,
)
from app.api.mines.region.resources.region import MineRegionResource
from app.api.mines.reports.resources.mine_report_category import (
MineReportCategoryListResource,
)
MineReportCategoryListResource, )
from app.api.mines.reports.resources.mine_report_comment import (
MineReportCommentListResource,
MineReportCommentResource,
)
from app.api.mines.reports.resources.mine_report_definition import (
MineReportDefinitionListResource,
)
MineReportDefinitionListResource, )
from app.api.mines.reports.resources.mine_report_definition_compliance_article_xref_resource import (
MineReportDefinitionComplianceArticleCreateResource,
MineReportDefinitionComplianceArticleUpdateResource,
)
from app.api.mines.reports.resources.mine_report_document import (
MineReportDocumentListResource,
)
MineReportDocumentListResource, )
from app.api.mines.reports.resources.mine_report_submission_resource import (
ReportSubmissionResource,
)
ReportSubmissionResource, )
from app.api.mines.reports.resources.mine_report_submission_status import (
MineReportSubmissionStatusResource,
)
MineReportSubmissionStatusResource, )
from app.api.mines.reports.resources.mine_reports import (
MineReportListResource,
MineReportResource,
Expand All @@ -149,31 +127,23 @@
MineSubscriptionResource,
)
from app.api.mines.tailings.resources.tailings import (
MineTailingsStorageFacilityResource,
)
MineTailingsStorageFacilityResource, )
from app.api.mines.tailings.resources.tailings_list import (
MineTailingsStorageFacilityListResource,
)
MineTailingsStorageFacilityListResource, )
from app.api.mines.variances.resources.variance import MineVarianceResource
from app.api.mines.variances.resources.variance_document_upload import (
MineVarianceDocumentUploadResource,
)
MineVarianceDocumentUploadResource, )
from app.api.mines.variances.resources.variance_list import MineVarianceListResource
from app.api.mines.variances.resources.variance_uploaded_documents import (
MineVarianceUploadedDocumentsResource,
)
MineVarianceUploadedDocumentsResource, )
from app.api.mines.work_information.resources.work_information import (
MineWorkInformationResource,
)
MineWorkInformationResource, )
from app.api.mines.work_information.resources.work_information_list import (
MineWorkInformationListResource,
)
MineWorkInformationListResource, )
from app.api.notice_of_departure.resources.notice_of_departure_document import (
MineNoticeOfDepartureNewDocumentUploadResource,
)
MineNoticeOfDepartureNewDocumentUploadResource, )
from app.api.parties.party_appt.resources.mine_party_appt_document_upload_resource import (
MinePartyApptDocumentUploadResource,
)
MinePartyApptDocumentUploadResource, )
from flask_restx import Namespace

api = Namespace('mines', description='Mine related operations')
Expand All @@ -194,8 +164,10 @@
'/<string:mine_guid>/tailings/<string:mine_tailings_storage_facility_guid>')
api.add_resource(MineDocumentListResource, '/<string:mine_guid>/documents')
api.add_resource(MineDocumentArchiveResource, '/<string:mine_guid>/documents/archive')
api.add_resource(MineDocumentVersionUploadResource, '/<string:mine_guid>/documents/<string:mine_document_guid>/versions/upload')
api.add_resource(MineDocumentVersionListResource, '/<string:mine_guid>/documents/<string:mine_document_guid>/versions')
api.add_resource(MineDocumentVersionUploadResource,
'/<string:mine_guid>/documents/<string:mine_document_guid>/versions/upload')
api.add_resource(MineDocumentVersionListResource,
'/<string:mine_guid>/documents/<string:mine_document_guid>/versions')
api.add_resource(MineDocumentBundleResource, '/document-bundle/<string:mine_document_bundle_id>')

api.add_resource(ZipResource, '/<string:mine_guid>/documents/zip')
Expand Down Expand Up @@ -271,11 +243,8 @@
'/<string:mine_guid>/permits/<string:permit_guid>/amendments/<string:permit_amendment_guid>')

api.add_resource(PermitConditionExtractionResource, '/permits/condition-extraction')
api.add_resource(PermitConditionExtractionProgressResource, '/permits/condition-extraction/<string:task_id>')
api.add_resource(
PermitAmendmentVCResource,
'/<string:mine_guid>/permits/<string:permit_guid>/amendments/<string:permit_amendment_guid>/verifiable-credential'
)
api.add_resource(PermitConditionExtractionProgressResource,
'/permits/condition-extraction/<string:task_id>')

api.add_resource(
PermitAmendmentDocumentListResource,
Expand All @@ -300,8 +269,9 @@
'/<string:mine_guid>/permits/<string:permit_guid>/amendments/<string:permit_amendment_guid>/conditions/<string:permit_condition_guid>',
)

api.add_resource(ExplosivesPermitAmendmentResource,
'/<string:mine_guid>/explosives-permits-amendment/<string:explosives_permit_amendment_guid>')
api.add_resource(
ExplosivesPermitAmendmentResource,
'/<string:mine_guid>/explosives-permits-amendment/<string:explosives_permit_amendment_guid>')
api.add_resource(ExplosivesPermitAmendmentListResource,
'/<string:mine_guid>/explosives-permits-amendment')
api.add_resource(ExplosivesPermitResource,
Expand All @@ -324,12 +294,16 @@

api.add_resource(EPICResource, '/<string:mine_guid>/epic')

api.add_resource(MineNoticeOfDepartureNewDocumentUploadResource, '/<string:mine_guid>/notices-of-departure/documents')
api.add_resource(MineNoticeOfDepartureNewDocumentUploadResource,
'/<string:mine_guid>/notices-of-departure/documents')

api.add_resource(MineAlertListResource, '/<string:mine_guid>/alerts')
api.add_resource(MineAlertResource, '/<string:mine_guid>/alerts/<string:mine_alert_guid>')
api.add_resource(GlobalMineAlertListResource, '/global-alerts')

api.add_resource(MineReportDefinitionComplianceArticleCreateResource, '/reports/definitions/compliance-article')
api.add_resource(MineReportDefinitionComplianceArticleUpdateResource,
'/reports/definitions/compliance-article/<string:mine_report_definition_compliance_article_xref_guid>')
api.add_resource(MineReportDefinitionComplianceArticleCreateResource,
'/reports/definitions/compliance-article')
api.add_resource(
MineReportDefinitionComplianceArticleUpdateResource,
'/reports/definitions/compliance-article/<string:mine_report_definition_compliance_article_xref_guid>'
)

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,17 @@
from app.api.utils.resources_mixins import UserMixin
from app.api.now_applications.models.now_application_identity import NOWApplicationIdentity
from app.api.now_applications.models.now_application_status import NOWApplicationStatus
from app.api.now_applications.models.now_application_progress import NOWApplicationProgress
from app.api.now_applications.response_models import NOW_APPLICATION_STATUS_CODES
from app.api.mines.permits.permit.models.permit import Permit
from app.api.mines.permits.permit_amendment.models.permit_amendment import PermitAmendment
from app.api.mines.permits.permit_amendment.models.permit_amendment_document import PermitAmendmentDocument
from app.api.parties.party_appt.models.mine_party_appt import MinePartyAppointment
from app.api.constants import PERMIT_LINKED_CONTACT_TYPES
from app.api.services.issue_to_orgbook_service import OrgBookIssuerService
from app.api.mines.mine.models.mine_type import MineType
from app.api.mines.mine.models.mine_type_detail import MineTypeDetail


class NOWApplicationStatusCodeResource(Resource, UserMixin):

@api.doc(description='Get a list of all Notice of Work status codes.', params={})
@requires_role_view_all
@api.marshal_with(NOW_APPLICATION_STATUS_CODES, code=200, envelope='records')
Expand Down Expand Up @@ -304,21 +302,11 @@ def check_if_equal(list_1, list_2):

db.session.commit()

# Issue verifiable credential to OrgBook (currently, a non-blocking operation)
try:
OrgBookIssuerService().issue_permit_amendment_vc(permit_amendment)
except AssertionError as e:
current_app.logger.info('VC not issued due to unsuccessful status code')
current_app.logger.debug(str(e))
except Exception as ex:
current_app.logger.warning('VC not issued due to unknown error')
current_app.logger.info(str(ex))

# Handle rejected and withdrawn statuses
elif now_application_status_code in ['REJ', 'WDN', 'NPR']:
for progress in now_application_identity.now_application.application_progress:
if progress.end_date is None or (progress.end_date is not None and
progress.end_date > datetime.now(tz=timezone.utc)):
if progress.end_date is None or (progress.end_date is not None and progress.end_date
> datetime.now(tz=timezone.utc)):
progress.end_date = datetime.now(tz=timezone.utc)
for delay in now_application_identity.application_delays:
if delay.end_date is None or (delay.end_date is not None
Expand Down
Loading
Loading