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

Test marshal merge to test 12.0 #5528

Closed
wants to merge 91 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
2c6ee52
Added Print
Jan 8, 2025
b48ae22
Added Print
Jan 8, 2025
c66f561
Added Print
Jan 8, 2025
b707346
Added Print
Jan 8, 2025
dc108b6
Added Print
Jan 8, 2025
1380c39
Revert "Added Print"
Jan 8, 2025
1f6f4d4
Revert All Print update
Jan 8, 2025
c84f22f
Added Print
Jan 8, 2025
815dbc5
Update in Email parameter
Jan 8, 2025
3c46f0d
Added email address type validation
Jan 8, 2025
1112cae
Print email content
Jan 9, 2025
a46b5b5
Revert "Print email content"
Jan 9, 2025
db5e62d
Payment URL
Jan 9, 2025
0424f73
Revert "Payment URL"
Jan 9, 2025
0e12e22
Revert "Added email address type validation"
Jan 9, 2025
571a354
Revert "Update in Email parameter"
Jan 9, 2025
217a2c8
Cleanup Print
Jan 10, 2025
9d42c28
Sending email update
Jan 10, 2025
f5b4f7a
Revert "Sending email update"
Jan 10, 2025
a9261ca
Sending Email update
Jan 10, 2025
f827eef
Added Print
Jan 10, 2025
1323c97
Print
Jan 10, 2025
08b9d97
Revert "Sending Email update"
Jan 10, 2025
e6cdedb
Update email service
Jan 10, 2025
e1de10e
Print Debug
Jan 10, 2025
bd614c3
Print variableschema
Jan 10, 2025
833a399
Print Response
Jan 10, 2025
eaa492e
Revert Result
Jan 10, 2025
b8ec97d
Added Payment
Jan 10, 2025
3e77c3b
Revert "Added Payment"
Jan 10, 2025
d72f283
Cleanup Print
Jan 10, 2025
29c38b9
Test applicantcorrespondence
Jan 11, 2025
a81a08a
Sending Email
Jan 11, 2025
fb99c3d
Print Result
Jan 12, 2025
b92984c
Print Key
Jan 12, 2025
9e3660d
Print Version
Jan 12, 2025
c6c823a
Print Result
Jan 12, 2025
a29bbc7
Print Result
Jan 12, 2025
b8803a4
Print paymentexpirydate
Jan 12, 2025
8686659
Print applicantcorrespondencelog
Jan 12, 2025
0b9ab3e
Print Result
Jan 12, 2025
09c0ddf
Print Result
Jan 12, 2025
b50c4be
Test Email
Jan 12, 2025
291d5df
Print Logs
Jan 12, 2025
24a8e4f
Print
Jan 12, 2025
c74d7ca
Print
Jan 12, 2025
a9cc77d
Print
Jan 12, 2025
7339d5d
Print
Jan 12, 2025
8b5a30f
Print
Jan 12, 2025
a14c7a6
Print
Jan 12, 2025
793e224
Print
Jan 12, 2025
f883602
Print
Jan 13, 2025
da0bc47
Print
Jan 13, 2025
38b9c64
Print
Jan 13, 2025
089bf9f
Print
Jan 13, 2025
8abc01e
Cleanup
Jan 13, 2025
acb1ac5
Cleanup
Jan 13, 2025
37780be
Cleanup
Jan 13, 2025
21bffca
Print EmailRequest
Jan 13, 2025
45dcce0
Print Prev Code
Jan 13, 2025
ac90513
Print correspondence
Jan 13, 2025
e50916c
Print applicantcorrespondences data
Jan 13, 2025
4a5331d
Print correspondencelogs
Jan 13, 2025
88389c2
Print applicantcorrespondence
Jan 13, 2025
3ba7608
Print applicantcorrespondence
Jan 13, 2025
07d317e
Update operatingteamemails
milosdes Jan 13, 2025
f6cd70e
Print Email Workflow
Jan 13, 2025
953db5d
Test Email Sender
Jan 13, 2025
18a1925
Cleanup Print
Jan 13, 2025
96d6e30
Revert Test-Marshal
Jan 14, 2025
1b0b075
Revert to original
Jan 14, 2025
7c9dd00
FOIMOD-3450 - Fix issue on Autoemail, Duplicate Correspondence and Pa…
Jan 14, 2025
f89190e
FOIMOD-3450 update code based on review
Jan 14, 2025
c78bfa1
Merge pull request #5517 from bcgov/test-marshal-JC-FOIMOD-3450-1
jocelyncabildo-aot Jan 14, 2025
73977f7
Print requestid
Jan 14, 2025
cad7bcb
Revert "Print requestid"
Jan 14, 2025
7746029
Test Email
Jan 14, 2025
3be4dbc
Merge pull request #5515 from bcgov/test-marshal-MD-3161
milosdes Jan 14, 2025
e97d853
Update endpoints to handle raw requests accurately
milosdes Jan 15, 2025
d1eedf7
Change variable name
milosdes Jan 15, 2025
d5eebfb
Merge pull request #5524 from bcgov/test-marshal-MD-correspondenceupdate
milosdes Jan 15, 2025
0e4427a
Fix error handling issue
milosdes Jan 15, 2025
2da801a
Merge pull request #5525 from bcgov/test-marshal-MD-correspondenceupdate
milosdes Jan 15, 2025
7e136d1
Revert "Merge pull request #5525 from bcgov/test-marshal-MD-correspon…
Jan 15, 2025
5d70a0f
Print cfrfee
Jan 15, 2025
30f5277
Revert "Print cfrfee"
Jan 15, 2025
00d5957
Print url_params_dict
Jan 15, 2025
611ce0e
Print request_json
Jan 15, 2025
5c08905
Revert "Print url_params_dict"
Jan 15, 2025
f8ab00f
Revert "Print request_json"
Jan 15, 2025
594d88d
Update ApplicantCorrespondence Result
Jan 16, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def upgrade():

