-
Notifications
You must be signed in to change notification settings - Fork 38
Issue permits as vc with mdt #1634
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
Changes from 46 commits
ee7aa78
03ab7a8
eae7068
33e847b
5ca44bf
f8a9bd0
71bd131
a94a773
d3a3a35
71b76a3
010127e
a17bfb2
0fe7792
bc7c8be
2bcc281
9eab05b
15568b7
c0dcc8c
423a687
7e6c8cb
681fea5
42db885
a199aff
48269a4
667b2b2
c06ba70
329a23c
1aa67f5
e42c5f8
8d8720b
0711f68
da9208f
5be8d8d
8caecdc
4ea2e34
76f7662
13353d7
ff1c65b
46ed333
adee719
462fc45
d49781a
8e09bc6
603a203
b1c3427
6aa0b5f
ea3fb2c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from datetime import datetime | ||
from flask import request, current_app | ||
from flask_restplus import Resource, reqparse | ||
from werkzeug.exceptions import BadRequest | ||
|
||
from app.api.mines.permits.permit_amendment.models.permit_amendment import PermitAmendment | ||
|
||
from app.extensions import api | ||
from app.api.utils.access_decorators import requires_role_mine_admin | ||
from app.api.utils.resources_mixins import UserMixin | ||
|
||
from app.api.services.issue_to_orgbook_service import OrgBookIssuerService | ||
|
||
|
||
class PermitAmendmentVCResource(Resource, UserMixin): | ||
@requires_role_mine_admin | ||
@api.response(200, "VC Issued to OrgBook, no local data created") | ||
def post(self, mine_guid, permit_guid, permit_amendment_guid): | ||
permit_amendment = PermitAmendment.find_by_permit_amendment_guid(permit_amendment_guid) | ||
|
||
response = OrgBookIssuerService().issue_permit_amendment_vc(permit_amendment) | ||
if not response: | ||
raise BadRequest( | ||
"Credential Not Issued, ensure permittee is associated with OrgBook Entity") | ||
return |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,8 @@ | |
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.services.issue_to_orgbook_service import OrgBookIssuerService | ||
from werkzeug.exceptions import BadRequest, NotFound, NotImplemented | ||
|
||
|
||
|
@@ -141,6 +143,17 @@ def put(self, application_guid): | |
|
||
permit_amendment.save() | ||
|
||
#Issue Permit as Verifiable Credential to OrgBook | ||
try: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should any possible exceptions be blocking? Do we just want to log the messages? |
||
OrgBookIssuerService().issue_permit_amendment_vc(permit_amendment) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to check the return value of this here, i.e. the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't want this code to effect this method at all. I could be talked into not modifying this at all. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Up to you guys on this one. |
||
except AssertionError as e: | ||
#non-blocking failure | ||
current_app.logger.info('VC Not issued due to non-200 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(e)) | ||
|
||
#create contacts | ||
for contact in now_application_identity.now_application.contacts: | ||
if contact.mine_party_appt_type_code == 'PMT' or contact.mine_party_appt_type_code == 'MMG': | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this better, thanks