op.execute('''INSERT INTO public."OperatingTeamEmails" (teamid, email_address)
VALUES
((SELECT teamid FROM public."OperatingTeams" WHERE name = 'Central and Economy Team'), 'IAOCentralTeam@gov.bc.ca'),
((SELECT teamid FROM public."OperatingTeams" WHERE name = 'Community and Health Team'), 'FOI.SocialEducationTeam@gov.bc.ca'),
((SELECT teamid FROM public."OperatingTeams" WHERE name = 'Central and Economy Team'), 'IAO.CentralAndEconomyTeam@gov.bc.ca'),
((SELECT teamid FROM public."OperatingTeams" WHERE name = 'Community and Health Team'), 'IAO.CommunityandHealthTeam@gov.bc.ca'),
((SELECT teamid FROM public."OperatingTeams" WHERE name = 'Resource and Justice Team'), '[email protected]'),
((SELECT teamid FROM public."OperatingTeams" WHERE name = 'Children and Family Team'), '[email protected]'),
((SELECT teamid FROM public."OperatingTeams" WHERE name = 'Children and Education Team'), '[email protected]'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,7 @@ def getapplicantcorrespondencesrawrequests(cls, requestid):
created_at, createdby, sentcorrespondencemessage, parentapplicantcorrespondenceid, sentby, sent_at,
isdraft, isdeleted, isresponse, response_at, israwrequest
from "FOIApplicantCorrespondencesRawRequests" rawcorr
where foirawrequest_id = (
SELECT foirawrequestid FROM public."FOIRequests"
WHERE foirequestid = :requestid
ORDER BY foirequestid ASC, version DESC limit 1)
OR
where
foirawrequest_id = :requestid
order by applicantcorrespondenceid desc, version desc"""
rs = db.session.execute(text(sql), {'requestid': requestid})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ class FOIFlowApplicantCorrespondence(Resource):
@auth.hasusertype('iao')
def get(requestid, ministryrequestid):
try:
rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid)
if ministryrequestid == 'None':
rawrequestid = requestid
else:
rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid)
correspondencelogs = applicantcorrespondenceservice().getapplicantcorrespondencelogs(ministryrequestid, rawrequestid)
return json.dumps(correspondencelogs) , 200
except BusinessException:
Expand All @@ -90,13 +93,15 @@ def get(requestid, ministryrequestid):
def post(requestid, ministryrequestid):
try:
requestjson = request.get_json()
applicantcorrespondencelog = FOIApplicantCorrespondenceSchema().load(data=requestjson)
rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid)
result = communicationwrapperservice().send_email(rawrequestid, ministryrequestid, applicantcorrespondencelog)
return {'status': result.success, 'message':result.message,'id':result.identifier} , 200
applicantcorrespondencelog = FOIApplicantCorrespondenceSchema().load(data=requestjson)
if ministryrequestid == 'None':
rawrequestid = requestid
else:
rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid)
result = communicationwrapperservice().send_email(requestid, rawrequestid, ministryrequestid, applicantcorrespondencelog)
return {'status': result['success'], 'message': result['message'], 'id': result['identifier']}, 200
except BusinessException:
return "Error happened while saving applicant correspondence log" , 500

return "Error happened while saving applicant correspondence log", 500


@cors_preflight('POST,OPTIONS')
Expand All @@ -111,7 +116,10 @@ def post(requestid, ministryrequestid):
try:
requestjson = request.get_json()
correspondenceschemaobj = FOIApplicantCorrespondenceSchema().load(data=requestjson)
rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid)
if ministryrequestid == 'None':
rawrequestid = requestid
else:
rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid)
if ministryrequestid != 'None' or "israwrequest" in correspondenceschemaobj and correspondenceschemaobj["israwrequest"] == False:
result = applicantcorrespondenceservice().saveapplicantcorrespondencelog(rawrequestid, ministryrequestid, correspondenceschemaobj, AuthHelper.getuserid(), True)
elif ministryrequestid == 'None' or "israwrequest" in correspondenceschemaobj and correspondenceschemaobj["israwrequest"] == True:
Expand All @@ -132,7 +140,10 @@ class FOIFlowApplicantCorrespondenceDraft(Resource):
def post(requestid, ministryrequestid):
try:
requestjson = request.get_json()
rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid)
if ministryrequestid == 'None':
rawrequestid = requestid
else:
rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid)
applicantcorrespondencelog = FOIApplicantCorrespondenceSchema().load(data=requestjson)
if ministryrequestid == 'None' or "israwrequest" in applicantcorrespondencelog and applicantcorrespondencelog["israwrequest"] == True:
result = applicantcorrespondenceservice().saveapplicantcorrespondencelogforrawrequest(rawrequestid, applicantcorrespondencelog, AuthHelper.getuserid(), True)
Expand All @@ -154,12 +165,15 @@ class FOIFlowApplicantCorrespondenceDraft(Resource):
def post(ministryrequestid, rawrequestid, correspondenceid):
try:
requestjson = request.get_json()
rawrequestidfromfoirequest = requestservice().getrawrequestidbyfoirequestid(rawrequestid)
if ministryrequestid == 'None':
rawrequestidforrequest = rawrequestid
else:
rawrequestidforrequest = requestservice().getrawrequestidbyfoirequestid(rawrequestid)
if ministryrequestid == 'None' or "israwrequest" in requestjson and requestjson["israwrequest"] == True:
rawresult = applicantcorrespondenceservice().deleteapplicantcorrespondencelograwrequest(rawrequestidfromfoirequest, correspondenceid, AuthHelper.getuserid())
rawresult = applicantcorrespondenceservice().deleteapplicantcorrespondencelograwrequest(rawrequestidforrequest, correspondenceid, AuthHelper.getuserid())
return {'status': rawresult.success, 'message':rawresult.message,'id':rawresult.identifier} , 200
else:
rawresult = applicantcorrespondenceservice().deleteapplicantcorrespondencelograwrequest(rawrequestidfromfoirequest, correspondenceid, AuthHelper.getuserid())
rawresult = applicantcorrespondenceservice().deleteapplicantcorrespondencelograwrequest(rawrequestidforrequest, correspondenceid, AuthHelper.getuserid())
ministryresult = applicantcorrespondenceservice().deleteapplicantcorrespondencelogministry(ministryrequestid, correspondenceid, AuthHelper.getuserid())
if rawresult.success == True and ministryresult.success == True:
return {'status': ministryresult.success, 'message':ministryresult.message,'id':ministryresult.identifier} , 200
Expand All @@ -178,9 +192,12 @@ class FOIFlowApplicantCorrespondenceEmail(Resource):
def post(ministryrequestid, rawrequestid):
try:
requestjson = request.get_json()
rawrequestidfromfoirequest = requestservice().getrawrequestidbyfoirequestid(rawrequestid)
if ministryrequestid == 'None':
rawrequestidforrequest = rawrequestid
else:
rawrequestidforrequest = requestservice().getrawrequestidbyfoirequestid(rawrequestid)
correspondenceemail = FOIApplicantCorrespondenceEmailSchema().load(data=requestjson)
result = correspondenceemailservice().savecorrespondenceemail(ministryrequestid, rawrequestidfromfoirequest, correspondenceemail, AuthHelper.getuserid())
result = correspondenceemailservice().savecorrespondenceemail(ministryrequestid, rawrequestidforrequest, correspondenceemail, AuthHelper.getuserid())

return {'status': result.success, 'message':result.message,'id':result.identifier} , 200
except BusinessException:
Expand All @@ -192,8 +209,11 @@ def post(ministryrequestid, rawrequestid):
@auth.require
def get(ministryrequestid, rawrequestid):
try:
rawrequestidfromfoirequest = requestservice().getrawrequestidbyfoirequestid(rawrequestid)
correspondenceemails = correspondenceemailservice().getcorrespondenceemails(ministryrequestid, rawrequestidfromfoirequest)
if ministryrequestid == 'None':
rawrequestidforrequest = rawrequestid
else:
rawrequestidforrequest = requestservice().getrawrequestidbyfoirequestid(rawrequestid)
correspondenceemails = correspondenceemailservice().getcorrespondenceemails(ministryrequestid, rawrequestidforrequest)
return json.dumps(correspondenceemails) , 200
except BusinessException:
return "Unable to retrieve correspondence emails" , 500
Expand All @@ -209,12 +229,15 @@ class FOIFlowApplicantCorrespondenceResponse(Resource):
def post(ministryrequestid, rawrequestid):
try:
requestjson = request.get_json()
rawrequestidfromfoirequest = requestservice().getrawrequestidbyfoirequestid(rawrequestid)
if ministryrequestid == 'None':
rawrequestidforrequest = rawrequestid
else:
rawrequestidforrequest = requestservice().getrawrequestidbyfoirequestid(rawrequestid)
correspondenceemail = FOIApplicantCorrespondenceResponseSchema().load(data=requestjson)
if ministryrequestid == 'None' or 'israwrequest' in requestjson and requestjson['israwrequest'] == True:
result = applicantcorrespondenceservice().saveapplicantcorrespondencelogforrawrequest(rawrequestidfromfoirequest, correspondenceemail, AuthHelper.getuserid())
result = applicantcorrespondenceservice().saveapplicantcorrespondencelogforrawrequest(rawrequestidforrequest, correspondenceemail, AuthHelper.getuserid())
else:
result = applicantcorrespondenceservice().saveapplicantcorrespondencelog(rawrequestidfromfoirequest, ministryrequestid, correspondenceemail, AuthHelper.getuserid())
result = applicantcorrespondenceservice().saveapplicantcorrespondencelog(rawrequestidforrequest, ministryrequestid, correspondenceemail, AuthHelper.getuserid())

return {'status': result.success, 'message':result.message,'id':result.identifier} , 200
except BusinessException:
Expand All @@ -231,11 +254,14 @@ class FOIFlowApplicantCorrespondenceEditResponse(Resource):
@auth.require
def post(ministryrequestid, rawrequestid):
try:
rawrequestidfromfoirequest = requestservice().getrawrequestidbyfoirequestid(rawrequestid)
if ministryrequestid == 'None':
rawrequestidforrequest = rawrequestid
else:
rawrequestidforrequest = requestservice().getrawrequestidbyfoirequestid(rawrequestid)
requestjson = request.get_json()
correspondenceemail = FOIApplicantCorrespondenceEditResponseSchema().load(data=requestjson)
if ministryrequestid == 'None' or 'israwrequest' in requestjson and requestjson['israwrequest'] == True:
result = applicantcorrespondenceservice().editapplicantcorrespondencelogforrawrequest(rawrequestidfromfoirequest, correspondenceemail, AuthHelper.getuserid())
result = applicantcorrespondenceservice().editapplicantcorrespondencelogforrawrequest(rawrequestidforrequest, correspondenceemail, AuthHelper.getuserid())
elif ministryrequestid != 'None' or 'israwrequest' in requestjson and requestjson['israwrequest'] == False:
result = applicantcorrespondenceservice().editapplicantcorrespondencelogforministry(ministryrequestid, correspondenceemail, AuthHelper.getuserid())

Expand All @@ -254,12 +280,15 @@ class FOIFlowApplicantCorrespondenceResponse(Resource):
def post(ministryrequestid, rawrequestid, correspondenceid):
try:
requestjson = request.get_json()
rawrequestidfromfoirequest = requestservice().getrawrequestidbyfoirequestid(rawrequestid)
if ministryrequestid == 'None':
rawrequestidforrequest = rawrequestid
else:
rawrequestidforrequest = requestservice().getrawrequestidbyfoirequestid(rawrequestid)
if ministryrequestid == 'None' or 'israwrequest' in requestjson and requestjson['israwrequest'] == True:
rawresult = applicantcorrespondenceservice().deleteapplicantcorrespondencelograwrequest(rawrequestidfromfoirequest, correspondenceid, AuthHelper.getuserid())
rawresult = applicantcorrespondenceservice().deleteapplicantcorrespondencelograwrequest(rawrequestidforrequest, correspondenceid, AuthHelper.getuserid())
return {'status': rawresult.success, 'message':rawresult.message,'id':rawresult.identifier} , 200
else:
rawresult = applicantcorrespondenceservice().deleteapplicantcorrespondencelograwrequest(rawrequestidfromfoirequest, correspondenceid, AuthHelper.getuserid())
rawresult = applicantcorrespondenceservice().deleteapplicantcorrespondencelograwrequest(rawrequestidforrequest, correspondenceid, AuthHelper.getuserid())
ministryresult = applicantcorrespondenceservice().deleteapplicantcorrespondencelogministry(ministryrequestid, correspondenceid, AuthHelper.getuserid())
if rawresult.success == True and ministryresult.success == True:
return {'status': ministryresult.success, 'message':ministryresult.message,'id':ministryresult.identifier} , 200
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ def gettemplatebyid(self, templateid):
""" Returns the active applicant correspondence templates
"""
return ApplicationCorrespondenceTemplate.get_template_by_id(templateid)



def getapplicantcorrespondencelogs(self,ministryrequestid, rawrequestid):
""" Returns the active applicant correspondence logs
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,43 +16,44 @@

class communicationwrapperservice:
""" FOI communication wrapper service

"""

def send_email(self,requestid, ministryrequestid, applicantcorrespondencelog):

def send_email(self, requestid, rawrequestid, ministryrequestid, applicantcorrespondencelog):
# Save correspondence log based on request type
if ministryrequestid == 'None' or ministryrequestid is None or ("israwrequest" in applicantcorrespondencelog and applicantcorrespondencelog["israwrequest"]) is True:
result = applicantcorrespondenceservice().saveapplicantcorrespondencelogforrawrequest(requestid, applicantcorrespondencelog, AuthHelper.getuserid())
result = applicantcorrespondenceservice().saveapplicantcorrespondencelogforrawrequest(rawrequestid, applicantcorrespondencelog, AuthHelper.getuserid())
else:
result = applicantcorrespondenceservice().saveapplicantcorrespondencelog(requestid, ministryrequestid, applicantcorrespondencelog, AuthHelper.getuserid())

if result.success == True:
# raw requests should never be fee emails so they would only get handled by else statement
if self.__is_fee_processing(applicantcorrespondencelog["templateid"]) == True:
return self.__handle_fee_email(requestid, ministryrequestid, applicantcorrespondencelog)
# Handle fee processing templates
if self.__is_fee_processing(applicantcorrespondencelog["templateid"]):
return self.__handle_fee_email(requestid, ministryrequestid, result, applicantcorrespondencelog)
# Handle non-fee templates - Send email for non-fee templates with email recipients
else:
if "emails" in applicantcorrespondencelog and len(applicantcorrespondencelog["emails"]) > 0:
template = applicantcorrespondenceservice().gettemplatebyid(applicantcorrespondencelog["templateid"])
return communicationemailservice().send(template, applicantcorrespondencelog)
return result





def __handle_fee_email(self,requestid, ministryrequestid, applicantcorrespondencelog):
if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != None:
def __handle_fee_email(self, requestid, ministryrequestid, result, applicantcorrespondencelog):
if cfrfeeservice().getactivepayment(requestid, ministryrequestid) is not None:
requestservice().postfeeeventtoworkflow(requestid, ministryrequestid, "CANCELLED")
_attributes = applicantcorrespondencelog["attributes"][0] if "attributes" in applicantcorrespondencelog else None
_paymentexpirydate = _attributes["paymentExpiryDate"] if _attributes is not None and "paymentExpiryDate" in _attributes else None
if _paymentexpirydate not in (None, ""):
paymentservice().createpayment(requestid, ministryrequestid, _attributes, AuthHelper.getuserid())
return requestservice().postcorrespondenceeventtoworkflow(requestid, ministryrequestid, result.identifier, applicantcorrespondencelog['attributes'], applicantcorrespondencelog['templateid'])
_attributes = applicantcorrespondencelog["attributes"][0] if "attributes" in applicantcorrespondencelog else None
_paymentexpirydate = _attributes["paymentExpiryDate"] if _attributes is not None and "paymentExpiryDate" in _attributes else None
if _paymentexpirydate not in (None, ""):
paymentservice().createpayment(requestid, ministryrequestid, _attributes, AuthHelper.getuserid())
requestservice().postcorrespondenceeventtoworkflow(requestid, ministryrequestid, result.identifier, applicantcorrespondencelog['attributes'], applicantcorrespondencelog['templateid'])
return {"success" : True, "message": "Sent successfully", "identifier": -1}


def __is_fee_processing(self, templateid):
if applicantcorrespondenceservice().gettemplatebyid(templateid) in ['PAYONLINE','PAYOUTSTANDING']:
if applicantcorrespondenceservice().gettemplatebyid(templateid).name in ['PAYONLINE','PAYOUTSTANDING']:
return True
return False

class CommuniationType(Enum):
"""Communication types."""
FEE_PROCESSING = 'FEE_PROCESSING'
GENERAL = 'GENERAL'
GENERAL = 'GENERAL'
Loading
Loading