From 2c6ee5236158c222c7dd08d9bc3fe11a15673ba2 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Wed, 8 Jan 2025 10:52:19 -0800 Subject: [PATCH 01/87] Added Print --- .../request_api/services/external/camundaservice.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/request-management-api/request_api/services/external/camundaservice.py b/request-management-api/request_api/services/external/camundaservice.py index be25070ac..441ce0600 100644 --- a/request-management-api/request_api/services/external/camundaservice.py +++ b/request-management-api/request_api/services/external/camundaservice.py @@ -19,15 +19,21 @@ class camundaservice: def _getserviceaccounttoken_(self): + print("selfbpmtokenurl", self.bpmtokenurl) + print("selfbpmclientid", self.bpmclientid) + print("selfbpmclientsecret", self.bpmclientsecret) auth_response = requests.post(self.bpmtokenurl, auth=(self.bpmclientid, self.bpmclientsecret), headers={ 'Content-Type': 'application/x-www-form-urlencoded'}, data='grant_type=client_credentials') return auth_response.json().get('access_token') def _getheaders_(self, token): + print("tokenbefore", token) """Generate headers.""" if token is None: + print("tokenNone", token) token = self._getserviceaccounttoken_(); + print("tokenAfter", token) return { "Authorization": "Bearer " + token, "Content-Type": "application/json", From b48ae22d817e3779a61c43ef42cf4ee2d740ce7e Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Wed, 8 Jan 2025 11:09:15 -0800 Subject: [PATCH 02/87] Added Print --- .../request_api/services/external/bpmservice.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/request-management-api/request_api/services/external/bpmservice.py b/request-management-api/request_api/services/external/bpmservice.py index 1ef074eb0..563e750d9 100644 --- a/request-management-api/request_api/services/external/bpmservice.py +++ b/request-management-api/request_api/services/external/bpmservice.py @@ -167,9 +167,12 @@ def _getserviceaccounttoken_(self): return auth_response.json().get('access_token') def _getHeaders_(self, token): + print("bpmtoken", token) """Generate headers.""" if token is None: + print("bpmtoken1", token) token = self._getserviceaccounttoken_(); + print("bpmtoken2", token) return { "Authorization": "Bearer " + token, "Content-Type": "application/json", From c66f561c0b644eaff80db8f9b639a7b390620ca9 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Wed, 8 Jan 2025 11:31:59 -0800 Subject: [PATCH 03/87] Added Print --- .../request_api/services/external/bpmservice.py | 11 +++++++---- .../request_api/services/external/camundaservice.py | 12 ++++++------ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/request-management-api/request_api/services/external/bpmservice.py b/request-management-api/request_api/services/external/bpmservice.py index 563e750d9..ff955751f 100644 --- a/request-management-api/request_api/services/external/bpmservice.py +++ b/request-management-api/request_api/services/external/bpmservice.py @@ -162,17 +162,20 @@ def _geProcessDefinitionKey_(self, messagequeue): return None def _getserviceaccounttoken_(self): + print("Bselfbpmtokenurl", self.bpmtokenurl) + print("Bselfbpmclientid", self.bpmclientid) + print("Bselfbpmclientsecret", self.bpmclientsecret) auth_response = requests.post(self.bpmtokenurl, auth=(self.bpmclientid, self.bpmclientsecret), headers={ 'Content-Type': 'application/x-www-form-urlencoded'}, data='grant_type=client_credentials') return auth_response.json().get('access_token') def _getHeaders_(self, token): - print("bpmtoken", token) + print("Bpmtoken", token) """Generate headers.""" if token is None: - print("bpmtoken1", token) - token = self._getserviceaccounttoken_(); - print("bpmtoken2", token) + print("Bpmtoken1", token) + token = self._getserviceaccounttoken_() + print("Bpmtoken2", token) return { "Authorization": "Bearer " + token, "Content-Type": "application/json", diff --git a/request-management-api/request_api/services/external/camundaservice.py b/request-management-api/request_api/services/external/camundaservice.py index 441ce0600..8239a640e 100644 --- a/request-management-api/request_api/services/external/camundaservice.py +++ b/request-management-api/request_api/services/external/camundaservice.py @@ -19,21 +19,21 @@ class camundaservice: def _getserviceaccounttoken_(self): - print("selfbpmtokenurl", self.bpmtokenurl) - print("selfbpmclientid", self.bpmclientid) - print("selfbpmclientsecret", self.bpmclientsecret) + print("Cselfbpmtokenurl", self.bpmtokenurl) + print("Cselfbpmclientid", self.bpmclientid) + print("Cselfbpmclientsecret", self.bpmclientsecret) auth_response = requests.post(self.bpmtokenurl, auth=(self.bpmclientid, self.bpmclientsecret), headers={ 'Content-Type': 'application/x-www-form-urlencoded'}, data='grant_type=client_credentials') return auth_response.json().get('access_token') def _getheaders_(self, token): - print("tokenbefore", token) + print("Ctokenbefore", token) """Generate headers.""" if token is None: - print("tokenNone", token) + print("CtokenNone", token) token = self._getserviceaccounttoken_(); - print("tokenAfter", token) + print("CtokenAfter", token) return { "Authorization": "Bearer " + token, "Content-Type": "application/json", From b70734666c4271e577e31fc7c1a0b6c865c4e530 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Wed, 8 Jan 2025 13:28:08 -0800 Subject: [PATCH 04/87] Added Print --- .../request_api/services/external/bpmservice.py | 3 +++ .../request_api/services/workflowservice.py | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/request-management-api/request_api/services/external/bpmservice.py b/request-management-api/request_api/services/external/bpmservice.py index ff955751f..40dfd2b1d 100644 --- a/request-management-api/request_api/services/external/bpmservice.py +++ b/request-management-api/request_api/services/external/bpmservice.py @@ -23,6 +23,7 @@ def createinstance(self, messagequeue, message, token=None): _variables["variables"][key] = {"type" : _variabletype, "value": message[key]} variableschema = VariableMessageSchema().dump(_variables) createresponce = requests.post(self._getUrl_(None,self._geProcessDefinitionKey_(messagequeue)), data=json.dumps(variableschema), headers = self._getHeaders_(token)) + print("createresponce", createresponce) if createresponce.ok: _createresponce = json.loads(createresponce.content) return _createresponce["id"] @@ -151,8 +152,10 @@ def __post_message(self, messagetype, messageschema, token=None): def _getUrl_(self, messagetype, definitionkey=None): if messagetype is not None: + print("messagetype", messagetype) return self.bpmengineresturl+"/message" elif definitionkey is not None: + print("definitionkey", definitionkey) return self.bpmengineresturl+"/process-definition/key/"+definitionkey+"/start" return self.bpmengineresturl diff --git a/request-management-api/request_api/services/workflowservice.py b/request-management-api/request_api/services/workflowservice.py index 1cbcbb1db..17e05ee36 100644 --- a/request-management-api/request_api/services/workflowservice.py +++ b/request-management-api/request_api/services/workflowservice.py @@ -101,7 +101,9 @@ def syncwfinstance(self, requesttype, requestid, isallactivity=False): try: # Sync and get raw instance details from FOI DB raw_metadata = self.__sync_raw_request(requesttype, requestid) + print("raw_metadata", raw_metadata) if requesttype == "ministryrequest": + print("ministryrequest", "ministryrequest") req_metadata = self.__sync_foi_request(requestid, raw_metadata) # Check foi request instance creation - Reconcile by transition to Open _all_activity_desc = FOIMinistryRequest.getactivitybyid(requestid) @@ -109,21 +111,28 @@ def syncwfinstance(self, requesttype, requestid, isallactivity=False): return req_metadata.wfinstanceid return raw_metadata.wfinstanceid except Exception as ex: + print("exLOGS", ex) logging.error(ex) return None def __sync_raw_request(self, requesttype, requestid): # Search for WF ID requestid = int(requestid) + print("requesttype", requesttype) _raw_metadata = FOIRawRequest.getworkflowinstancebyraw(requestid) if requesttype == "rawrequest" else FOIRawRequest.getworkflowinstancebyministry(requestid) + print("_raw_metadata", _raw_metadata) wf_rawrequest_pid = self.__get_wf_pid("rawrequest", _raw_metadata) + print("wf_rawrequest_pid", wf_rawrequest_pid) # Check for exists - Reconcile with new instance creation if wf_rawrequest_pid not in (None, "") and _raw_metadata.wfinstanceid not in (None, "") and str(_raw_metadata.wfinstanceid) == wf_rawrequest_pid: + print("wf_rawrequest_pidNotNone", wf_rawrequest_pid) return _raw_metadata # WF Instance is not present if wf_rawrequest_pid in (None, ""): + print("wf_rawrequest_pidNone", wf_rawrequest_pid) self.createinstance(RedisPublisherService().foirequestqueueredischannel, json.dumps(self.__prepare_raw_requestobj(_raw_metadata))) else: + print("wf_rawrequest_pidElse", wf_rawrequest_pid) if _raw_metadata.wfinstanceid in (None, "") or str(_raw_metadata.wfinstanceid) != wf_rawrequest_pid: FOIRawRequest.updateworkflowinstance_n(wf_rawrequest_pid, int(_raw_metadata.requestid), "System") return FOIRawRequest.getworkflowinstancebyraw(requestid) if requesttype == "rawrequest" else FOIRawRequest.getworkflowinstancebyministry(requestid) From dc108b6217b8a7f7753898baad61a56ec81ef1f6 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Wed, 8 Jan 2025 14:00:39 -0800 Subject: [PATCH 05/87] Added Print --- .../request_api/services/external/bpmservice.py | 3 --- .../request_api/services/workflowservice.py | 12 ++++++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/request-management-api/request_api/services/external/bpmservice.py b/request-management-api/request_api/services/external/bpmservice.py index 40dfd2b1d..d228b5a24 100644 --- a/request-management-api/request_api/services/external/bpmservice.py +++ b/request-management-api/request_api/services/external/bpmservice.py @@ -173,12 +173,9 @@ def _getserviceaccounttoken_(self): return auth_response.json().get('access_token') def _getHeaders_(self, token): - print("Bpmtoken", token) """Generate headers.""" if token is None: - print("Bpmtoken1", token) token = self._getserviceaccounttoken_() - print("Bpmtoken2", token) return { "Authorization": "Bearer " + token, "Content-Type": "application/json", diff --git a/request-management-api/request_api/services/workflowservice.py b/request-management-api/request_api/services/workflowservice.py index 17e05ee36..adacfa27a 100644 --- a/request-management-api/request_api/services/workflowservice.py +++ b/request-management-api/request_api/services/workflowservice.py @@ -101,17 +101,18 @@ def syncwfinstance(self, requesttype, requestid, isallactivity=False): try: # Sync and get raw instance details from FOI DB raw_metadata = self.__sync_raw_request(requesttype, requestid) - print("raw_metadata", raw_metadata) + print("raw_metadata", "raw_metadata") if requesttype == "ministryrequest": - print("ministryrequest", "ministryrequest") - req_metadata = self.__sync_foi_request(requestid, raw_metadata) + print("requesttype", requesttype) + req_metadata = self.__sync_foi_request(requestid, raw_metadata) + print("req_metadata", req_metadata) # Check foi request instance creation - Reconcile by transition to Open - _all_activity_desc = FOIMinistryRequest.getactivitybyid(requestid) + _all_activity_desc = FOIMinistryRequest.getactivitybyid(requestid) + print("_all_activity_desc", _all_activity_desc) self.__sync_state_transition(requestid, str(req_metadata.wfinstanceid), _all_activity_desc, isallactivity) return req_metadata.wfinstanceid return raw_metadata.wfinstanceid except Exception as ex: - print("exLOGS", ex) logging.error(ex) return None @@ -120,7 +121,6 @@ def __sync_raw_request(self, requesttype, requestid): requestid = int(requestid) print("requesttype", requesttype) _raw_metadata = FOIRawRequest.getworkflowinstancebyraw(requestid) if requesttype == "rawrequest" else FOIRawRequest.getworkflowinstancebyministry(requestid) - print("_raw_metadata", _raw_metadata) wf_rawrequest_pid = self.__get_wf_pid("rawrequest", _raw_metadata) print("wf_rawrequest_pid", wf_rawrequest_pid) # Check for exists - Reconcile with new instance creation From 1380c398d8d48103d11a333e3b747517b6d0e14b Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Wed, 8 Jan 2025 14:33:19 -0800 Subject: [PATCH 06/87] Revert "Added Print" This reverts commit dc108b6217b8a7f7753898baad61a56ec81ef1f6. --- .../request_api/services/external/bpmservice.py | 3 +++ .../request_api/services/workflowservice.py | 12 ++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/request-management-api/request_api/services/external/bpmservice.py b/request-management-api/request_api/services/external/bpmservice.py index d228b5a24..40dfd2b1d 100644 --- a/request-management-api/request_api/services/external/bpmservice.py +++ b/request-management-api/request_api/services/external/bpmservice.py @@ -173,9 +173,12 @@ def _getserviceaccounttoken_(self): return auth_response.json().get('access_token') def _getHeaders_(self, token): + print("Bpmtoken", token) """Generate headers.""" if token is None: + print("Bpmtoken1", token) token = self._getserviceaccounttoken_() + print("Bpmtoken2", token) return { "Authorization": "Bearer " + token, "Content-Type": "application/json", diff --git a/request-management-api/request_api/services/workflowservice.py b/request-management-api/request_api/services/workflowservice.py index adacfa27a..17e05ee36 100644 --- a/request-management-api/request_api/services/workflowservice.py +++ b/request-management-api/request_api/services/workflowservice.py @@ -101,18 +101,17 @@ def syncwfinstance(self, requesttype, requestid, isallactivity=False): try: # Sync and get raw instance details from FOI DB raw_metadata = self.__sync_raw_request(requesttype, requestid) - print("raw_metadata", "raw_metadata") + print("raw_metadata", raw_metadata) if requesttype == "ministryrequest": - print("requesttype", requesttype) - req_metadata = self.__sync_foi_request(requestid, raw_metadata) - print("req_metadata", req_metadata) + print("ministryrequest", "ministryrequest") + req_metadata = self.__sync_foi_request(requestid, raw_metadata) # Check foi request instance creation - Reconcile by transition to Open - _all_activity_desc = FOIMinistryRequest.getactivitybyid(requestid) - print("_all_activity_desc", _all_activity_desc) + _all_activity_desc = FOIMinistryRequest.getactivitybyid(requestid) self.__sync_state_transition(requestid, str(req_metadata.wfinstanceid), _all_activity_desc, isallactivity) return req_metadata.wfinstanceid return raw_metadata.wfinstanceid except Exception as ex: + print("exLOGS", ex) logging.error(ex) return None @@ -121,6 +120,7 @@ def __sync_raw_request(self, requesttype, requestid): requestid = int(requestid) print("requesttype", requesttype) _raw_metadata = FOIRawRequest.getworkflowinstancebyraw(requestid) if requesttype == "rawrequest" else FOIRawRequest.getworkflowinstancebyministry(requestid) + print("_raw_metadata", _raw_metadata) wf_rawrequest_pid = self.__get_wf_pid("rawrequest", _raw_metadata) print("wf_rawrequest_pid", wf_rawrequest_pid) # Check for exists - Reconcile with new instance creation From 1f6f4d4c303fe1b2159ed0296675d44062d57ba2 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Wed, 8 Jan 2025 14:38:40 -0800 Subject: [PATCH 07/87] Revert All Print update --- .../request_api/services/external/bpmservice.py | 8 -------- .../request_api/services/workflowservice.py | 9 --------- 2 files changed, 17 deletions(-) diff --git a/request-management-api/request_api/services/external/bpmservice.py b/request-management-api/request_api/services/external/bpmservice.py index 40dfd2b1d..0faf97281 100644 --- a/request-management-api/request_api/services/external/bpmservice.py +++ b/request-management-api/request_api/services/external/bpmservice.py @@ -152,10 +152,8 @@ def __post_message(self, messagetype, messageschema, token=None): def _getUrl_(self, messagetype, definitionkey=None): if messagetype is not None: - print("messagetype", messagetype) return self.bpmengineresturl+"/message" elif definitionkey is not None: - print("definitionkey", definitionkey) return self.bpmengineresturl+"/process-definition/key/"+definitionkey+"/start" return self.bpmengineresturl @@ -165,20 +163,14 @@ def _geProcessDefinitionKey_(self, messagequeue): return None def _getserviceaccounttoken_(self): - print("Bselfbpmtokenurl", self.bpmtokenurl) - print("Bselfbpmclientid", self.bpmclientid) - print("Bselfbpmclientsecret", self.bpmclientsecret) auth_response = requests.post(self.bpmtokenurl, auth=(self.bpmclientid, self.bpmclientsecret), headers={ 'Content-Type': 'application/x-www-form-urlencoded'}, data='grant_type=client_credentials') return auth_response.json().get('access_token') def _getHeaders_(self, token): - print("Bpmtoken", token) """Generate headers.""" if token is None: - print("Bpmtoken1", token) token = self._getserviceaccounttoken_() - print("Bpmtoken2", token) return { "Authorization": "Bearer " + token, "Content-Type": "application/json", diff --git a/request-management-api/request_api/services/workflowservice.py b/request-management-api/request_api/services/workflowservice.py index 17e05ee36..1cbcbb1db 100644 --- a/request-management-api/request_api/services/workflowservice.py +++ b/request-management-api/request_api/services/workflowservice.py @@ -101,9 +101,7 @@ def syncwfinstance(self, requesttype, requestid, isallactivity=False): try: # Sync and get raw instance details from FOI DB raw_metadata = self.__sync_raw_request(requesttype, requestid) - print("raw_metadata", raw_metadata) if requesttype == "ministryrequest": - print("ministryrequest", "ministryrequest") req_metadata = self.__sync_foi_request(requestid, raw_metadata) # Check foi request instance creation - Reconcile by transition to Open _all_activity_desc = FOIMinistryRequest.getactivitybyid(requestid) @@ -111,28 +109,21 @@ def syncwfinstance(self, requesttype, requestid, isallactivity=False): return req_metadata.wfinstanceid return raw_metadata.wfinstanceid except Exception as ex: - print("exLOGS", ex) logging.error(ex) return None def __sync_raw_request(self, requesttype, requestid): # Search for WF ID requestid = int(requestid) - print("requesttype", requesttype) _raw_metadata = FOIRawRequest.getworkflowinstancebyraw(requestid) if requesttype == "rawrequest" else FOIRawRequest.getworkflowinstancebyministry(requestid) - print("_raw_metadata", _raw_metadata) wf_rawrequest_pid = self.__get_wf_pid("rawrequest", _raw_metadata) - print("wf_rawrequest_pid", wf_rawrequest_pid) # Check for exists - Reconcile with new instance creation if wf_rawrequest_pid not in (None, "") and _raw_metadata.wfinstanceid not in (None, "") and str(_raw_metadata.wfinstanceid) == wf_rawrequest_pid: - print("wf_rawrequest_pidNotNone", wf_rawrequest_pid) return _raw_metadata # WF Instance is not present if wf_rawrequest_pid in (None, ""): - print("wf_rawrequest_pidNone", wf_rawrequest_pid) self.createinstance(RedisPublisherService().foirequestqueueredischannel, json.dumps(self.__prepare_raw_requestobj(_raw_metadata))) else: - print("wf_rawrequest_pidElse", wf_rawrequest_pid) if _raw_metadata.wfinstanceid in (None, "") or str(_raw_metadata.wfinstanceid) != wf_rawrequest_pid: FOIRawRequest.updateworkflowinstance_n(wf_rawrequest_pid, int(_raw_metadata.requestid), "System") return FOIRawRequest.getworkflowinstancebyraw(requestid) if requesttype == "rawrequest" else FOIRawRequest.getworkflowinstancebyministry(requestid) From c84f22f7a26b8d48865705de982720b9684c0a1a Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Wed, 8 Jan 2025 15:00:38 -0800 Subject: [PATCH 08/87] Added Print --- request-management-api/request_api/resources/foiemail.py | 1 + .../request_api/services/email/senderservice.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/request-management-api/request_api/resources/foiemail.py b/request-management-api/request_api/resources/foiemail.py index c175cc6f3..36aaf0243 100644 --- a/request-management-api/request_api/resources/foiemail.py +++ b/request-management-api/request_api/resources/foiemail.py @@ -49,6 +49,7 @@ def post(requestid, ministryrequestid, servicename): requestjson = request.get_json() emailschema = FOIEmailSchema().load(requestjson) result = emailservice().send(servicename.upper(), requestid, ministryrequestid, emailschema) + print("result", result) return json.dumps(result), 200 if result["success"] == True else 500 except ValueError as err: return {'status': 500, 'message': str(err)}, 500 diff --git a/request-management-api/request_api/services/email/senderservice.py b/request-management-api/request_api/services/email/senderservice.py index 58d6197c2..b03460bf9 100644 --- a/request-management-api/request_api/services/email/senderservice.py +++ b/request-management-api/request_api/services/email/senderservice.py @@ -76,11 +76,15 @@ def send(self, subject, content, _messageattachmentlist, emails, from_email = No smtpobj.starttls() smtpobj.ehlo() #smtpobj.login(MAIL_SRV_USERID, MAIL_SRV_PASSWORD) + print("msgFrom", msg['From']) + print("msgTo", msg['To']) + print("msgSTR", msg.as_string()) smtpobj.sendmail(msg['From'], msg['To'], msg.as_string()) smtpobj.quit() logging.debug("End: Send email for request") return DefaultMethodResult(True,'Sent successfully', -1) except Exception as e: + print("exception", e) logging.exception(e) return DefaultMethodResult(False,'Unable to send', -1) From 815dbc597e039acaa24282758a55bb38c6c46c8d Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Wed, 8 Jan 2025 15:34:24 -0800 Subject: [PATCH 09/87] Update in Email parameter --- request-management-api/request_api/resources/foiemail.py | 1 - .../request_api/services/email/senderservice.py | 4 +--- request-management-api/request_api/services/emailservice.py | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/request-management-api/request_api/resources/foiemail.py b/request-management-api/request_api/resources/foiemail.py index 36aaf0243..c175cc6f3 100644 --- a/request-management-api/request_api/resources/foiemail.py +++ b/request-management-api/request_api/resources/foiemail.py @@ -49,7 +49,6 @@ def post(requestid, ministryrequestid, servicename): requestjson = request.get_json() emailschema = FOIEmailSchema().load(requestjson) result = emailservice().send(servicename.upper(), requestid, ministryrequestid, emailschema) - print("result", result) return json.dumps(result), 200 if result["success"] == True else 500 except ValueError as err: return {'status': 500, 'message': str(err)}, 500 diff --git a/request-management-api/request_api/services/email/senderservice.py b/request-management-api/request_api/services/email/senderservice.py index b03460bf9..7b485b267 100644 --- a/request-management-api/request_api/services/email/senderservice.py +++ b/request-management-api/request_api/services/email/senderservice.py @@ -50,6 +50,7 @@ def send(self, subject, content, _messageattachmentlist, emails, from_email = No msg['From'] = from_email msg['To'] = ",".join(emails) msg['Subject'] = subject + print("msgTo", msg['To']) formattedContent, embeddedImages = embeddedimagehandler().formatembeddedimage(content) part = MIMEText(formattedContent, "html") msg.attach(part) @@ -76,9 +77,6 @@ def send(self, subject, content, _messageattachmentlist, emails, from_email = No smtpobj.starttls() smtpobj.ehlo() #smtpobj.login(MAIL_SRV_USERID, MAIL_SRV_PASSWORD) - print("msgFrom", msg['From']) - print("msgTo", msg['To']) - print("msgSTR", msg.as_string()) smtpobj.sendmail(msg['From'], msg['To'], msg.as_string()) smtpobj.quit() logging.debug("End: Send email for request") diff --git a/request-management-api/request_api/services/emailservice.py b/request-management-api/request_api/services/emailservice.py index 6df55855c..08d24f823 100644 --- a/request-management-api/request_api/services/emailservice.py +++ b/request-management-api/request_api/services/emailservice.py @@ -35,7 +35,7 @@ def send(self, servicename, requestid, ministryrequestid, emailschema): _messageattachmentlist = self.__get_attachments(ministryrequestid, emailschema, servicename) self.__pre_send_correspondence_audit(requestid, ministryrequestid,emailschema, content, templateconfig().isnotreceipt(servicename), _messageattachmentlist) subject = templateconfig().getsubject(servicename, requestjson) - return senderservice().send(subject, _messagepart, _messageattachmentlist, requestjson) + return senderservice().send(subject, _messagepart, _messageattachmentlist, requestjson.get("email")) except Exception as ex: logging.exception(ex) From 3c46f0db89ba5fad1b0ce74e279b06fd80570425 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Wed, 8 Jan 2025 15:56:15 -0800 Subject: [PATCH 10/87] Added email address type validation --- .../request_api/services/email/senderservice.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/request-management-api/request_api/services/email/senderservice.py b/request-management-api/request_api/services/email/senderservice.py index 7b485b267..baae68ac4 100644 --- a/request-management-api/request_api/services/email/senderservice.py +++ b/request-management-api/request_api/services/email/senderservice.py @@ -46,9 +46,12 @@ def send(self, subject, content, _messageattachmentlist, emails, from_email = No msg = MIMEMultipart('related') if from_email is None: from_email = MAIL_FROM_ADDRESS - + msg['From'] = from_email - msg['To'] = ",".join(emails) + if isinstance(emails, list): + msg['To'] = ",".join(emails) + else: + msg['To'] = emails msg['Subject'] = subject print("msgTo", msg['To']) formattedContent, embeddedImages = embeddedimagehandler().formatembeddedimage(content) From 1112caed4bef68928b8a627142f1fc4e9f89522e Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Wed, 8 Jan 2025 18:09:06 -0800 Subject: [PATCH 11/87] Print email content --- .../request_api/services/email/senderservice.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/request-management-api/request_api/services/email/senderservice.py b/request-management-api/request_api/services/email/senderservice.py index baae68ac4..941bb7cd6 100644 --- a/request-management-api/request_api/services/email/senderservice.py +++ b/request-management-api/request_api/services/email/senderservice.py @@ -40,7 +40,7 @@ def send_by_request(self, subject, content, _messageattachmentlist, requestjson) def send(self, subject, content, _messageattachmentlist, emails, from_email = None): logging.debug("Begin: Send email for request ") - + content = content.replace('src=\\\"', 'src="') content = content.replace('\\\">','">') msg = MIMEMultipart('related') @@ -80,6 +80,7 @@ def send(self, subject, content, _messageattachmentlist, emails, from_email = No smtpobj.starttls() smtpobj.ehlo() #smtpobj.login(MAIL_SRV_USERID, MAIL_SRV_PASSWORD) + print("msgSTR", msg.as_string()) smtpobj.sendmail(msg['From'], msg['To'], msg.as_string()) smtpobj.quit() logging.debug("End: Send email for request") From a46b5b539b0d83b2945ef4c60d9fad8699b84fdd Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Thu, 9 Jan 2025 12:01:00 -0800 Subject: [PATCH 12/87] Revert "Print email content" This reverts commit 1112caed4bef68928b8a627142f1fc4e9f89522e. --- .../request_api/services/email/senderservice.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/request-management-api/request_api/services/email/senderservice.py b/request-management-api/request_api/services/email/senderservice.py index 941bb7cd6..baae68ac4 100644 --- a/request-management-api/request_api/services/email/senderservice.py +++ b/request-management-api/request_api/services/email/senderservice.py @@ -40,7 +40,7 @@ def send_by_request(self, subject, content, _messageattachmentlist, requestjson) def send(self, subject, content, _messageattachmentlist, emails, from_email = None): logging.debug("Begin: Send email for request ") - + content = content.replace('src=\\\"', 'src="') content = content.replace('\\\">','">') msg = MIMEMultipart('related') @@ -80,7 +80,6 @@ def send(self, subject, content, _messageattachmentlist, emails, from_email = No smtpobj.starttls() smtpobj.ehlo() #smtpobj.login(MAIL_SRV_USERID, MAIL_SRV_PASSWORD) - print("msgSTR", msg.as_string()) smtpobj.sendmail(msg['From'], msg['To'], msg.as_string()) smtpobj.quit() logging.debug("End: Send email for request") From db5e62d6ff70fad57364787e172ae2b8f95624df Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Thu, 9 Jan 2025 14:45:22 -0800 Subject: [PATCH 13/87] Payment URL --- .../request_api/services/communicationwrapperservice.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/request-management-api/request_api/services/communicationwrapperservice.py b/request-management-api/request_api/services/communicationwrapperservice.py index 2e3d5bc93..e990a9fdb 100644 --- a/request-management-api/request_api/services/communicationwrapperservice.py +++ b/request-management-api/request_api/services/communicationwrapperservice.py @@ -31,6 +31,10 @@ def send_email(self,requestid, ministryrequestid, applicantcorrespondencelog): else: if "emails" in applicantcorrespondencelog and len(applicantcorrespondencelog["emails"]) > 0: template = applicantcorrespondenceservice().gettemplatebyid(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()) return communicationemailservice().send(template, applicantcorrespondencelog) return result @@ -41,6 +45,7 @@ def send_email(self,requestid, ministryrequestid, applicantcorrespondencelog): def __handle_fee_email(self,requestid, ministryrequestid, applicantcorrespondencelog): if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != None: requestservice().postfeeeventtoworkflow(requestid, ministryrequestid, "CANCELLED") + print('__handle_fee_email') _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, ""): From 0424f73fb2986667f9260d831754f31086220966 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Thu, 9 Jan 2025 15:52:49 -0800 Subject: [PATCH 14/87] Revert "Payment URL" This reverts commit db5e62d6ff70fad57364787e172ae2b8f95624df. --- .../request_api/services/communicationwrapperservice.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/request-management-api/request_api/services/communicationwrapperservice.py b/request-management-api/request_api/services/communicationwrapperservice.py index e990a9fdb..2e3d5bc93 100644 --- a/request-management-api/request_api/services/communicationwrapperservice.py +++ b/request-management-api/request_api/services/communicationwrapperservice.py @@ -31,10 +31,6 @@ def send_email(self,requestid, ministryrequestid, applicantcorrespondencelog): else: if "emails" in applicantcorrespondencelog and len(applicantcorrespondencelog["emails"]) > 0: template = applicantcorrespondenceservice().gettemplatebyid(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()) return communicationemailservice().send(template, applicantcorrespondencelog) return result @@ -45,7 +41,6 @@ def send_email(self,requestid, ministryrequestid, applicantcorrespondencelog): def __handle_fee_email(self,requestid, ministryrequestid, applicantcorrespondencelog): if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != None: requestservice().postfeeeventtoworkflow(requestid, ministryrequestid, "CANCELLED") - print('__handle_fee_email') _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, ""): From 0e12e2256edece83bb6cc32f128abc04917de623 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Thu, 9 Jan 2025 15:54:27 -0800 Subject: [PATCH 15/87] Revert "Added email address type validation" This reverts commit 3c46f0db89ba5fad1b0ce74e279b06fd80570425. --- .../request_api/services/email/senderservice.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/request-management-api/request_api/services/email/senderservice.py b/request-management-api/request_api/services/email/senderservice.py index baae68ac4..7b485b267 100644 --- a/request-management-api/request_api/services/email/senderservice.py +++ b/request-management-api/request_api/services/email/senderservice.py @@ -46,12 +46,9 @@ def send(self, subject, content, _messageattachmentlist, emails, from_email = No msg = MIMEMultipart('related') if from_email is None: from_email = MAIL_FROM_ADDRESS - + msg['From'] = from_email - if isinstance(emails, list): - msg['To'] = ",".join(emails) - else: - msg['To'] = emails + msg['To'] = ",".join(emails) msg['Subject'] = subject print("msgTo", msg['To']) formattedContent, embeddedImages = embeddedimagehandler().formatembeddedimage(content) From 571a354eb4b788bf736cb95d4cd327b6d3423681 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Thu, 9 Jan 2025 15:54:45 -0800 Subject: [PATCH 16/87] Revert "Update in Email parameter" This reverts commit 815dbc597e039acaa24282758a55bb38c6c46c8d. --- request-management-api/request_api/resources/foiemail.py | 1 + .../request_api/services/email/senderservice.py | 4 +++- request-management-api/request_api/services/emailservice.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/request-management-api/request_api/resources/foiemail.py b/request-management-api/request_api/resources/foiemail.py index c175cc6f3..36aaf0243 100644 --- a/request-management-api/request_api/resources/foiemail.py +++ b/request-management-api/request_api/resources/foiemail.py @@ -49,6 +49,7 @@ def post(requestid, ministryrequestid, servicename): requestjson = request.get_json() emailschema = FOIEmailSchema().load(requestjson) result = emailservice().send(servicename.upper(), requestid, ministryrequestid, emailschema) + print("result", result) return json.dumps(result), 200 if result["success"] == True else 500 except ValueError as err: return {'status': 500, 'message': str(err)}, 500 diff --git a/request-management-api/request_api/services/email/senderservice.py b/request-management-api/request_api/services/email/senderservice.py index 7b485b267..b03460bf9 100644 --- a/request-management-api/request_api/services/email/senderservice.py +++ b/request-management-api/request_api/services/email/senderservice.py @@ -50,7 +50,6 @@ def send(self, subject, content, _messageattachmentlist, emails, from_email = No msg['From'] = from_email msg['To'] = ",".join(emails) msg['Subject'] = subject - print("msgTo", msg['To']) formattedContent, embeddedImages = embeddedimagehandler().formatembeddedimage(content) part = MIMEText(formattedContent, "html") msg.attach(part) @@ -77,6 +76,9 @@ def send(self, subject, content, _messageattachmentlist, emails, from_email = No smtpobj.starttls() smtpobj.ehlo() #smtpobj.login(MAIL_SRV_USERID, MAIL_SRV_PASSWORD) + print("msgFrom", msg['From']) + print("msgTo", msg['To']) + print("msgSTR", msg.as_string()) smtpobj.sendmail(msg['From'], msg['To'], msg.as_string()) smtpobj.quit() logging.debug("End: Send email for request") diff --git a/request-management-api/request_api/services/emailservice.py b/request-management-api/request_api/services/emailservice.py index 08d24f823..6df55855c 100644 --- a/request-management-api/request_api/services/emailservice.py +++ b/request-management-api/request_api/services/emailservice.py @@ -35,7 +35,7 @@ def send(self, servicename, requestid, ministryrequestid, emailschema): _messageattachmentlist = self.__get_attachments(ministryrequestid, emailschema, servicename) self.__pre_send_correspondence_audit(requestid, ministryrequestid,emailschema, content, templateconfig().isnotreceipt(servicename), _messageattachmentlist) subject = templateconfig().getsubject(servicename, requestjson) - return senderservice().send(subject, _messagepart, _messageattachmentlist, requestjson.get("email")) + return senderservice().send(subject, _messagepart, _messageattachmentlist, requestjson) except Exception as ex: logging.exception(ex) From 217a2c8dd34c136df98c71daeeb05692ba4fbdf8 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Thu, 9 Jan 2025 16:00:24 -0800 Subject: [PATCH 17/87] Cleanup Print --- request-management-api/request_api/resources/foiemail.py | 1 - .../request_api/services/email/senderservice.py | 4 ---- 2 files changed, 5 deletions(-) diff --git a/request-management-api/request_api/resources/foiemail.py b/request-management-api/request_api/resources/foiemail.py index 36aaf0243..c175cc6f3 100644 --- a/request-management-api/request_api/resources/foiemail.py +++ b/request-management-api/request_api/resources/foiemail.py @@ -49,7 +49,6 @@ def post(requestid, ministryrequestid, servicename): requestjson = request.get_json() emailschema = FOIEmailSchema().load(requestjson) result = emailservice().send(servicename.upper(), requestid, ministryrequestid, emailschema) - print("result", result) return json.dumps(result), 200 if result["success"] == True else 500 except ValueError as err: return {'status': 500, 'message': str(err)}, 500 diff --git a/request-management-api/request_api/services/email/senderservice.py b/request-management-api/request_api/services/email/senderservice.py index b03460bf9..58d6197c2 100644 --- a/request-management-api/request_api/services/email/senderservice.py +++ b/request-management-api/request_api/services/email/senderservice.py @@ -76,15 +76,11 @@ def send(self, subject, content, _messageattachmentlist, emails, from_email = No smtpobj.starttls() smtpobj.ehlo() #smtpobj.login(MAIL_SRV_USERID, MAIL_SRV_PASSWORD) - print("msgFrom", msg['From']) - print("msgTo", msg['To']) - print("msgSTR", msg.as_string()) smtpobj.sendmail(msg['From'], msg['To'], msg.as_string()) smtpobj.quit() logging.debug("End: Send email for request") return DefaultMethodResult(True,'Sent successfully', -1) except Exception as e: - print("exception", e) logging.exception(e) return DefaultMethodResult(False,'Unable to send', -1) From 9d42c28f2e7f77103dd8d2454bf6bbb7fea7a8e2 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Thu, 9 Jan 2025 16:12:43 -0800 Subject: [PATCH 18/87] Sending email update --- .../request_api/services/email/senderservice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/request-management-api/request_api/services/email/senderservice.py b/request-management-api/request_api/services/email/senderservice.py index 58d6197c2..62e69b528 100644 --- a/request-management-api/request_api/services/email/senderservice.py +++ b/request-management-api/request_api/services/email/senderservice.py @@ -48,7 +48,7 @@ def send(self, subject, content, _messageattachmentlist, emails, from_email = No from_email = MAIL_FROM_ADDRESS msg['From'] = from_email - msg['To'] = ",".join(emails) + msg['To'] = ",".join(emails) if isinstance(emails, list) else emails.get("email") msg['Subject'] = subject formattedContent, embeddedImages = embeddedimagehandler().formatembeddedimage(content) part = MIMEText(formattedContent, "html") From f5b4f7a5611de92adc99b08ebd9020a519899270 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Thu, 9 Jan 2025 16:36:45 -0800 Subject: [PATCH 19/87] Revert "Sending email update" This reverts commit 9d42c28f2e7f77103dd8d2454bf6bbb7fea7a8e2. --- .../request_api/services/email/senderservice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/request-management-api/request_api/services/email/senderservice.py b/request-management-api/request_api/services/email/senderservice.py index 62e69b528..58d6197c2 100644 --- a/request-management-api/request_api/services/email/senderservice.py +++ b/request-management-api/request_api/services/email/senderservice.py @@ -48,7 +48,7 @@ def send(self, subject, content, _messageattachmentlist, emails, from_email = No from_email = MAIL_FROM_ADDRESS msg['From'] = from_email - msg['To'] = ",".join(emails) if isinstance(emails, list) else emails.get("email") + msg['To'] = ",".join(emails) msg['Subject'] = subject formattedContent, embeddedImages = embeddedimagehandler().formatembeddedimage(content) part = MIMEText(formattedContent, "html") From a9261cae5e1fa4d1fb3a7a0f98056fc3f9b6ddc7 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Thu, 9 Jan 2025 17:02:04 -0800 Subject: [PATCH 20/87] Sending Email update --- .../request_api/services/email/senderservice.py | 7 +++++-- .../request_api/services/emailservice.py | 2 +- .../request_api/services/unopenedreportservice.py | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/request-management-api/request_api/services/email/senderservice.py b/request-management-api/request_api/services/email/senderservice.py index 58d6197c2..ae595c937 100644 --- a/request-management-api/request_api/services/email/senderservice.py +++ b/request-management-api/request_api/services/email/senderservice.py @@ -46,9 +46,12 @@ def send(self, subject, content, _messageattachmentlist, emails, from_email = No msg = MIMEMultipart('related') if from_email is None: from_email = MAIL_FROM_ADDRESS - + msg['From'] = from_email - msg['To'] = ",".join(emails) + if isinstance(emails, list): + msg['To'] = ",".join(emails) + else: + msg['To'] = emails msg['Subject'] = subject formattedContent, embeddedImages = embeddedimagehandler().formatembeddedimage(content) part = MIMEText(formattedContent, "html") diff --git a/request-management-api/request_api/services/emailservice.py b/request-management-api/request_api/services/emailservice.py index 6df55855c..08d24f823 100644 --- a/request-management-api/request_api/services/emailservice.py +++ b/request-management-api/request_api/services/emailservice.py @@ -35,7 +35,7 @@ def send(self, servicename, requestid, ministryrequestid, emailschema): _messageattachmentlist = self.__get_attachments(ministryrequestid, emailschema, servicename) self.__pre_send_correspondence_audit(requestid, ministryrequestid,emailschema, content, templateconfig().isnotreceipt(servicename), _messageattachmentlist) subject = templateconfig().getsubject(servicename, requestjson) - return senderservice().send(subject, _messagepart, _messageattachmentlist, requestjson) + return senderservice().send(subject, _messagepart, _messageattachmentlist, requestjson.get("email")) except Exception as ex: logging.exception(ex) diff --git a/request-management-api/request_api/services/unopenedreportservice.py b/request-management-api/request_api/services/unopenedreportservice.py index 61fa1054a..3875030bc 100644 --- a/request-management-api/request_api/services/unopenedreportservice.py +++ b/request-management-api/request_api/services/unopenedreportservice.py @@ -68,11 +68,12 @@ async def generateunopenedreport(self): alerts.append({"request": request, "rank": 2, "potentialmatches": alert.potentialmatches}) UnopenedReport.bulkinsert(alertdbrows) alerts.sort(key=lambda a : a.get('potentialmatches', {'highscore': -1})['highscore']) + emails = {"email": self.reportemail, "topic": "Unopened Report"} senderservice().send( subject="Intake Unopened Request Report: " + str(date.today()), content=self.generateemailhtml(alerts), _messageattachmentlist=[], - requestjson={"email": self.reportemail, "topic": "Unopened Report"} + requestjson=emails.get("email") ) return alerts From f827eefa027a4b2cbf963d1381dd3dd6d78c49e1 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Thu, 9 Jan 2025 17:21:56 -0800 Subject: [PATCH 21/87] Added Print --- .../request_api/services/email/senderservice.py | 1 + 1 file changed, 1 insertion(+) diff --git a/request-management-api/request_api/services/email/senderservice.py b/request-management-api/request_api/services/email/senderservice.py index ae595c937..07321a2ab 100644 --- a/request-management-api/request_api/services/email/senderservice.py +++ b/request-management-api/request_api/services/email/senderservice.py @@ -40,6 +40,7 @@ def send_by_request(self, subject, content, _messageattachmentlist, requestjson) def send(self, subject, content, _messageattachmentlist, emails, from_email = None): logging.debug("Begin: Send email for request ") + print('emails', emails) content = content.replace('src=\\\"', 'src="') content = content.replace('\\\">','">') From 1323c97d27d375b7d493ab681d976d1089d04ca4 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Thu, 9 Jan 2025 18:01:25 -0800 Subject: [PATCH 22/87] Print --- .../request_api/services/external/bpmservice.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/request-management-api/request_api/services/external/bpmservice.py b/request-management-api/request_api/services/external/bpmservice.py index 0faf97281..2946913ac 100644 --- a/request-management-api/request_api/services/external/bpmservice.py +++ b/request-management-api/request_api/services/external/bpmservice.py @@ -163,14 +163,20 @@ def _geProcessDefinitionKey_(self, messagequeue): return None def _getserviceaccounttoken_(self): + print("Bselfbpmtokenurl", self.bpmtokenurl) + print("Bselfbpmclientid", self.bpmclientid) + print("Bselfbpmclientsecret", self.bpmclientsecret) auth_response = requests.post(self.bpmtokenurl, auth=(self.bpmclientid, self.bpmclientsecret), headers={ 'Content-Type': 'application/x-www-form-urlencoded'}, data='grant_type=client_credentials') return auth_response.json().get('access_token') def _getHeaders_(self, token): """Generate headers.""" + print("Bpmtoken", token) if token is None: + print("Bpmtoken1", token) token = self._getserviceaccounttoken_() + print("Bpmtoken2", token) return { "Authorization": "Bearer " + token, "Content-Type": "application/json", From 08b9d975fe88bb4e8e6df545122ba6b6ff95a4a7 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Thu, 9 Jan 2025 18:24:20 -0800 Subject: [PATCH 23/87] Revert "Sending Email update" This reverts commit a9261cae5e1fa4d1fb3a7a0f98056fc3f9b6ddc7. --- .../request_api/services/email/senderservice.py | 7 ++----- .../request_api/services/emailservice.py | 2 +- .../request_api/services/unopenedreportservice.py | 3 +-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/request-management-api/request_api/services/email/senderservice.py b/request-management-api/request_api/services/email/senderservice.py index 07321a2ab..87a082ffc 100644 --- a/request-management-api/request_api/services/email/senderservice.py +++ b/request-management-api/request_api/services/email/senderservice.py @@ -47,12 +47,9 @@ def send(self, subject, content, _messageattachmentlist, emails, from_email = No msg = MIMEMultipart('related') if from_email is None: from_email = MAIL_FROM_ADDRESS - + msg['From'] = from_email - if isinstance(emails, list): - msg['To'] = ",".join(emails) - else: - msg['To'] = emails + msg['To'] = ",".join(emails) msg['Subject'] = subject formattedContent, embeddedImages = embeddedimagehandler().formatembeddedimage(content) part = MIMEText(formattedContent, "html") diff --git a/request-management-api/request_api/services/emailservice.py b/request-management-api/request_api/services/emailservice.py index 08d24f823..6df55855c 100644 --- a/request-management-api/request_api/services/emailservice.py +++ b/request-management-api/request_api/services/emailservice.py @@ -35,7 +35,7 @@ def send(self, servicename, requestid, ministryrequestid, emailschema): _messageattachmentlist = self.__get_attachments(ministryrequestid, emailschema, servicename) self.__pre_send_correspondence_audit(requestid, ministryrequestid,emailschema, content, templateconfig().isnotreceipt(servicename), _messageattachmentlist) subject = templateconfig().getsubject(servicename, requestjson) - return senderservice().send(subject, _messagepart, _messageattachmentlist, requestjson.get("email")) + return senderservice().send(subject, _messagepart, _messageattachmentlist, requestjson) except Exception as ex: logging.exception(ex) diff --git a/request-management-api/request_api/services/unopenedreportservice.py b/request-management-api/request_api/services/unopenedreportservice.py index 3875030bc..61fa1054a 100644 --- a/request-management-api/request_api/services/unopenedreportservice.py +++ b/request-management-api/request_api/services/unopenedreportservice.py @@ -68,12 +68,11 @@ async def generateunopenedreport(self): alerts.append({"request": request, "rank": 2, "potentialmatches": alert.potentialmatches}) UnopenedReport.bulkinsert(alertdbrows) alerts.sort(key=lambda a : a.get('potentialmatches', {'highscore': -1})['highscore']) - emails = {"email": self.reportemail, "topic": "Unopened Report"} senderservice().send( subject="Intake Unopened Request Report: " + str(date.today()), content=self.generateemailhtml(alerts), _messageattachmentlist=[], - requestjson=emails.get("email") + requestjson={"email": self.reportemail, "topic": "Unopened Report"} ) return alerts From e6cdedbdd7f1be18dacdc22595bddfeb758d1eda Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Thu, 9 Jan 2025 18:25:54 -0800 Subject: [PATCH 24/87] Update email service --- .../request_api/services/email/senderservice.py | 5 ++++- request-management-api/request_api/services/emailservice.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/request-management-api/request_api/services/email/senderservice.py b/request-management-api/request_api/services/email/senderservice.py index 87a082ffc..5b20a86a9 100644 --- a/request-management-api/request_api/services/email/senderservice.py +++ b/request-management-api/request_api/services/email/senderservice.py @@ -49,7 +49,10 @@ def send(self, subject, content, _messageattachmentlist, emails, from_email = No from_email = MAIL_FROM_ADDRESS msg['From'] = from_email - msg['To'] = ",".join(emails) + if isinstance(emails, list): + msg['To'] = ",".join(emails) + else: + msg['To'] = emails msg['Subject'] = subject formattedContent, embeddedImages = embeddedimagehandler().formatembeddedimage(content) part = MIMEText(formattedContent, "html") diff --git a/request-management-api/request_api/services/emailservice.py b/request-management-api/request_api/services/emailservice.py index 6df55855c..08d24f823 100644 --- a/request-management-api/request_api/services/emailservice.py +++ b/request-management-api/request_api/services/emailservice.py @@ -35,7 +35,7 @@ def send(self, servicename, requestid, ministryrequestid, emailschema): _messageattachmentlist = self.__get_attachments(ministryrequestid, emailschema, servicename) self.__pre_send_correspondence_audit(requestid, ministryrequestid,emailschema, content, templateconfig().isnotreceipt(servicename), _messageattachmentlist) subject = templateconfig().getsubject(servicename, requestjson) - return senderservice().send(subject, _messagepart, _messageattachmentlist, requestjson) + return senderservice().send(subject, _messagepart, _messageattachmentlist, requestjson.get("email")) except Exception as ex: logging.exception(ex) From e1de10eb4974b224fa44aac3e90c53f42accf1b1 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Thu, 9 Jan 2025 19:05:52 -0800 Subject: [PATCH 25/87] Print Debug --- .../request_api/services/communicationwrapperservice.py | 9 +++------ .../request_api/services/email/senderservice.py | 1 + .../request_api/services/external/bpmservice.py | 5 ++++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/request-management-api/request_api/services/communicationwrapperservice.py b/request-management-api/request_api/services/communicationwrapperservice.py index 2e3d5bc93..b3921f6e5 100644 --- a/request-management-api/request_api/services/communicationwrapperservice.py +++ b/request-management-api/request_api/services/communicationwrapperservice.py @@ -27,18 +27,15 @@ def send_email(self,requestid, ministryrequestid, applicantcorrespondencelog): 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) + return self.__handle_fee_email(requestid, ministryrequestid, applicantcorrespondencelog, result) 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): + + def __handle_fee_email(self,requestid, ministryrequestid, applicantcorrespondencelog, result): if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != None: requestservice().postfeeeventtoworkflow(requestid, ministryrequestid, "CANCELLED") _attributes = applicantcorrespondencelog["attributes"][0] if "attributes" in applicantcorrespondencelog else None diff --git a/request-management-api/request_api/services/email/senderservice.py b/request-management-api/request_api/services/email/senderservice.py index 5b20a86a9..d7873689d 100644 --- a/request-management-api/request_api/services/email/senderservice.py +++ b/request-management-api/request_api/services/email/senderservice.py @@ -80,6 +80,7 @@ def send(self, subject, content, _messageattachmentlist, emails, from_email = No smtpobj.starttls() smtpobj.ehlo() #smtpobj.login(MAIL_SRV_USERID, MAIL_SRV_PASSWORD) + print('msgSTR', msg.as_string()) smtpobj.sendmail(msg['From'], msg['To'], msg.as_string()) smtpobj.quit() logging.debug("End: Send email for request") diff --git a/request-management-api/request_api/services/external/bpmservice.py b/request-management-api/request_api/services/external/bpmservice.py index 2946913ac..3698ea6b9 100644 --- a/request-management-api/request_api/services/external/bpmservice.py +++ b/request-management-api/request_api/services/external/bpmservice.py @@ -16,6 +16,10 @@ class bpmservice(camundaservice): def createinstance(self, messagequeue, message, token=None): + print('message', message) + print('token', token) + print('messagequeue', messagequeue) + print('selfbpmengineresturl', self.bpmengineresturl) if self.bpmengineresturl is not None: _variables = {"variables":{}} for key in message: @@ -23,7 +27,6 @@ def createinstance(self, messagequeue, message, token=None): _variables["variables"][key] = {"type" : _variabletype, "value": message[key]} variableschema = VariableMessageSchema().dump(_variables) createresponce = requests.post(self._getUrl_(None,self._geProcessDefinitionKey_(messagequeue)), data=json.dumps(variableschema), headers = self._getHeaders_(token)) - print("createresponce", createresponce) if createresponce.ok: _createresponce = json.loads(createresponce.content) return _createresponce["id"] From bd614c3547637d419afc23283cc7eb436106248b Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Thu, 9 Jan 2025 20:04:36 -0800 Subject: [PATCH 26/87] Print variableschema --- .../request_api/services/external/bpmservice.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/request-management-api/request_api/services/external/bpmservice.py b/request-management-api/request_api/services/external/bpmservice.py index 3698ea6b9..537e02c10 100644 --- a/request-management-api/request_api/services/external/bpmservice.py +++ b/request-management-api/request_api/services/external/bpmservice.py @@ -26,6 +26,9 @@ def createinstance(self, messagequeue, message, token=None): _variabletype = VariableType.Integer.value if key in ["id"] else VariableType.String.value _variables["variables"][key] = {"type" : _variabletype, "value": message[key]} variableschema = VariableMessageSchema().dump(_variables) + print("variableschema", variableschema) + print("instanceURL", self._getUrl_(None,self._geProcessDefinitionKey_(messagequeue)), data=json.dumps(variableschema)) + print('header', self._getHeaders_(token)) createresponce = requests.post(self._getUrl_(None,self._geProcessDefinitionKey_(messagequeue)), data=json.dumps(variableschema), headers = self._getHeaders_(token)) if createresponce.ok: _createresponce = json.loads(createresponce.content) From 833a399f9ca23c0399580999bec16f7c9a29d9ab Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Thu, 9 Jan 2025 20:12:19 -0800 Subject: [PATCH 27/87] Print Response --- .../request_api/services/external/bpmservice.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/request-management-api/request_api/services/external/bpmservice.py b/request-management-api/request_api/services/external/bpmservice.py index 537e02c10..9130e20ff 100644 --- a/request-management-api/request_api/services/external/bpmservice.py +++ b/request-management-api/request_api/services/external/bpmservice.py @@ -27,9 +27,10 @@ def createinstance(self, messagequeue, message, token=None): _variables["variables"][key] = {"type" : _variabletype, "value": message[key]} variableschema = VariableMessageSchema().dump(_variables) print("variableschema", variableschema) - print("instanceURL", self._getUrl_(None,self._geProcessDefinitionKey_(messagequeue)), data=json.dumps(variableschema)) + print("instanceURL", self._getUrl_(None,self._geProcessDefinitionKey_(messagequeue))) print('header', self._getHeaders_(token)) createresponce = requests.post(self._getUrl_(None,self._geProcessDefinitionKey_(messagequeue)), data=json.dumps(variableschema), headers = self._getHeaders_(token)) + print('createresponce', createresponce) if createresponce.ok: _createresponce = json.loads(createresponce.content) return _createresponce["id"] From eaa492e51e66d2cb50b22142a46dfb17ec7c875a Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Fri, 10 Jan 2025 11:21:42 -0800 Subject: [PATCH 28/87] Revert Result --- .../request_api/services/communicationwrapperservice.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/request-management-api/request_api/services/communicationwrapperservice.py b/request-management-api/request_api/services/communicationwrapperservice.py index b3921f6e5..32ab5348f 100644 --- a/request-management-api/request_api/services/communicationwrapperservice.py +++ b/request-management-api/request_api/services/communicationwrapperservice.py @@ -27,7 +27,7 @@ def send_email(self,requestid, ministryrequestid, applicantcorrespondencelog): 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, result) + return self.__handle_fee_email(requestid, ministryrequestid, applicantcorrespondencelog) else: if "emails" in applicantcorrespondencelog and len(applicantcorrespondencelog["emails"]) > 0: template = applicantcorrespondenceservice().gettemplatebyid(applicantcorrespondencelog["templateid"]) @@ -35,7 +35,7 @@ def send_email(self,requestid, ministryrequestid, applicantcorrespondencelog): return result - def __handle_fee_email(self,requestid, ministryrequestid, applicantcorrespondencelog, result): + def __handle_fee_email(self,requestid, ministryrequestid, applicantcorrespondencelog): if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != None: requestservice().postfeeeventtoworkflow(requestid, ministryrequestid, "CANCELLED") _attributes = applicantcorrespondencelog["attributes"][0] if "attributes" in applicantcorrespondencelog else None From b8ec97d641746cd16036466aff83b3ab5837e8f3 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Fri, 10 Jan 2025 13:49:12 -0800 Subject: [PATCH 29/87] Added Payment --- .../request_api/services/communicationwrapperservice.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/request-management-api/request_api/services/communicationwrapperservice.py b/request-management-api/request_api/services/communicationwrapperservice.py index 32ab5348f..0304de6e2 100644 --- a/request-management-api/request_api/services/communicationwrapperservice.py +++ b/request-management-api/request_api/services/communicationwrapperservice.py @@ -13,6 +13,7 @@ from request_api.services.paymentservice import paymentservice from request_api.models.default_method_result import DefaultMethodResult from request_api.services.communicationemailservice import communicationemailservice +from request_api.services.fee_service import FeeService class communicationwrapperservice: """ FOI communication wrapper service @@ -31,6 +32,11 @@ def send_email(self,requestid, ministryrequestid, applicantcorrespondencelog): else: if "emails" in applicantcorrespondencelog and len(applicantcorrespondencelog["emails"]) > 0: template = applicantcorrespondenceservice().gettemplatebyid(applicantcorrespondencelog["templateid"]) + request_json={"request_id": requestid,"fee_code": None} + fee_service: FeeService = FeeService(request_id=requestid, code=request_json['fee_code']) + pay_response = fee_service.init_payment(request_json) + print("pay_response", pay_response) + print("applicantcorrespondencelog", applicantcorrespondencelog) return communicationemailservice().send(template, applicantcorrespondencelog) return result From 3e77c3b59cf7800e799fe944726acd69ec3dd41e Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Fri, 10 Jan 2025 14:16:42 -0800 Subject: [PATCH 30/87] Revert "Added Payment" This reverts commit b8ec97d641746cd16036466aff83b3ab5837e8f3. --- .../request_api/services/communicationwrapperservice.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/request-management-api/request_api/services/communicationwrapperservice.py b/request-management-api/request_api/services/communicationwrapperservice.py index 0304de6e2..32ab5348f 100644 --- a/request-management-api/request_api/services/communicationwrapperservice.py +++ b/request-management-api/request_api/services/communicationwrapperservice.py @@ -13,7 +13,6 @@ from request_api.services.paymentservice import paymentservice from request_api.models.default_method_result import DefaultMethodResult from request_api.services.communicationemailservice import communicationemailservice -from request_api.services.fee_service import FeeService class communicationwrapperservice: """ FOI communication wrapper service @@ -32,11 +31,6 @@ def send_email(self,requestid, ministryrequestid, applicantcorrespondencelog): else: if "emails" in applicantcorrespondencelog and len(applicantcorrespondencelog["emails"]) > 0: template = applicantcorrespondenceservice().gettemplatebyid(applicantcorrespondencelog["templateid"]) - request_json={"request_id": requestid,"fee_code": None} - fee_service: FeeService = FeeService(request_id=requestid, code=request_json['fee_code']) - pay_response = fee_service.init_payment(request_json) - print("pay_response", pay_response) - print("applicantcorrespondencelog", applicantcorrespondencelog) return communicationemailservice().send(template, applicantcorrespondencelog) return result From d72f283602e1b828ddb6e8deacd518f06f9d1d6a Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Fri, 10 Jan 2025 14:44:58 -0800 Subject: [PATCH 31/87] Cleanup Print --- .../request_api/resources/fee.py | 2 ++ .../request_api/services/email/senderservice.py | 2 -- .../request_api/services/external/bpmservice.py | 14 -------------- .../services/external/camundaservice.py | 6 ------ 4 files changed, 2 insertions(+), 22 deletions(-) diff --git a/request-management-api/request_api/resources/fee.py b/request-management-api/request_api/resources/fee.py index b3b8216ef..c92913e2c 100644 --- a/request-management-api/request_api/resources/fee.py +++ b/request-management-api/request_api/resources/fee.py @@ -60,6 +60,8 @@ class Payment(Resource): def post(request_id: int): try: request_json = request.get_json() + print("request_id", request_id) + print("request_json", request_json) fee_service: FeeService = FeeService(request_id=request_id, code=request_json['fee_code']) pay_response = fee_service.init_payment(request_json) return pay_response, 201 diff --git a/request-management-api/request_api/services/email/senderservice.py b/request-management-api/request_api/services/email/senderservice.py index d7873689d..019fcadb2 100644 --- a/request-management-api/request_api/services/email/senderservice.py +++ b/request-management-api/request_api/services/email/senderservice.py @@ -40,7 +40,6 @@ def send_by_request(self, subject, content, _messageattachmentlist, requestjson) def send(self, subject, content, _messageattachmentlist, emails, from_email = None): logging.debug("Begin: Send email for request ") - print('emails', emails) content = content.replace('src=\\\"', 'src="') content = content.replace('\\\">','">') @@ -80,7 +79,6 @@ def send(self, subject, content, _messageattachmentlist, emails, from_email = No smtpobj.starttls() smtpobj.ehlo() #smtpobj.login(MAIL_SRV_USERID, MAIL_SRV_PASSWORD) - print('msgSTR', msg.as_string()) smtpobj.sendmail(msg['From'], msg['To'], msg.as_string()) smtpobj.quit() logging.debug("End: Send email for request") diff --git a/request-management-api/request_api/services/external/bpmservice.py b/request-management-api/request_api/services/external/bpmservice.py index 9130e20ff..09534a129 100644 --- a/request-management-api/request_api/services/external/bpmservice.py +++ b/request-management-api/request_api/services/external/bpmservice.py @@ -16,21 +16,13 @@ class bpmservice(camundaservice): def createinstance(self, messagequeue, message, token=None): - print('message', message) - print('token', token) - print('messagequeue', messagequeue) - print('selfbpmengineresturl', self.bpmengineresturl) if self.bpmengineresturl is not None: _variables = {"variables":{}} for key in message: _variabletype = VariableType.Integer.value if key in ["id"] else VariableType.String.value _variables["variables"][key] = {"type" : _variabletype, "value": message[key]} variableschema = VariableMessageSchema().dump(_variables) - print("variableschema", variableschema) - print("instanceURL", self._getUrl_(None,self._geProcessDefinitionKey_(messagequeue))) - print('header', self._getHeaders_(token)) createresponce = requests.post(self._getUrl_(None,self._geProcessDefinitionKey_(messagequeue)), data=json.dumps(variableschema), headers = self._getHeaders_(token)) - print('createresponce', createresponce) if createresponce.ok: _createresponce = json.loads(createresponce.content) return _createresponce["id"] @@ -170,20 +162,14 @@ def _geProcessDefinitionKey_(self, messagequeue): return None def _getserviceaccounttoken_(self): - print("Bselfbpmtokenurl", self.bpmtokenurl) - print("Bselfbpmclientid", self.bpmclientid) - print("Bselfbpmclientsecret", self.bpmclientsecret) auth_response = requests.post(self.bpmtokenurl, auth=(self.bpmclientid, self.bpmclientsecret), headers={ 'Content-Type': 'application/x-www-form-urlencoded'}, data='grant_type=client_credentials') return auth_response.json().get('access_token') def _getHeaders_(self, token): """Generate headers.""" - print("Bpmtoken", token) if token is None: - print("Bpmtoken1", token) token = self._getserviceaccounttoken_() - print("Bpmtoken2", token) return { "Authorization": "Bearer " + token, "Content-Type": "application/json", diff --git a/request-management-api/request_api/services/external/camundaservice.py b/request-management-api/request_api/services/external/camundaservice.py index 8239a640e..be25070ac 100644 --- a/request-management-api/request_api/services/external/camundaservice.py +++ b/request-management-api/request_api/services/external/camundaservice.py @@ -19,21 +19,15 @@ class camundaservice: def _getserviceaccounttoken_(self): - print("Cselfbpmtokenurl", self.bpmtokenurl) - print("Cselfbpmclientid", self.bpmclientid) - print("Cselfbpmclientsecret", self.bpmclientsecret) auth_response = requests.post(self.bpmtokenurl, auth=(self.bpmclientid, self.bpmclientsecret), headers={ 'Content-Type': 'application/x-www-form-urlencoded'}, data='grant_type=client_credentials') return auth_response.json().get('access_token') def _getheaders_(self, token): - print("Ctokenbefore", token) """Generate headers.""" if token is None: - print("CtokenNone", token) token = self._getserviceaccounttoken_(); - print("CtokenAfter", token) return { "Authorization": "Bearer " + token, "Content-Type": "application/json", From 29c38b9a9e8b6b853cedb91a17ff4b3aa1853f98 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Fri, 10 Jan 2025 18:51:39 -0800 Subject: [PATCH 32/87] Test applicantcorrespondence --- .../resources/applicantcorrespondence.py | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/request-management-api/request_api/resources/applicantcorrespondence.py b/request-management-api/request_api/resources/applicantcorrespondence.py index 365bf3132..63a5c11dd 100644 --- a/request-management-api/request_api/resources/applicantcorrespondence.py +++ b/request-management-api/request_api/resources/applicantcorrespondence.py @@ -82,6 +82,20 @@ def get(requestid, ministryrequestid): except BusinessException: return "Error happened while fetching applicant correspondence logs" , 500 + # @staticmethod + # @TRACER.trace() + # @cross_origin(origins=allowedorigins()) + # @auth.require + # @auth.hasusertype('iao') + # 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 + # except BusinessException: + # return "Error happened while saving applicant correspondence log" , 500 @staticmethod @TRACER.trace() @cross_origin(origins=allowedorigins()) @@ -91,14 +105,23 @@ 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 + result = applicantcorrespondenceservice().saveapplicantcorrespondencelog(requestid, ministryrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) + if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != None: + requestservice().postfeeeventtoworkflow(requestid, ministryrequestid, "CANCELLED") + if result.success == True: + _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 {'status': result.success, 'message':result.message,'id':result.identifier} , 200 except BusinessException: return "Error happened while saving applicant correspondence log" , 500 + @cors_preflight('POST,OPTIONS') @API.route('/foiflow/applicantcorrespondence/draft//') class FOIFlowApplicantCorrespondenceDraft(Resource): From a81a08a50f3475d1b9e91d855ff4c2f1088362e8 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Fri, 10 Jan 2025 20:52:46 -0800 Subject: [PATCH 33/87] Sending Email --- .../resources/applicantcorrespondence.py | 33 +++---------------- .../request_api/resources/fee.py | 2 -- .../services/communicationwrapperservice.py | 24 ++++++++++++-- .../services/external/bpmservice.py | 2 +- .../services/unopenedreportservice.py | 3 +- 5 files changed, 28 insertions(+), 36 deletions(-) diff --git a/request-management-api/request_api/resources/applicantcorrespondence.py b/request-management-api/request_api/resources/applicantcorrespondence.py index 63a5c11dd..3ae650e35 100644 --- a/request-management-api/request_api/resources/applicantcorrespondence.py +++ b/request-management-api/request_api/resources/applicantcorrespondence.py @@ -82,20 +82,6 @@ def get(requestid, ministryrequestid): except BusinessException: return "Error happened while fetching applicant correspondence logs" , 500 - # @staticmethod - # @TRACER.trace() - # @cross_origin(origins=allowedorigins()) - # @auth.require - # @auth.hasusertype('iao') - # 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 - # except BusinessException: - # return "Error happened while saving applicant correspondence log" , 500 @staticmethod @TRACER.trace() @cross_origin(origins=allowedorigins()) @@ -105,23 +91,12 @@ def post(requestid, ministryrequestid): try: requestjson = request.get_json() applicantcorrespondencelog = FOIApplicantCorrespondenceSchema().load(data=requestjson) - result = applicantcorrespondenceservice().saveapplicantcorrespondencelog(requestid, ministryrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) - if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != None: - requestservice().postfeeeventtoworkflow(requestid, ministryrequestid, "CANCELLED") - if result.success == True: - _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 {'status': result.success, 'message':result.message,'id':result.identifier} , 200 + rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid) + result = communicationwrapperservice().send_email(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 - - - - + @cors_preflight('POST,OPTIONS') @API.route('/foiflow/applicantcorrespondence/draft//') class FOIFlowApplicantCorrespondenceDraft(Resource): diff --git a/request-management-api/request_api/resources/fee.py b/request-management-api/request_api/resources/fee.py index c92913e2c..b3b8216ef 100644 --- a/request-management-api/request_api/resources/fee.py +++ b/request-management-api/request_api/resources/fee.py @@ -60,8 +60,6 @@ class Payment(Resource): def post(request_id: int): try: request_json = request.get_json() - print("request_id", request_id) - print("request_json", request_json) fee_service: FeeService = FeeService(request_id=request_id, code=request_json['fee_code']) pay_response = fee_service.init_payment(request_json) return pay_response, 201 diff --git a/request-management-api/request_api/services/communicationwrapperservice.py b/request-management-api/request_api/services/communicationwrapperservice.py index 32ab5348f..b4a4e9331 100644 --- a/request-management-api/request_api/services/communicationwrapperservice.py +++ b/request-management-api/request_api/services/communicationwrapperservice.py @@ -26,8 +26,11 @@ def send_email(self,requestid, ministryrequestid, applicantcorrespondencelog): 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 + isFee = self.__is_fee_processing(applicantcorrespondencelog["templateid"]) + print("isFee", isFee) if self.__is_fee_processing(applicantcorrespondencelog["templateid"]) == True: - return self.__handle_fee_email(requestid, ministryrequestid, applicantcorrespondencelog) + print("isFee2", isFee) + return self.__handle_fee_email(requestid, ministryrequestid, applicantcorrespondencelog, result) else: if "emails" in applicantcorrespondencelog and len(applicantcorrespondencelog["emails"]) > 0: template = applicantcorrespondenceservice().gettemplatebyid(applicantcorrespondencelog["templateid"]) @@ -35,17 +38,32 @@ def send_email(self,requestid, ministryrequestid, applicantcorrespondencelog): return result - def __handle_fee_email(self,requestid, ministryrequestid, applicantcorrespondencelog): + def __handle_fee_email(self,requestid, ministryrequestid, applicantcorrespondencelog, result): if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != 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()) + print("isFee3") return requestservice().postcorrespondenceeventtoworkflow(requestid, ministryrequestid, result.identifier, applicantcorrespondencelog['attributes'], applicantcorrespondencelog['templateid']) + # def __is_fee_processing(self, templateid): + # template = applicantcorrespondenceservice().gettemplatebyid(templateid) + # print("template10", template) + # return template and template.name in ['PAYONLINE', 'PAYOUTSTANDING'] + + # def __is_fee_processing(self, templateid): + # template = applicantcorrespondenceservice().getactivetemplatebyid(templateid) + # template2 = applicantcorrespondenceservice().gettemplatebyid(templateid).name + # print("template10", template) + # print("template12", template2) + # if template and hasattr(template, 'name') and template.name.upper() in ['PAYONLINE', 'PAYOUTSTANDING']: + # return True + # return False + 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 diff --git a/request-management-api/request_api/services/external/bpmservice.py b/request-management-api/request_api/services/external/bpmservice.py index 09534a129..1ef074eb0 100644 --- a/request-management-api/request_api/services/external/bpmservice.py +++ b/request-management-api/request_api/services/external/bpmservice.py @@ -169,7 +169,7 @@ def _getserviceaccounttoken_(self): def _getHeaders_(self, token): """Generate headers.""" if token is None: - token = self._getserviceaccounttoken_() + token = self._getserviceaccounttoken_(); return { "Authorization": "Bearer " + token, "Content-Type": "application/json", diff --git a/request-management-api/request_api/services/unopenedreportservice.py b/request-management-api/request_api/services/unopenedreportservice.py index 61fa1054a..67c18642b 100644 --- a/request-management-api/request_api/services/unopenedreportservice.py +++ b/request-management-api/request_api/services/unopenedreportservice.py @@ -68,11 +68,12 @@ async def generateunopenedreport(self): alerts.append({"request": request, "rank": 2, "potentialmatches": alert.potentialmatches}) UnopenedReport.bulkinsert(alertdbrows) alerts.sort(key=lambda a : a.get('potentialmatches', {'highscore': -1})['highscore']) + requestjson={"email": self.reportemail, "topic": "Unopened Report"} senderservice().send( subject="Intake Unopened Request Report: " + str(date.today()), content=self.generateemailhtml(alerts), _messageattachmentlist=[], - requestjson={"email": self.reportemail, "topic": "Unopened Report"} + emails=requestjson.get("email") ) return alerts From fb99c3dc55e707fd1cddd14bdda1d8645573a9e8 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Sat, 11 Jan 2025 17:04:40 -0800 Subject: [PATCH 34/87] Print Result --- .../models/FOIRequestContactInformation.py | 3 ++- .../resources/applicantcorrespondence.py | 1 + .../services/communicationwrapperservice.py | 15 ++++++++++----- .../services/foirequest/requestservicegetter.py | 2 ++ .../request_api/services/requestservice.py | 1 + 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/request-management-api/request_api/models/FOIRequestContactInformation.py b/request-management-api/request_api/models/FOIRequestContactInformation.py index be1b7d6f3..05e19bdc1 100644 --- a/request-management-api/request_api/models/FOIRequestContactInformation.py +++ b/request-management-api/request_api/models/FOIRequestContactInformation.py @@ -41,7 +41,8 @@ class FOIRequestContactInformation(db.Model): def getrequestcontactinformation(cls,foirequest_id,foirequestversion): requestcontact_schema = FOIRequestContactInformationSchema(many=True) _contactinfos = db.session.query(FOIRequestContactInformation).filter(FOIRequestContactInformation.foirequest_id == foirequest_id , FOIRequestContactInformation.foirequestversion_id == foirequestversion).order_by(FOIRequestContactInformation.foirequestcontactid.asc()).all() - contactinfos = requestcontact_schema.dump(_contactinfos) + contactinfos = requestcontact_schema.dump(_contactinfos) + print("contactinfos", contactinfos) return contactinfos diff --git a/request-management-api/request_api/resources/applicantcorrespondence.py b/request-management-api/request_api/resources/applicantcorrespondence.py index 3ae650e35..4f1256cb7 100644 --- a/request-management-api/request_api/resources/applicantcorrespondence.py +++ b/request-management-api/request_api/resources/applicantcorrespondence.py @@ -93,6 +93,7 @@ def post(requestid, ministryrequestid): applicantcorrespondencelog = FOIApplicantCorrespondenceSchema().load(data=requestjson) rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid) result = communicationwrapperservice().send_email(rawrequestid, ministryrequestid, applicantcorrespondencelog) + print("FOIFlowApplicantCorrespondenceresult", result) return {'status': result.success, 'message':result.message,'id':result.identifier} , 200 except BusinessException: return "Error happened while saving applicant correspondence log" , 500 diff --git a/request-management-api/request_api/services/communicationwrapperservice.py b/request-management-api/request_api/services/communicationwrapperservice.py index b4a4e9331..ceb8f375e 100644 --- a/request-management-api/request_api/services/communicationwrapperservice.py +++ b/request-management-api/request_api/services/communicationwrapperservice.py @@ -20,9 +20,13 @@ class communicationwrapperservice: """ def send_email(self,requestid, ministryrequestid, applicantcorrespondencelog): + isMinistry = ministryrequestid == 'None' or ministryrequestid is None or ("israwrequest" in applicantcorrespondencelog and applicantcorrespondencelog["israwrequest"]) + print("isMinistry", isMinistry) if ministryrequestid == 'None' or ministryrequestid is None or ("israwrequest" in applicantcorrespondencelog and applicantcorrespondencelog["israwrequest"]) is True: + print("isMinistryNone", isMinistry) result = applicantcorrespondenceservice().saveapplicantcorrespondencelogforrawrequest(requestid, applicantcorrespondencelog, AuthHelper.getuserid()) else: + print("isMinistryYes", isMinistry) 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 @@ -41,11 +45,12 @@ def send_email(self,requestid, ministryrequestid, applicantcorrespondencelog): def __handle_fee_email(self,requestid, ministryrequestid, applicantcorrespondencelog, result): if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != 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()) - print("isFee3") + if result.success == True: + _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()) + print("isFee3") return requestservice().postcorrespondenceeventtoworkflow(requestid, ministryrequestid, result.identifier, applicantcorrespondencelog['attributes'], applicantcorrespondencelog['templateid']) # def __is_fee_processing(self, templateid): diff --git a/request-management-api/request_api/services/foirequest/requestservicegetter.py b/request-management-api/request_api/services/foirequest/requestservicegetter.py index 14c43eb74..b0298a0bc 100644 --- a/request-management-api/request_api/services/foirequest/requestservicegetter.py +++ b/request-management-api/request_api/services/foirequest/requestservicegetter.py @@ -26,7 +26,9 @@ class requestservicegetter: def getrequest(self,foirequestid,foiministryrequestid): request = FOIRequest.getrequest(foirequestid) + print("requestservicegetter_request", request) requestministry = FOIMinistryRequest.getrequestbyministryrequestid(foiministryrequestid) + print("version", request['version']) requestcontactinformation = FOIRequestContactInformation.getrequestcontactinformation(foirequestid,request['version']) requestapplicants = FOIRequestApplicantMapping.getrequestapplicantinfos(foirequestid,request['version']) requestministrydivisions = FOIMinistryRequestDivision.getdivisions(foiministryrequestid,requestministry['version']) diff --git a/request-management-api/request_api/services/requestservice.py b/request-management-api/request_api/services/requestservice.py index 121de75fa..8a1f3f971 100644 --- a/request-management-api/request_api/services/requestservice.py +++ b/request-management-api/request_api/services/requestservice.py @@ -251,6 +251,7 @@ def postcorrespondenceeventtoworkflow( wfinstanceid = workflowservice().syncwfinstance( "ministryrequest", ministryrequestid, True ) + print("foirequestschema", foirequestschema) workflowservice().postcorrenspodenceevent( wfinstanceid, ministryrequestid, From b92984c24f943416708d649d42a96c857200c9e0 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Sat, 11 Jan 2025 17:21:46 -0800 Subject: [PATCH 35/87] Print Key --- .../services/foirequest/requestservicegetter.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/request-management-api/request_api/services/foirequest/requestservicegetter.py b/request-management-api/request_api/services/foirequest/requestservicegetter.py index b0298a0bc..0acc4fa2b 100644 --- a/request-management-api/request_api/services/foirequest/requestservicegetter.py +++ b/request-management-api/request_api/services/foirequest/requestservicegetter.py @@ -29,9 +29,10 @@ def getrequest(self,foirequestid,foiministryrequestid): print("requestservicegetter_request", request) requestministry = FOIMinistryRequest.getrequestbyministryrequestid(foiministryrequestid) print("version", request['version']) - requestcontactinformation = FOIRequestContactInformation.getrequestcontactinformation(foirequestid,request['version']) - requestapplicants = FOIRequestApplicantMapping.getrequestapplicantinfos(foirequestid,request['version']) - requestministrydivisions = FOIMinistryRequestDivision.getdivisions(foiministryrequestid,requestministry['version']) + version = request.get('version') + requestcontactinformation = FOIRequestContactInformation.getrequestcontactinformation(foirequestid,version) + requestapplicants = FOIRequestApplicantMapping.getrequestapplicantinfos(foirequestid,version) + requestministrydivisions = FOIMinistryRequestDivision.getdivisions(foiministryrequestid,version) iaorestrictrequestdetails = FOIRestrictedMinistryRequest.getrestricteddetails(ministryrequestid=foiministryrequestid,type='iao') baserequestinfo = self.__preparebaseinfo(request,foiministryrequestid,requestministry,requestministrydivisions) From 9e3660d9f79ab45802fdaaf409bba55c9899eb22 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Sat, 11 Jan 2025 17:27:39 -0800 Subject: [PATCH 36/87] Print Version --- .../request_api/services/foirequest/requestservicegetter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/request-management-api/request_api/services/foirequest/requestservicegetter.py b/request-management-api/request_api/services/foirequest/requestservicegetter.py index 0acc4fa2b..d56ef6ace 100644 --- a/request-management-api/request_api/services/foirequest/requestservicegetter.py +++ b/request-management-api/request_api/services/foirequest/requestservicegetter.py @@ -28,8 +28,8 @@ def getrequest(self,foirequestid,foiministryrequestid): request = FOIRequest.getrequest(foirequestid) print("requestservicegetter_request", request) requestministry = FOIMinistryRequest.getrequestbyministryrequestid(foiministryrequestid) - print("version", request['version']) version = request.get('version') + print("version", version) requestcontactinformation = FOIRequestContactInformation.getrequestcontactinformation(foirequestid,version) requestapplicants = FOIRequestApplicantMapping.getrequestapplicantinfos(foirequestid,version) requestministrydivisions = FOIMinistryRequestDivision.getdivisions(foiministryrequestid,version) From c6c823a299b36c7b08b2e54353af01f6093e1dd3 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Sat, 11 Jan 2025 17:40:49 -0800 Subject: [PATCH 37/87] Print Result --- .../services/communicationwrapperservice.py | 32 ++++++------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/request-management-api/request_api/services/communicationwrapperservice.py b/request-management-api/request_api/services/communicationwrapperservice.py index ceb8f375e..dc216044f 100644 --- a/request-management-api/request_api/services/communicationwrapperservice.py +++ b/request-management-api/request_api/services/communicationwrapperservice.py @@ -34,7 +34,7 @@ def send_email(self,requestid, ministryrequestid, applicantcorrespondencelog): print("isFee", isFee) if self.__is_fee_processing(applicantcorrespondencelog["templateid"]) == True: print("isFee2", isFee) - return self.__handle_fee_email(requestid, ministryrequestid, applicantcorrespondencelog, result) + return self.__handle_fee_email(requestid, ministryrequestid, applicantcorrespondencelog, result.identifier) else: if "emails" in applicantcorrespondencelog and len(applicantcorrespondencelog["emails"]) > 0: template = applicantcorrespondenceservice().gettemplatebyid(applicantcorrespondencelog["templateid"]) @@ -42,30 +42,16 @@ def send_email(self,requestid, ministryrequestid, applicantcorrespondencelog): return result - def __handle_fee_email(self,requestid, ministryrequestid, applicantcorrespondencelog, result): + def __handle_fee_email(self,requestid, ministryrequestid, applicantcorrespondencelog, identifier): if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != None: requestservice().postfeeeventtoworkflow(requestid, ministryrequestid, "CANCELLED") - if result.success == True: - _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()) - print("isFee3") - return requestservice().postcorrespondenceeventtoworkflow(requestid, ministryrequestid, result.identifier, applicantcorrespondencelog['attributes'], applicantcorrespondencelog['templateid']) - - # def __is_fee_processing(self, templateid): - # template = applicantcorrespondenceservice().gettemplatebyid(templateid) - # print("template10", template) - # return template and template.name in ['PAYONLINE', 'PAYOUTSTANDING'] - - # def __is_fee_processing(self, templateid): - # template = applicantcorrespondenceservice().getactivetemplatebyid(templateid) - # template2 = applicantcorrespondenceservice().gettemplatebyid(templateid).name - # print("template10", template) - # print("template12", template2) - # if template and hasattr(template, 'name') and template.name.upper() in ['PAYONLINE', 'PAYOUTSTANDING']: - # return True - # return False + _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()) + print("isFee3") + print("isFee4") + return requestservice().postcorrespondenceeventtoworkflow(requestid, ministryrequestid, identifier, applicantcorrespondencelog['attributes'], applicantcorrespondencelog['templateid']) def __is_fee_processing(self, templateid): if applicantcorrespondenceservice().gettemplatebyid(templateid).name in ['PAYONLINE','PAYOUTSTANDING']: From a29bbc7197c41ebbb7a7a35dcc59692857e88428 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Sat, 11 Jan 2025 18:21:33 -0800 Subject: [PATCH 38/87] Print Result --- .../request_api/resources/applicantcorrespondence.py | 2 +- .../request_api/services/communicationwrapperservice.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/request-management-api/request_api/resources/applicantcorrespondence.py b/request-management-api/request_api/resources/applicantcorrespondence.py index 4f1256cb7..2ed251102 100644 --- a/request-management-api/request_api/resources/applicantcorrespondence.py +++ b/request-management-api/request_api/resources/applicantcorrespondence.py @@ -92,7 +92,7 @@ def post(requestid, ministryrequestid): requestjson = request.get_json() applicantcorrespondencelog = FOIApplicantCorrespondenceSchema().load(data=requestjson) rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid) - result = communicationwrapperservice().send_email(rawrequestid, ministryrequestid, applicantcorrespondencelog) + result = communicationwrapperservice().send_email(requestid, rawrequestid, ministryrequestid, applicantcorrespondencelog) print("FOIFlowApplicantCorrespondenceresult", result) return {'status': result.success, 'message':result.message,'id':result.identifier} , 200 except BusinessException: diff --git a/request-management-api/request_api/services/communicationwrapperservice.py b/request-management-api/request_api/services/communicationwrapperservice.py index dc216044f..54688cb0e 100644 --- a/request-management-api/request_api/services/communicationwrapperservice.py +++ b/request-management-api/request_api/services/communicationwrapperservice.py @@ -19,15 +19,17 @@ class communicationwrapperservice: """ - def send_email(self,requestid, ministryrequestid, applicantcorrespondencelog): + def send_email(self, requestid, rawrequestid, ministryrequestid, applicantcorrespondencelog): isMinistry = ministryrequestid == 'None' or ministryrequestid is None or ("israwrequest" in applicantcorrespondencelog and applicantcorrespondencelog["israwrequest"]) print("isMinistry", isMinistry) if ministryrequestid == 'None' or ministryrequestid is None or ("israwrequest" in applicantcorrespondencelog and applicantcorrespondencelog["israwrequest"]) is True: print("isMinistryNone", isMinistry) - result = applicantcorrespondenceservice().saveapplicantcorrespondencelogforrawrequest(requestid, applicantcorrespondencelog, AuthHelper.getuserid()) + result = applicantcorrespondenceservice().saveapplicantcorrespondencelogforrawrequest(rawrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) + print("resultNotRaw", result) else: print("isMinistryYes", isMinistry) result = applicantcorrespondenceservice().saveapplicantcorrespondencelog(requestid, ministryrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) + print("resultNotRaw", result) if result.success == True: # raw requests should never be fee emails so they would only get handled by else statement isFee = self.__is_fee_processing(applicantcorrespondencelog["templateid"]) @@ -41,7 +43,6 @@ def send_email(self,requestid, ministryrequestid, applicantcorrespondencelog): return communicationemailservice().send(template, applicantcorrespondencelog) return result - def __handle_fee_email(self,requestid, ministryrequestid, applicantcorrespondencelog, identifier): if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != None: requestservice().postfeeeventtoworkflow(requestid, ministryrequestid, "CANCELLED") From b8803a48b1d77a493a2898ea3ed5e022c480191c Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Sat, 11 Jan 2025 18:52:15 -0800 Subject: [PATCH 39/87] Print paymentexpirydate --- .../request_api/resources/applicantcorrespondence.py | 1 - .../services/communicationwrapperservice.py | 11 ++--------- .../request_api/services/paymentservice.py | 3 +++ 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/request-management-api/request_api/resources/applicantcorrespondence.py b/request-management-api/request_api/resources/applicantcorrespondence.py index 2ed251102..a782c742a 100644 --- a/request-management-api/request_api/resources/applicantcorrespondence.py +++ b/request-management-api/request_api/resources/applicantcorrespondence.py @@ -93,7 +93,6 @@ def post(requestid, ministryrequestid): applicantcorrespondencelog = FOIApplicantCorrespondenceSchema().load(data=requestjson) rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid) result = communicationwrapperservice().send_email(requestid, rawrequestid, ministryrequestid, applicantcorrespondencelog) - print("FOIFlowApplicantCorrespondenceresult", result) return {'status': result.success, 'message':result.message,'id':result.identifier} , 200 except BusinessException: return "Error happened while saving applicant correspondence log" , 500 diff --git a/request-management-api/request_api/services/communicationwrapperservice.py b/request-management-api/request_api/services/communicationwrapperservice.py index 54688cb0e..794fce68e 100644 --- a/request-management-api/request_api/services/communicationwrapperservice.py +++ b/request-management-api/request_api/services/communicationwrapperservice.py @@ -20,22 +20,13 @@ class communicationwrapperservice: """ def send_email(self, requestid, rawrequestid, ministryrequestid, applicantcorrespondencelog): - isMinistry = ministryrequestid == 'None' or ministryrequestid is None or ("israwrequest" in applicantcorrespondencelog and applicantcorrespondencelog["israwrequest"]) - print("isMinistry", isMinistry) if ministryrequestid == 'None' or ministryrequestid is None or ("israwrequest" in applicantcorrespondencelog and applicantcorrespondencelog["israwrequest"]) is True: - print("isMinistryNone", isMinistry) result = applicantcorrespondenceservice().saveapplicantcorrespondencelogforrawrequest(rawrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) - print("resultNotRaw", result) else: - print("isMinistryYes", isMinistry) result = applicantcorrespondenceservice().saveapplicantcorrespondencelog(requestid, ministryrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) - print("resultNotRaw", result) if result.success == True: # raw requests should never be fee emails so they would only get handled by else statement - isFee = self.__is_fee_processing(applicantcorrespondencelog["templateid"]) - print("isFee", isFee) if self.__is_fee_processing(applicantcorrespondencelog["templateid"]) == True: - print("isFee2", isFee) return self.__handle_fee_email(requestid, ministryrequestid, applicantcorrespondencelog, result.identifier) else: if "emails" in applicantcorrespondencelog and len(applicantcorrespondencelog["emails"]) > 0: @@ -48,7 +39,9 @@ def __handle_fee_email(self,requestid, ministryrequestid, applicantcorrespondenc 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 + print("_paymentexpirydate1", _paymentexpirydate) if _paymentexpirydate not in (None, ""): + print("_paymentexpirydate2", _paymentexpirydate) paymentservice().createpayment(requestid, ministryrequestid, _attributes, AuthHelper.getuserid()) print("isFee3") print("isFee4") diff --git a/request-management-api/request_api/services/paymentservice.py b/request-management-api/request_api/services/paymentservice.py index 3bf598034..c30ae3539 100644 --- a/request-management-api/request_api/services/paymentservice.py +++ b/request-management-api/request_api/services/paymentservice.py @@ -33,7 +33,9 @@ def createpayment(self, requestid, ministryrequestid, data, createdby='System'): payment.ministryrequestid = ministryrequestid payment.ministryrequestversion = ministryversion payment.paymenturl = data['paymenturl'] if 'paymenturl' in data else None + print("data", data) payment.paymentexpirydate = data['paymentExpiryDate'] if 'paymentExpiryDate' in data else self.getpaymentexpirydate(requestid, ministryrequestid) + print("_paymentexpirydate3", data['paymentExpiryDate']) payment.version = 1 payment.createdby = createdby _payment = FOIRequestPayment.getpayment(requestid, ministryrequestid) @@ -80,6 +82,7 @@ def getpayment(self, requestid, ministryrequestid): def getpaymentexpirydate(self, requestid, ministryrequestid): payment = FOIRequestPayment.getpayment(requestid, ministryrequestid) + print("payment", payment) paymentexpirydate = payment["paymentexpirydate"] if payment not in (None, {}) else None if paymentexpirydate is not None: return parse(str(paymentexpirydate)).strftime("%Y-%m-%d") From 86866599b1951f305f68256c205494a8b7560429 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Sat, 11 Jan 2025 19:21:11 -0800 Subject: [PATCH 40/87] Print applicantcorrespondencelog --- .../request_api/services/communicationwrapperservice.py | 1 + .../request_api/services/paymentservice.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/request-management-api/request_api/services/communicationwrapperservice.py b/request-management-api/request_api/services/communicationwrapperservice.py index 794fce68e..1cb427358 100644 --- a/request-management-api/request_api/services/communicationwrapperservice.py +++ b/request-management-api/request_api/services/communicationwrapperservice.py @@ -35,6 +35,7 @@ def send_email(self, requestid, rawrequestid, ministryrequestid, applicantcorres return result def __handle_fee_email(self,requestid, ministryrequestid, applicantcorrespondencelog, identifier): + print("applicantcorrespondencelog", applicantcorrespondencelog) if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != None: requestservice().postfeeeventtoworkflow(requestid, ministryrequestid, "CANCELLED") _attributes = applicantcorrespondencelog["attributes"][0] if "attributes" in applicantcorrespondencelog else None diff --git a/request-management-api/request_api/services/paymentservice.py b/request-management-api/request_api/services/paymentservice.py index c30ae3539..2b2f5701f 100644 --- a/request-management-api/request_api/services/paymentservice.py +++ b/request-management-api/request_api/services/paymentservice.py @@ -34,7 +34,10 @@ def createpayment(self, requestid, ministryrequestid, data, createdby='System'): payment.ministryrequestversion = ministryversion payment.paymenturl = data['paymenturl'] if 'paymenturl' in data else None print("data", data) - payment.paymentexpirydate = data['paymentExpiryDate'] if 'paymentExpiryDate' in data else self.getpaymentexpirydate(requestid, ministryrequestid) + paymentexpirydate = data.get('paymentexpirydate') or data.get('paymentExpiryDate') + if not paymentexpirydate: + paymentexpirydate = self.getpaymentexpirydate(requestid, ministryrequestid) + payment.paymentexpirydate = paymentexpirydate print("_paymentexpirydate3", data['paymentExpiryDate']) payment.version = 1 payment.createdby = createdby From 0b9ab3e1dc97357986f2a9f3011ee2381a413040 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Sat, 11 Jan 2025 19:34:46 -0800 Subject: [PATCH 41/87] Print Result --- .../request_api/resources/applicantcorrespondence.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/request-management-api/request_api/resources/applicantcorrespondence.py b/request-management-api/request_api/resources/applicantcorrespondence.py index a782c742a..c48eb20f3 100644 --- a/request-management-api/request_api/resources/applicantcorrespondence.py +++ b/request-management-api/request_api/resources/applicantcorrespondence.py @@ -93,7 +93,8 @@ def post(requestid, ministryrequestid): applicantcorrespondencelog = FOIApplicantCorrespondenceSchema().load(data=requestjson) rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid) result = communicationwrapperservice().send_email(requestid, rawrequestid, ministryrequestid, applicantcorrespondencelog) - return {'status': result.success, 'message':result.message,'id':result.identifier} , 200 + if result.success == True: + return {'status': result.success, 'message':result.message,'id':result.identifier} , 200 except BusinessException: return "Error happened while saving applicant correspondence log" , 500 From 09c0ddfa14c8046aa85d7b32423e19333c4d011b Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Sat, 11 Jan 2025 20:04:17 -0800 Subject: [PATCH 42/87] Print Result --- .../request_api/resources/applicantcorrespondence.py | 4 ++-- .../request_api/services/communicationwrapperservice.py | 9 ++++++++- .../request_api/services/requestservice.py | 1 - 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/request-management-api/request_api/resources/applicantcorrespondence.py b/request-management-api/request_api/resources/applicantcorrespondence.py index c48eb20f3..7fb6e834d 100644 --- a/request-management-api/request_api/resources/applicantcorrespondence.py +++ b/request-management-api/request_api/resources/applicantcorrespondence.py @@ -93,8 +93,8 @@ def post(requestid, ministryrequestid): applicantcorrespondencelog = FOIApplicantCorrespondenceSchema().load(data=requestjson) rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid) result = communicationwrapperservice().send_email(requestid, rawrequestid, ministryrequestid, applicantcorrespondencelog) - if result.success == True: - return {'status': result.success, 'message':result.message,'id':result.identifier} , 200 + print("communicationwrapperserviceResult", result) + return {'status': result.success, 'message':result.message,'id':result.identifier} , 200 except BusinessException: return "Error happened while saving applicant correspondence log" , 500 diff --git a/request-management-api/request_api/services/communicationwrapperservice.py b/request-management-api/request_api/services/communicationwrapperservice.py index 1cb427358..ce79b29c1 100644 --- a/request-management-api/request_api/services/communicationwrapperservice.py +++ b/request-management-api/request_api/services/communicationwrapperservice.py @@ -46,7 +46,14 @@ def __handle_fee_email(self,requestid, ministryrequestid, applicantcorrespondenc paymentservice().createpayment(requestid, ministryrequestid, _attributes, AuthHelper.getuserid()) print("isFee3") print("isFee4") - return requestservice().postcorrespondenceeventtoworkflow(requestid, ministryrequestid, identifier, applicantcorrespondencelog['attributes'], applicantcorrespondencelog['templateid']) + workflow_result = requestservice().postcorrespondenceeventtoworkflow(requestid, ministryrequestid, identifier, applicantcorrespondencelog['attributes'], applicantcorrespondencelog['templateid']) + print("isFee5") + print("workflow_result", workflow_result) + return type('Result', (object,), { + "success": True, + "message": "Fee email processed successfully.", + "identifier": identifier + })() def __is_fee_processing(self, templateid): if applicantcorrespondenceservice().gettemplatebyid(templateid).name in ['PAYONLINE','PAYOUTSTANDING']: diff --git a/request-management-api/request_api/services/requestservice.py b/request-management-api/request_api/services/requestservice.py index 8a1f3f971..121de75fa 100644 --- a/request-management-api/request_api/services/requestservice.py +++ b/request-management-api/request_api/services/requestservice.py @@ -251,7 +251,6 @@ def postcorrespondenceeventtoworkflow( wfinstanceid = workflowservice().syncwfinstance( "ministryrequest", ministryrequestid, True ) - print("foirequestschema", foirequestschema) workflowservice().postcorrenspodenceevent( wfinstanceid, ministryrequestid, From b50c4bea32302c128617ff2e1ce4bdc11c5b6f71 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Sat, 11 Jan 2025 20:51:41 -0800 Subject: [PATCH 43/87] Test Email --- .../models/FOIRequestContactInformation.py | 3 +- .../resources/applicantcorrespondence.py | 58 +++++++++++++++++-- .../services/communicationwrapperservice.py | 39 ++++--------- 3 files changed, 66 insertions(+), 34 deletions(-) diff --git a/request-management-api/request_api/models/FOIRequestContactInformation.py b/request-management-api/request_api/models/FOIRequestContactInformation.py index 05e19bdc1..1ac471c55 100644 --- a/request-management-api/request_api/models/FOIRequestContactInformation.py +++ b/request-management-api/request_api/models/FOIRequestContactInformation.py @@ -41,8 +41,7 @@ class FOIRequestContactInformation(db.Model): def getrequestcontactinformation(cls,foirequest_id,foirequestversion): requestcontact_schema = FOIRequestContactInformationSchema(many=True) _contactinfos = db.session.query(FOIRequestContactInformation).filter(FOIRequestContactInformation.foirequest_id == foirequest_id , FOIRequestContactInformation.foirequestversion_id == foirequestversion).order_by(FOIRequestContactInformation.foirequestcontactid.asc()).all() - contactinfos = requestcontact_schema.dump(_contactinfos) - print("contactinfos", contactinfos) + contactinfos = requestcontact_schema.dump(_contactinfos) return contactinfos diff --git a/request-management-api/request_api/resources/applicantcorrespondence.py b/request-management-api/request_api/resources/applicantcorrespondence.py index 7fb6e834d..743f8568c 100644 --- a/request-management-api/request_api/resources/applicantcorrespondence.py +++ b/request-management-api/request_api/resources/applicantcorrespondence.py @@ -34,6 +34,7 @@ from request_api.services.cfrfeeservice import cfrfeeservice from request_api.services.paymentservice import paymentservice from request_api.services.communicationwrapperservice import communicationwrapperservice +from request_api.services.communicationemailservice import communicationemailservice API = Namespace('FOIApplicantCorrespondenceLog', description='Endpoints for FOI Applicant Correspondence Log') TRACER = Tracer.get_instance() @@ -82,6 +83,21 @@ def get(requestid, ministryrequestid): except BusinessException: return "Error happened while fetching applicant correspondence logs" , 500 + # @staticmethod + # @TRACER.trace() + # @cross_origin(origins=allowedorigins()) + # @auth.require + # @auth.hasusertype('iao') + # def post(requestid, ministryrequestid): + # try: + # requestjson = request.get_json() + # applicantcorrespondencelog = FOIApplicantCorrespondenceSchema().load(data=requestjson) + # 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 + @staticmethod @TRACER.trace() @cross_origin(origins=allowedorigins()) @@ -90,13 +106,45 @@ def get(requestid, ministryrequestid): def post(requestid, ministryrequestid): try: requestjson = request.get_json() - applicantcorrespondencelog = FOIApplicantCorrespondenceSchema().load(data=requestjson) + applicantcorrespondencelog = FOIApplicantCorrespondenceSchema().load(data=requestjson) rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid) - result = communicationwrapperservice().send_email(requestid, rawrequestid, ministryrequestid, applicantcorrespondencelog) - print("communicationwrapperserviceResult", result) - return {'status': result.success, 'message':result.message,'id':result.identifier} , 200 + + # Save correspondence log based on request type + if ministryrequestid == 'None' or ministryrequestid is None or ("israwrequest" in applicantcorrespondencelog and applicantcorrespondencelog["israwrequest"]): + result = applicantcorrespondenceservice().saveapplicantcorrespondencelogforrawrequest(rawrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) + else: + result = applicantcorrespondenceservice().saveapplicantcorrespondencelog(requestid, ministryrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) + + if result.success: + # Fee processing logic + if FOIFlowApplicantCorrespondence.__is_fee_processing(applicantcorrespondencelog["templateid"]): + active_payment = cfrfeeservice().getactivepayment(requestid, ministryrequestid) + if active_payment is not None: + requestservice().postfeeeventtoworkflow(requestid, ministryrequestid, "CANCELLED") + + # Handle payment attributes + _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()) + print("success1") + # Post correspondence event to workflow + requestservice().postcorrespondenceeventtoworkflow(requestid, ministryrequestid, result.identifier, applicantcorrespondencelog.get('attributes'), applicantcorrespondencelog["templateid"]) + print("success2") + # Send email for non-fee templates with email recipients + if not FOIFlowApplicantCorrespondence.__is_fee_processing(applicantcorrespondencelog["templateid"]) and "emails" in applicantcorrespondencelog: + if len(applicantcorrespondencelog["emails"]) > 0: + template = applicantcorrespondenceservice().gettemplatebyid(applicantcorrespondencelog["templateid"]) + communicationemailservice().send(template, applicantcorrespondencelog) + print("success3") + 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 + + @staticmethod + def __is_fee_processing(templateid): + template = applicantcorrespondenceservice().gettemplatebyid(templateid) + return template.name in ['PAYONLINE', 'PAYOUTSTANDING'] @cors_preflight('POST,OPTIONS') @API.route('/foiflow/applicantcorrespondence/draft//') diff --git a/request-management-api/request_api/services/communicationwrapperservice.py b/request-management-api/request_api/services/communicationwrapperservice.py index ce79b29c1..cd67a4de0 100644 --- a/request-management-api/request_api/services/communicationwrapperservice.py +++ b/request-management-api/request_api/services/communicationwrapperservice.py @@ -27,38 +27,23 @@ def send_email(self, requestid, rawrequestid, ministryrequestid, applicantcorres 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, result.identifier) + if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != 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']) 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, identifier): - print("applicantcorrespondencelog", applicantcorrespondencelog) - if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != 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 - print("_paymentexpirydate1", _paymentexpirydate) - if _paymentexpirydate not in (None, ""): - print("_paymentexpirydate2", _paymentexpirydate) - paymentservice().createpayment(requestid, ministryrequestid, _attributes, AuthHelper.getuserid()) - print("isFee3") - print("isFee4") - workflow_result = requestservice().postcorrespondenceeventtoworkflow(requestid, ministryrequestid, identifier, applicantcorrespondencelog['attributes'], applicantcorrespondencelog['templateid']) - print("isFee5") - print("workflow_result", workflow_result) - return type('Result', (object,), { - "success": True, - "message": "Fee email processed successfully.", - "identifier": identifier - })() - - def __is_fee_processing(self, templateid): - if applicantcorrespondenceservice().gettemplatebyid(templateid).name in ['PAYONLINE','PAYOUTSTANDING']: - return True - return False + + @staticmethod + def __is_fee_processing(templateid): + template = applicantcorrespondenceservice().gettemplatebyid(templateid) + return template.name in ['PAYONLINE', 'PAYOUTSTANDING'] class CommuniationType(Enum): """Communication types.""" From 291d5df7be2f00fdc99af42e785370b3b82121e8 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Sun, 12 Jan 2025 11:37:54 -0800 Subject: [PATCH 44/87] Print Logs --- .../resources/applicantcorrespondence.py | 38 ++++++++++--------- .../services/communicationwrapperservice.py | 7 ++-- .../request_api/services/paymentservice.py | 7 +--- 3 files changed, 27 insertions(+), 25 deletions(-) diff --git a/request-management-api/request_api/resources/applicantcorrespondence.py b/request-management-api/request_api/resources/applicantcorrespondence.py index 743f8568c..462dfad19 100644 --- a/request-management-api/request_api/resources/applicantcorrespondence.py +++ b/request-management-api/request_api/resources/applicantcorrespondence.py @@ -110,41 +110,45 @@ def post(requestid, ministryrequestid): rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid) # Save correspondence log based on request type - if ministryrequestid == 'None' or ministryrequestid is None or ("israwrequest" in applicantcorrespondencelog and applicantcorrespondencelog["israwrequest"]): + if ministryrequestid == 'None' or ministryrequestid is None or ("israwrequest" in applicantcorrespondencelog and applicantcorrespondencelog["israwrequest"]) is True: result = applicantcorrespondenceservice().saveapplicantcorrespondencelogforrawrequest(rawrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) else: result = applicantcorrespondenceservice().saveapplicantcorrespondencelog(requestid, ministryrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) - if result.success: + # if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != None: + # requestservice().postfeeeventtoworkflow(requestid, ministryrequestid, "CANCELLED") + + if result.success == True: # Fee processing logic - if FOIFlowApplicantCorrespondence.__is_fee_processing(applicantcorrespondencelog["templateid"]): - active_payment = cfrfeeservice().getactivepayment(requestid, ministryrequestid) - if active_payment is not None: + isFee = communicationwrapperservice._is_fee_processing(applicantcorrespondencelog["templateid"]) + print("isFee", isFee) + if communicationwrapperservice._is_fee_processing(applicantcorrespondencelog["templateid"]) == True: + if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != None: requestservice().postfeeeventtoworkflow(requestid, ministryrequestid, "CANCELLED") # Handle payment attributes + print("_attributes") _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()) - print("success1") - # Post correspondence event to workflow - requestservice().postcorrespondenceeventtoworkflow(requestid, ministryrequestid, result.identifier, applicantcorrespondencelog.get('attributes'), applicantcorrespondencelog["templateid"]) - print("success2") + paymentservice().createpayment(requestid, ministryrequestid, _attributes, AuthHelper.getuserid()) + + print("success1") + # Post correspondence event to workflow + requestservice().postcorrespondenceeventtoworkflow(requestid, ministryrequestid, result.identifier, applicantcorrespondencelog['attributes'], applicantcorrespondencelog['templateid']) + print("success2") + # Send email for non-fee templates with email recipients - if not FOIFlowApplicantCorrespondence.__is_fee_processing(applicantcorrespondencelog["templateid"]) and "emails" in applicantcorrespondencelog: - if len(applicantcorrespondencelog["emails"]) > 0: + else: + if "emails" in applicantcorrespondencelog and len(applicantcorrespondencelog["emails"]) > 0: template = applicantcorrespondenceservice().gettemplatebyid(applicantcorrespondencelog["templateid"]) - communicationemailservice().send(template, applicantcorrespondencelog) + return communicationemailservice().send(template, applicantcorrespondencelog) + print("success3") return {'status': result.success, 'message': result.message, 'id': result.identifier}, 200 except BusinessException: return "Error happened while saving applicant correspondence log", 500 - @staticmethod - def __is_fee_processing(templateid): - template = applicantcorrespondenceservice().gettemplatebyid(templateid) - return template.name in ['PAYONLINE', 'PAYOUTSTANDING'] @cors_preflight('POST,OPTIONS') @API.route('/foiflow/applicantcorrespondence/draft//') diff --git a/request-management-api/request_api/services/communicationwrapperservice.py b/request-management-api/request_api/services/communicationwrapperservice.py index cd67a4de0..3182ba1ea 100644 --- a/request-management-api/request_api/services/communicationwrapperservice.py +++ b/request-management-api/request_api/services/communicationwrapperservice.py @@ -41,9 +41,10 @@ def send_email(self, requestid, rawrequestid, ministryrequestid, applicantcorres return result @staticmethod - def __is_fee_processing(templateid): - template = applicantcorrespondenceservice().gettemplatebyid(templateid) - return template.name in ['PAYONLINE', 'PAYOUTSTANDING'] + def _is_fee_processing(templateid): + if applicantcorrespondenceservice().gettemplatebyid(templateid).name in ['PAYONLINE','PAYOUTSTANDING']: + return True + return False class CommuniationType(Enum): """Communication types.""" diff --git a/request-management-api/request_api/services/paymentservice.py b/request-management-api/request_api/services/paymentservice.py index 2b2f5701f..87d091538 100644 --- a/request-management-api/request_api/services/paymentservice.py +++ b/request-management-api/request_api/services/paymentservice.py @@ -33,11 +33,8 @@ def createpayment(self, requestid, ministryrequestid, data, createdby='System'): payment.ministryrequestid = ministryrequestid payment.ministryrequestversion = ministryversion payment.paymenturl = data['paymenturl'] if 'paymenturl' in data else None - print("data", data) - paymentexpirydate = data.get('paymentexpirydate') or data.get('paymentExpiryDate') - if not paymentexpirydate: - paymentexpirydate = self.getpaymentexpirydate(requestid, ministryrequestid) - payment.paymentexpirydate = paymentexpirydate + print("data_paymentexpirydate3", data) + payment.paymentexpirydate = data['paymentExpiryDate'] if 'paymentExpiryDate' in data else self.getpaymentexpirydate(requestid, ministryrequestid) print("_paymentexpirydate3", data['paymentExpiryDate']) payment.version = 1 payment.createdby = createdby From 24a8e4fba1d87b67b47a166acd4255689cd7f28d Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Sun, 12 Jan 2025 12:03:12 -0800 Subject: [PATCH 45/87] Print --- .../resources/applicantcorrespondence.py | 98 +++++++++---------- .../services/communicationwrapperservice.py | 32 +++--- .../services/external/bpmservice.py | 2 + 3 files changed, 70 insertions(+), 62 deletions(-) diff --git a/request-management-api/request_api/resources/applicantcorrespondence.py b/request-management-api/request_api/resources/applicantcorrespondence.py index 462dfad19..3549dc910 100644 --- a/request-management-api/request_api/resources/applicantcorrespondence.py +++ b/request-management-api/request_api/resources/applicantcorrespondence.py @@ -83,21 +83,6 @@ def get(requestid, ministryrequestid): except BusinessException: return "Error happened while fetching applicant correspondence logs" , 500 - # @staticmethod - # @TRACER.trace() - # @cross_origin(origins=allowedorigins()) - # @auth.require - # @auth.hasusertype('iao') - # def post(requestid, ministryrequestid): - # try: - # requestjson = request.get_json() - # applicantcorrespondencelog = FOIApplicantCorrespondenceSchema().load(data=requestjson) - # 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 - @staticmethod @TRACER.trace() @cross_origin(origins=allowedorigins()) @@ -106,48 +91,63 @@ def get(requestid, ministryrequestid): def post(requestid, ministryrequestid): try: requestjson = request.get_json() - applicantcorrespondencelog = FOIApplicantCorrespondenceSchema().load(data=requestjson) + 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 + except BusinessException: + return "Error happened while saving applicant correspondence log" , 500 - # 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(rawrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) - else: - result = applicantcorrespondenceservice().saveapplicantcorrespondencelog(requestid, ministryrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) + # @staticmethod + # @TRACER.trace() + # @cross_origin(origins=allowedorigins()) + # @auth.require + # @auth.hasusertype('iao') + # def post(requestid, ministryrequestid): + # try: + # requestjson = request.get_json() + # applicantcorrespondencelog = FOIApplicantCorrespondenceSchema().load(data=requestjson) + # rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid) - # if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != None: - # requestservice().postfeeeventtoworkflow(requestid, ministryrequestid, "CANCELLED") + # # 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(rawrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) + # else: + # result = applicantcorrespondenceservice().saveapplicantcorrespondencelog(requestid, ministryrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) - if result.success == True: - # Fee processing logic - isFee = communicationwrapperservice._is_fee_processing(applicantcorrespondencelog["templateid"]) - print("isFee", isFee) - if communicationwrapperservice._is_fee_processing(applicantcorrespondencelog["templateid"]) == True: - if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != None: - requestservice().postfeeeventtoworkflow(requestid, ministryrequestid, "CANCELLED") + # # if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != None: + # # requestservice().postfeeeventtoworkflow(requestid, ministryrequestid, "CANCELLED") + + # if result.success == True: + # # Fee processing logic + # isFee = communicationwrapperservice._is_fee_processing(applicantcorrespondencelog["templateid"]) + # print("isFee", isFee) + # if communicationwrapperservice._is_fee_processing(applicantcorrespondencelog["templateid"]) == True: + # if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != None: + # requestservice().postfeeeventtoworkflow(requestid, ministryrequestid, "CANCELLED") - # Handle payment attributes - print("_attributes") - _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()) + # # Handle payment attributes + # print("_attributes") + # _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()) - print("success1") - # Post correspondence event to workflow - requestservice().postcorrespondenceeventtoworkflow(requestid, ministryrequestid, result.identifier, applicantcorrespondencelog['attributes'], applicantcorrespondencelog['templateid']) - print("success2") + # print("success1") + # # Post correspondence event to workflow + # requestservice().postcorrespondenceeventtoworkflow(requestid, ministryrequestid, result.identifier, applicantcorrespondencelog['attributes'], applicantcorrespondencelog['templateid']) + # print("success2") - # 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) + # # 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) - print("success3") - return {'status': result.success, 'message': result.message, 'id': result.identifier}, 200 - except BusinessException: - return "Error happened while saving applicant correspondence log", 500 + # print("success3") + # return {'status': result.success, 'message': result.message, 'id': result.identifier}, 200 + # except BusinessException: + # return "Error happened while saving applicant correspondence log", 500 @cors_preflight('POST,OPTIONS') diff --git a/request-management-api/request_api/services/communicationwrapperservice.py b/request-management-api/request_api/services/communicationwrapperservice.py index 3182ba1ea..2e3d5bc93 100644 --- a/request-management-api/request_api/services/communicationwrapperservice.py +++ b/request-management-api/request_api/services/communicationwrapperservice.py @@ -19,30 +19,36 @@ class communicationwrapperservice: """ - def send_email(self, requestid, rawrequestid, ministryrequestid, applicantcorrespondencelog): + def send_email(self,requestid, ministryrequestid, applicantcorrespondencelog): if ministryrequestid == 'None' or ministryrequestid is None or ("israwrequest" in applicantcorrespondencelog and applicantcorrespondencelog["israwrequest"]) is True: - result = applicantcorrespondenceservice().saveapplicantcorrespondencelogforrawrequest(rawrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) + result = applicantcorrespondenceservice().saveapplicantcorrespondencelogforrawrequest(requestid, 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: - if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != 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']) + return self.__handle_fee_email(requestid, ministryrequestid, applicantcorrespondencelog) else: if "emails" in applicantcorrespondencelog and len(applicantcorrespondencelog["emails"]) > 0: template = applicantcorrespondenceservice().gettemplatebyid(applicantcorrespondencelog["templateid"]) return communicationemailservice().send(template, applicantcorrespondencelog) return result - - @staticmethod - def _is_fee_processing(templateid): - if applicantcorrespondenceservice().gettemplatebyid(templateid).name in ['PAYONLINE','PAYOUTSTANDING']: + + + + + + def __handle_fee_email(self,requestid, ministryrequestid, applicantcorrespondencelog): + if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != 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']) + + def __is_fee_processing(self, templateid): + if applicantcorrespondenceservice().gettemplatebyid(templateid) in ['PAYONLINE','PAYOUTSTANDING']: return True return False diff --git a/request-management-api/request_api/services/external/bpmservice.py b/request-management-api/request_api/services/external/bpmservice.py index 1ef074eb0..c8fdaaa91 100644 --- a/request-management-api/request_api/services/external/bpmservice.py +++ b/request-management-api/request_api/services/external/bpmservice.py @@ -22,7 +22,9 @@ def createinstance(self, messagequeue, message, token=None): _variabletype = VariableType.Integer.value if key in ["id"] else VariableType.String.value _variables["variables"][key] = {"type" : _variabletype, "value": message[key]} variableschema = VariableMessageSchema().dump(_variables) + print("createresponce", createresponce) createresponce = requests.post(self._getUrl_(None,self._geProcessDefinitionKey_(messagequeue)), data=json.dumps(variableschema), headers = self._getHeaders_(token)) + print("createresponce2", createresponce) if createresponce.ok: _createresponce = json.loads(createresponce.content) return _createresponce["id"] From c74d7ca250a99537dff1bfdf063f77264b51b5b5 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Sun, 12 Jan 2025 12:23:02 -0800 Subject: [PATCH 46/87] Print --- request-management-api/request_api/resources/foiemail.py | 2 ++ .../request_api/services/emailservice.py | 1 + .../services/foirequest/requestservicegetter.py | 9 +++------ .../request_api/services/unopenedreportservice.py | 3 +-- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/request-management-api/request_api/resources/foiemail.py b/request-management-api/request_api/resources/foiemail.py index c175cc6f3..49db939a2 100644 --- a/request-management-api/request_api/resources/foiemail.py +++ b/request-management-api/request_api/resources/foiemail.py @@ -48,6 +48,8 @@ def post(requestid, ministryrequestid, servicename): try: requestjson = request.get_json() emailschema = FOIEmailSchema().load(requestjson) + print("requestjson", requestjson) + print("emailschema", emailschema) result = emailservice().send(servicename.upper(), requestid, ministryrequestid, emailschema) return json.dumps(result), 200 if result["success"] == True else 500 except ValueError as err: diff --git a/request-management-api/request_api/services/emailservice.py b/request-management-api/request_api/services/emailservice.py index 08d24f823..cc3802630 100644 --- a/request-management-api/request_api/services/emailservice.py +++ b/request-management-api/request_api/services/emailservice.py @@ -35,6 +35,7 @@ def send(self, servicename, requestid, ministryrequestid, emailschema): _messageattachmentlist = self.__get_attachments(ministryrequestid, emailschema, servicename) self.__pre_send_correspondence_audit(requestid, ministryrequestid,emailschema, content, templateconfig().isnotreceipt(servicename), _messageattachmentlist) subject = templateconfig().getsubject(servicename, requestjson) + print("requestjson", requestjson) return senderservice().send(subject, _messagepart, _messageattachmentlist, requestjson.get("email")) except Exception as ex: logging.exception(ex) diff --git a/request-management-api/request_api/services/foirequest/requestservicegetter.py b/request-management-api/request_api/services/foirequest/requestservicegetter.py index d56ef6ace..14c43eb74 100644 --- a/request-management-api/request_api/services/foirequest/requestservicegetter.py +++ b/request-management-api/request_api/services/foirequest/requestservicegetter.py @@ -26,13 +26,10 @@ class requestservicegetter: def getrequest(self,foirequestid,foiministryrequestid): request = FOIRequest.getrequest(foirequestid) - print("requestservicegetter_request", request) requestministry = FOIMinistryRequest.getrequestbyministryrequestid(foiministryrequestid) - version = request.get('version') - print("version", version) - requestcontactinformation = FOIRequestContactInformation.getrequestcontactinformation(foirequestid,version) - requestapplicants = FOIRequestApplicantMapping.getrequestapplicantinfos(foirequestid,version) - requestministrydivisions = FOIMinistryRequestDivision.getdivisions(foiministryrequestid,version) + requestcontactinformation = FOIRequestContactInformation.getrequestcontactinformation(foirequestid,request['version']) + requestapplicants = FOIRequestApplicantMapping.getrequestapplicantinfos(foirequestid,request['version']) + requestministrydivisions = FOIMinistryRequestDivision.getdivisions(foiministryrequestid,requestministry['version']) iaorestrictrequestdetails = FOIRestrictedMinistryRequest.getrestricteddetails(ministryrequestid=foiministryrequestid,type='iao') baserequestinfo = self.__preparebaseinfo(request,foiministryrequestid,requestministry,requestministrydivisions) diff --git a/request-management-api/request_api/services/unopenedreportservice.py b/request-management-api/request_api/services/unopenedreportservice.py index 67c18642b..61fa1054a 100644 --- a/request-management-api/request_api/services/unopenedreportservice.py +++ b/request-management-api/request_api/services/unopenedreportservice.py @@ -68,12 +68,11 @@ async def generateunopenedreport(self): alerts.append({"request": request, "rank": 2, "potentialmatches": alert.potentialmatches}) UnopenedReport.bulkinsert(alertdbrows) alerts.sort(key=lambda a : a.get('potentialmatches', {'highscore': -1})['highscore']) - requestjson={"email": self.reportemail, "topic": "Unopened Report"} senderservice().send( subject="Intake Unopened Request Report: " + str(date.today()), content=self.generateemailhtml(alerts), _messageattachmentlist=[], - emails=requestjson.get("email") + requestjson={"email": self.reportemail, "topic": "Unopened Report"} ) return alerts From a9cc77dbefd38ff9d6718f6930e3d03d4bd642d2 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Sun, 12 Jan 2025 15:03:44 -0800 Subject: [PATCH 47/87] Print --- .../resources/applicantcorrespondence.py | 51 ------------------- .../services/external/bpmservice.py | 5 +- .../request_api/services/paymentservice.py | 3 -- 3 files changed, 4 insertions(+), 55 deletions(-) diff --git a/request-management-api/request_api/resources/applicantcorrespondence.py b/request-management-api/request_api/resources/applicantcorrespondence.py index 3549dc910..c8df333db 100644 --- a/request-management-api/request_api/resources/applicantcorrespondence.py +++ b/request-management-api/request_api/resources/applicantcorrespondence.py @@ -97,57 +97,6 @@ def post(requestid, ministryrequestid): return {'status': result.success, 'message':result.message,'id':result.identifier} , 200 except BusinessException: return "Error happened while saving applicant correspondence log" , 500 - - # @staticmethod - # @TRACER.trace() - # @cross_origin(origins=allowedorigins()) - # @auth.require - # @auth.hasusertype('iao') - # def post(requestid, ministryrequestid): - # try: - # requestjson = request.get_json() - # applicantcorrespondencelog = FOIApplicantCorrespondenceSchema().load(data=requestjson) - # rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid) - - # # 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(rawrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) - # else: - # result = applicantcorrespondenceservice().saveapplicantcorrespondencelog(requestid, ministryrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) - - # # if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != None: - # # requestservice().postfeeeventtoworkflow(requestid, ministryrequestid, "CANCELLED") - - # if result.success == True: - # # Fee processing logic - # isFee = communicationwrapperservice._is_fee_processing(applicantcorrespondencelog["templateid"]) - # print("isFee", isFee) - # if communicationwrapperservice._is_fee_processing(applicantcorrespondencelog["templateid"]) == True: - # if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != None: - # requestservice().postfeeeventtoworkflow(requestid, ministryrequestid, "CANCELLED") - - # # Handle payment attributes - # print("_attributes") - # _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()) - - # print("success1") - # # Post correspondence event to workflow - # requestservice().postcorrespondenceeventtoworkflow(requestid, ministryrequestid, result.identifier, applicantcorrespondencelog['attributes'], applicantcorrespondencelog['templateid']) - # print("success2") - - # # 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) - - # print("success3") - # return {'status': result.success, 'message': result.message, 'id': result.identifier}, 200 - # except BusinessException: - # return "Error happened while saving applicant correspondence log", 500 @cors_preflight('POST,OPTIONS') diff --git a/request-management-api/request_api/services/external/bpmservice.py b/request-management-api/request_api/services/external/bpmservice.py index c8fdaaa91..ba208d1ae 100644 --- a/request-management-api/request_api/services/external/bpmservice.py +++ b/request-management-api/request_api/services/external/bpmservice.py @@ -169,9 +169,12 @@ def _getserviceaccounttoken_(self): return auth_response.json().get('access_token') def _getHeaders_(self, token): + print("_getHeaders_1", token) """Generate headers.""" if token is None: - token = self._getserviceaccounttoken_(); + print("_getHeaders_2", token) + token = self._getserviceaccounttoken_() + print("_getHeaders_3", token) return { "Authorization": "Bearer " + token, "Content-Type": "application/json", diff --git a/request-management-api/request_api/services/paymentservice.py b/request-management-api/request_api/services/paymentservice.py index 87d091538..3bf598034 100644 --- a/request-management-api/request_api/services/paymentservice.py +++ b/request-management-api/request_api/services/paymentservice.py @@ -33,9 +33,7 @@ def createpayment(self, requestid, ministryrequestid, data, createdby='System'): payment.ministryrequestid = ministryrequestid payment.ministryrequestversion = ministryversion payment.paymenturl = data['paymenturl'] if 'paymenturl' in data else None - print("data_paymentexpirydate3", data) payment.paymentexpirydate = data['paymentExpiryDate'] if 'paymentExpiryDate' in data else self.getpaymentexpirydate(requestid, ministryrequestid) - print("_paymentexpirydate3", data['paymentExpiryDate']) payment.version = 1 payment.createdby = createdby _payment = FOIRequestPayment.getpayment(requestid, ministryrequestid) @@ -82,7 +80,6 @@ def getpayment(self, requestid, ministryrequestid): def getpaymentexpirydate(self, requestid, ministryrequestid): payment = FOIRequestPayment.getpayment(requestid, ministryrequestid) - print("payment", payment) paymentexpirydate = payment["paymentexpirydate"] if payment not in (None, {}) else None if paymentexpirydate is not None: return parse(str(paymentexpirydate)).strftime("%Y-%m-%d") From 7339d5d82108654f98992d880da407cfb83ac352 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Sun, 12 Jan 2025 15:12:47 -0800 Subject: [PATCH 48/87] Print --- .../resources/applicantcorrespondence.py | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/request-management-api/request_api/resources/applicantcorrespondence.py b/request-management-api/request_api/resources/applicantcorrespondence.py index c8df333db..3f6f06381 100644 --- a/request-management-api/request_api/resources/applicantcorrespondence.py +++ b/request-management-api/request_api/resources/applicantcorrespondence.py @@ -82,7 +82,7 @@ def get(requestid, ministryrequestid): return json.dumps(correspondencelogs) , 200 except BusinessException: return "Error happened while fetching applicant correspondence logs" , 500 - + @staticmethod @TRACER.trace() @cross_origin(origins=allowedorigins()) @@ -92,11 +92,36 @@ 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 + + result = applicantcorrespondenceservice().saveapplicantcorrespondencelog(requestid, ministryrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) + if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != None: + requestservice().postfeeeventtoworkflow(requestid, ministryrequestid, "CANCELLED") + if result.success == True: + _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 {'status': result.success, 'message':result.message,'id':result.identifier} , 200 except BusinessException: return "Error happened while saving applicant correspondence log" , 500 + + + # @staticmethod + # @TRACER.trace() + # @cross_origin(origins=allowedorigins()) + # @auth.require + # @auth.hasusertype('iao') + # 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 + # except BusinessException: + # return "Error happened while saving applicant correspondence log" , 500 @cors_preflight('POST,OPTIONS') From 8b5a30f88b57cea5a0c68d6a92d8cca7545d693e Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Sun, 12 Jan 2025 15:34:55 -0800 Subject: [PATCH 49/87] Print --- .../request_api/resources/applicantcorrespondence.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/request-management-api/request_api/resources/applicantcorrespondence.py b/request-management-api/request_api/resources/applicantcorrespondence.py index 3f6f06381..96b4b203b 100644 --- a/request-management-api/request_api/resources/applicantcorrespondence.py +++ b/request-management-api/request_api/resources/applicantcorrespondence.py @@ -92,8 +92,17 @@ def post(requestid, ministryrequestid): try: requestjson = request.get_json() applicantcorrespondencelog = FOIApplicantCorrespondenceSchema().load(data=requestjson) + rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid) + + # Save correspondence log based on request type + if ministryrequestid == 'None' or ministryrequestid is None or ("israwrequest" in applicantcorrespondencelog and applicantcorrespondencelog["israwrequest"]) is True: + print("ministryrequestid1") + result = applicantcorrespondenceservice().saveapplicantcorrespondencelogforrawrequest(rawrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) + else: + print("ministryrequestid2") + result = applicantcorrespondenceservice().saveapplicantcorrespondencelog(requestid, ministryrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) - result = applicantcorrespondenceservice().saveapplicantcorrespondencelog(requestid, ministryrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) + print("result", result) if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != None: requestservice().postfeeeventtoworkflow(requestid, ministryrequestid, "CANCELLED") if result.success == True: From a14c7a6ab640ad59d2b1b4476da52820fcabc16d Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Sun, 12 Jan 2025 15:44:31 -0800 Subject: [PATCH 50/87] Print --- .../resources/applicantcorrespondence.py | 26 ++++++++++++------- .../services/communicationwrapperservice.py | 7 ++++- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/request-management-api/request_api/resources/applicantcorrespondence.py b/request-management-api/request_api/resources/applicantcorrespondence.py index 96b4b203b..40aef6c11 100644 --- a/request-management-api/request_api/resources/applicantcorrespondence.py +++ b/request-management-api/request_api/resources/applicantcorrespondence.py @@ -103,15 +103,23 @@ def post(requestid, ministryrequestid): result = applicantcorrespondenceservice().saveapplicantcorrespondencelog(requestid, ministryrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) print("result", result) - if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != None: - requestservice().postfeeeventtoworkflow(requestid, ministryrequestid, "CANCELLED") - if result.success == True: - _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']) - + if communicationwrapperservice._is_fee_processing(applicantcorrespondencelog["templateid"]) == True: + if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != None: + requestservice().postfeeeventtoworkflow(requestid, ministryrequestid, "CANCELLED") + if result.success == True: + _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']) + print("result2", result) + + # 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 {'status': result.success, 'message':result.message,'id':result.identifier} , 200 except BusinessException: return "Error happened while saving applicant correspondence log" , 500 diff --git a/request-management-api/request_api/services/communicationwrapperservice.py b/request-management-api/request_api/services/communicationwrapperservice.py index 2e3d5bc93..4e9b7eef9 100644 --- a/request-management-api/request_api/services/communicationwrapperservice.py +++ b/request-management-api/request_api/services/communicationwrapperservice.py @@ -33,7 +33,7 @@ def send_email(self,requestid, ministryrequestid, applicantcorrespondencelog): template = applicantcorrespondenceservice().gettemplatebyid(applicantcorrespondencelog["templateid"]) return communicationemailservice().send(template, applicantcorrespondencelog) return result - + @@ -51,6 +51,11 @@ def __is_fee_processing(self, templateid): if applicantcorrespondenceservice().gettemplatebyid(templateid) in ['PAYONLINE','PAYOUTSTANDING']: return True return False + + def _is_fee_processing(templateid): + if applicantcorrespondenceservice().gettemplatebyid(templateid).name in ['PAYONLINE','PAYOUTSTANDING']: + return True + return False class CommuniationType(Enum): """Communication types.""" From 793e2242c62b7cd7acf3387ac29ecf30acfeb3be Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Sun, 12 Jan 2025 15:56:54 -0800 Subject: [PATCH 51/87] Print --- .../request_api/resources/applicantcorrespondence.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/request-management-api/request_api/resources/applicantcorrespondence.py b/request-management-api/request_api/resources/applicantcorrespondence.py index 40aef6c11..9ed3b3719 100644 --- a/request-management-api/request_api/resources/applicantcorrespondence.py +++ b/request-management-api/request_api/resources/applicantcorrespondence.py @@ -113,14 +113,15 @@ def post(requestid, ministryrequestid): paymentservice().createpayment(requestid, ministryrequestid, _attributes, AuthHelper.getuserid()) requestservice().postcorrespondenceeventtoworkflow(requestid, ministryrequestid, result.identifier, applicantcorrespondencelog['attributes'], applicantcorrespondencelog['templateid']) print("result2", result) - + return {'status': result.success, 'message':result.message,'id':result.identifier} , 200 + # 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) + communicationemailservice().send(template, applicantcorrespondencelog) + return {'status': result.success, 'message':result.message,'id':result.identifier} , 200 - return {'status': result.success, 'message':result.message,'id':result.identifier} , 200 except BusinessException: return "Error happened while saving applicant correspondence log" , 500 From f883602dd866ea7b62a7e49ccd6e4c326fd029b6 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Sun, 12 Jan 2025 16:14:25 -0800 Subject: [PATCH 52/87] Print --- .../resources/applicantcorrespondence.py | 83 ++++++++++++------- .../services/email/senderservice.py | 1 + 2 files changed, 55 insertions(+), 29 deletions(-) diff --git a/request-management-api/request_api/resources/applicantcorrespondence.py b/request-management-api/request_api/resources/applicantcorrespondence.py index 9ed3b3719..e00c6496e 100644 --- a/request-management-api/request_api/resources/applicantcorrespondence.py +++ b/request-management-api/request_api/resources/applicantcorrespondence.py @@ -82,7 +82,7 @@ def get(requestid, ministryrequestid): return json.dumps(correspondencelogs) , 200 except BusinessException: return "Error happened while fetching applicant correspondence logs" , 500 - + @staticmethod @TRACER.trace() @cross_origin(origins=allowedorigins()) @@ -92,38 +92,63 @@ def post(requestid, ministryrequestid): try: requestjson = request.get_json() applicantcorrespondencelog = FOIApplicantCorrespondenceSchema().load(data=requestjson) - rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid) - # Save correspondence log based on request type - if ministryrequestid == 'None' or ministryrequestid is None or ("israwrequest" in applicantcorrespondencelog and applicantcorrespondencelog["israwrequest"]) is True: - print("ministryrequestid1") - result = applicantcorrespondenceservice().saveapplicantcorrespondencelogforrawrequest(rawrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) - else: - print("ministryrequestid2") - result = applicantcorrespondenceservice().saveapplicantcorrespondencelog(requestid, ministryrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) + result = applicantcorrespondenceservice().saveapplicantcorrespondencelog(requestid, ministryrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) + if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != None: + requestservice().postfeeeventtoworkflow(requestid, ministryrequestid, "CANCELLED") + if result.success == True: + _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 {'status': result.success, 'message':result.message,'id':result.identifier} , 200 + except BusinessException: + return "Error happened while saving applicant correspondence log" , 500 - print("result", result) - if communicationwrapperservice._is_fee_processing(applicantcorrespondencelog["templateid"]) == True: - if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != None: - requestservice().postfeeeventtoworkflow(requestid, ministryrequestid, "CANCELLED") - if result.success == True: - _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']) - print("result2", result) - return {'status': result.success, 'message':result.message,'id':result.identifier} , 200 + + # @staticmethod + # @TRACER.trace() + # @cross_origin(origins=allowedorigins()) + # @auth.require + # @auth.hasusertype('iao') + # def post(requestid, ministryrequestid): + # try: + # requestjson = request.get_json() + # applicantcorrespondencelog = FOIApplicantCorrespondenceSchema().load(data=requestjson) + # rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid) - # Send email for non-fee templates with email recipients - else: - if "emails" in applicantcorrespondencelog and len(applicantcorrespondencelog["emails"]) > 0: - template = applicantcorrespondenceservice().gettemplatebyid(applicantcorrespondencelog["templateid"]) - communicationemailservice().send(template, applicantcorrespondencelog) - return {'status': result.success, 'message':result.message,'id':result.identifier} , 200 + # # Save correspondence log based on request type + # if ministryrequestid == 'None' or ministryrequestid is None or ("israwrequest" in applicantcorrespondencelog and applicantcorrespondencelog["israwrequest"]) is True: + # print("ministryrequestid1") + # result = applicantcorrespondenceservice().saveapplicantcorrespondencelogforrawrequest(rawrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) + # else: + # print("ministryrequestid2") + # result = applicantcorrespondenceservice().saveapplicantcorrespondencelog(requestid, ministryrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) - except BusinessException: - return "Error happened while saving applicant correspondence log" , 500 + # print("result", result) + # if communicationwrapperservice._is_fee_processing(applicantcorrespondencelog["templateid"]) == True: + # if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != None: + # requestservice().postfeeeventtoworkflow(requestid, ministryrequestid, "CANCELLED") + # if result.success == True: + # _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']) + # print("result2", result) + # return {'status': result.success, 'message':result.message,'id':result.identifier} , 200 + + # # Send email for non-fee templates with email recipients + # else: + # if "emails" in applicantcorrespondencelog and len(applicantcorrespondencelog["emails"]) > 0: + # template = applicantcorrespondenceservice().gettemplatebyid(applicantcorrespondencelog["templateid"]) + # communicationemailservice().send(template, applicantcorrespondencelog) + # return {'status': result.success, 'message':result.message,'id':result.identifier} , 200 + + # except BusinessException: + # return "Error happened while saving applicant correspondence log" , 500 # @staticmethod diff --git a/request-management-api/request_api/services/email/senderservice.py b/request-management-api/request_api/services/email/senderservice.py index 019fcadb2..e5c13d876 100644 --- a/request-management-api/request_api/services/email/senderservice.py +++ b/request-management-api/request_api/services/email/senderservice.py @@ -80,6 +80,7 @@ def send(self, subject, content, _messageattachmentlist, emails, from_email = No smtpobj.ehlo() #smtpobj.login(MAIL_SRV_USERID, MAIL_SRV_PASSWORD) smtpobj.sendmail(msg['From'], msg['To'], msg.as_string()) + print("msgSTR", msg.as_string()) smtpobj.quit() logging.debug("End: Send email for request") return DefaultMethodResult(True,'Sent successfully', -1) From da0bc47a4de7ac3f2c48e1463ac35dd39a0fa863 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Sun, 12 Jan 2025 16:29:21 -0800 Subject: [PATCH 53/87] Print --- .../resources/applicantcorrespondence.py | 106 +++++++++--------- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/request-management-api/request_api/resources/applicantcorrespondence.py b/request-management-api/request_api/resources/applicantcorrespondence.py index e00c6496e..46d422415 100644 --- a/request-management-api/request_api/resources/applicantcorrespondence.py +++ b/request-management-api/request_api/resources/applicantcorrespondence.py @@ -83,31 +83,6 @@ def get(requestid, ministryrequestid): except BusinessException: return "Error happened while fetching applicant correspondence logs" , 500 - @staticmethod - @TRACER.trace() - @cross_origin(origins=allowedorigins()) - @auth.require - @auth.hasusertype('iao') - def post(requestid, ministryrequestid): - try: - requestjson = request.get_json() - applicantcorrespondencelog = FOIApplicantCorrespondenceSchema().load(data=requestjson) - - result = applicantcorrespondenceservice().saveapplicantcorrespondencelog(requestid, ministryrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) - if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != None: - requestservice().postfeeeventtoworkflow(requestid, ministryrequestid, "CANCELLED") - if result.success == True: - _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 {'status': result.success, 'message':result.message,'id':result.identifier} , 200 - except BusinessException: - return "Error happened while saving applicant correspondence log" , 500 - - # @staticmethod # @TRACER.trace() # @cross_origin(origins=allowedorigins()) @@ -117,39 +92,64 @@ def post(requestid, ministryrequestid): # try: # requestjson = request.get_json() # applicantcorrespondencelog = FOIApplicantCorrespondenceSchema().load(data=requestjson) - # rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid) - # # Save correspondence log based on request type - # if ministryrequestid == 'None' or ministryrequestid is None or ("israwrequest" in applicantcorrespondencelog and applicantcorrespondencelog["israwrequest"]) is True: - # print("ministryrequestid1") - # result = applicantcorrespondenceservice().saveapplicantcorrespondencelogforrawrequest(rawrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) - # else: - # print("ministryrequestid2") - # result = applicantcorrespondenceservice().saveapplicantcorrespondencelog(requestid, ministryrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) + # result = applicantcorrespondenceservice().saveapplicantcorrespondencelog(requestid, ministryrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) + # if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != None: + # requestservice().postfeeeventtoworkflow(requestid, ministryrequestid, "CANCELLED") + # if result.success == True: + # _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 {'status': result.success, 'message':result.message,'id':result.identifier} , 200 + # except BusinessException: + # return "Error happened while saving applicant correspondence log" , 500 + + + @staticmethod + @TRACER.trace() + @cross_origin(origins=allowedorigins()) + @auth.require + @auth.hasusertype('iao') + def post(requestid, ministryrequestid): + try: + requestjson = request.get_json() + applicantcorrespondencelog = FOIApplicantCorrespondenceSchema().load(data=requestjson) + rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid) - # print("result", result) - # if communicationwrapperservice._is_fee_processing(applicantcorrespondencelog["templateid"]) == True: - # if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != None: - # requestservice().postfeeeventtoworkflow(requestid, ministryrequestid, "CANCELLED") - # if result.success == True: - # _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']) - # print("result2", result) - # return {'status': result.success, 'message':result.message,'id':result.identifier} , 200 + # Save correspondence log based on request type + if ministryrequestid == 'None' or ministryrequestid is None or ("israwrequest" in applicantcorrespondencelog and applicantcorrespondencelog["israwrequest"]) is True: + print("ministryrequestid1") + result = applicantcorrespondenceservice().saveapplicantcorrespondencelogforrawrequest(rawrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) + else: + print("ministryrequestid2") + result = applicantcorrespondenceservice().saveapplicantcorrespondencelog(requestid, ministryrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) - # # Send email for non-fee templates with email recipients - # else: - # if "emails" in applicantcorrespondencelog and len(applicantcorrespondencelog["emails"]) > 0: - # template = applicantcorrespondenceservice().gettemplatebyid(applicantcorrespondencelog["templateid"]) - # communicationemailservice().send(template, applicantcorrespondencelog) - # return {'status': result.success, 'message':result.message,'id':result.identifier} , 200 + print("result", result) + if communicationwrapperservice._is_fee_processing(applicantcorrespondencelog["templateid"]) == True: + if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != None: + requestservice().postfeeeventtoworkflow(requestid, ministryrequestid, "CANCELLED") + if result.success == True: + _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']) + print("result2", result) + return {'status': result.success, 'message':result.message,'id':result.identifier} , 200 - # except BusinessException: - # return "Error happened while saving applicant correspondence log" , 500 + # Send email for non-fee templates with email recipients + else: + if "emails" in applicantcorrespondencelog and len(applicantcorrespondencelog["emails"]) > 0: + template = applicantcorrespondenceservice().gettemplatebyid(applicantcorrespondencelog["templateid"]) + communicationemailservice().send(template, applicantcorrespondencelog) + return {'status': result.success, 'message':result.message,'id':result.identifier} , 200 + except BusinessException: + return "Error happened while saving applicant correspondence log" , 500 + # @staticmethod # @TRACER.trace() From 38b9c6479787af88b754a77d269e4ef28ba529c9 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Sun, 12 Jan 2025 16:44:35 -0800 Subject: [PATCH 54/87] Print --- .../resources/applicantcorrespondence.py | 64 +++---------------- .../services/communicationwrapperservice.py | 63 +++++++++++++----- 2 files changed, 54 insertions(+), 73 deletions(-) diff --git a/request-management-api/request_api/resources/applicantcorrespondence.py b/request-management-api/request_api/resources/applicantcorrespondence.py index 46d422415..adbe1458b 100644 --- a/request-management-api/request_api/resources/applicantcorrespondence.py +++ b/request-management-api/request_api/resources/applicantcorrespondence.py @@ -83,31 +83,6 @@ def get(requestid, ministryrequestid): except BusinessException: return "Error happened while fetching applicant correspondence logs" , 500 - # @staticmethod - # @TRACER.trace() - # @cross_origin(origins=allowedorigins()) - # @auth.require - # @auth.hasusertype('iao') - # def post(requestid, ministryrequestid): - # try: - # requestjson = request.get_json() - # applicantcorrespondencelog = FOIApplicantCorrespondenceSchema().load(data=requestjson) - - # result = applicantcorrespondenceservice().saveapplicantcorrespondencelog(requestid, ministryrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) - # if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != None: - # requestservice().postfeeeventtoworkflow(requestid, ministryrequestid, "CANCELLED") - # if result.success == True: - # _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 {'status': result.success, 'message':result.message,'id':result.identifier} , 200 - # except BusinessException: - # return "Error happened while saving applicant correspondence log" , 500 - - @staticmethod @TRACER.trace() @cross_origin(origins=allowedorigins()) @@ -116,40 +91,17 @@ def get(requestid, ministryrequestid): def post(requestid, ministryrequestid): try: requestjson = request.get_json() - applicantcorrespondencelog = FOIApplicantCorrespondenceSchema().load(data=requestjson) + applicantcorrespondencelog = FOIApplicantCorrespondenceSchema().load(data=requestjson) rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid) - # Save correspondence log based on request type - if ministryrequestid == 'None' or ministryrequestid is None or ("israwrequest" in applicantcorrespondencelog and applicantcorrespondencelog["israwrequest"]) is True: - print("ministryrequestid1") - result = applicantcorrespondenceservice().saveapplicantcorrespondencelogforrawrequest(rawrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) - else: - print("ministryrequestid2") - result = applicantcorrespondenceservice().saveapplicantcorrespondencelog(requestid, ministryrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) - - print("result", result) - if communicationwrapperservice._is_fee_processing(applicantcorrespondencelog["templateid"]) == True: - if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != None: - requestservice().postfeeeventtoworkflow(requestid, ministryrequestid, "CANCELLED") - if result.success == True: - _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']) - print("result2", result) - return {'status': result.success, 'message':result.message,'id':result.identifier} , 200 - - # Send email for non-fee templates with email recipients - else: - if "emails" in applicantcorrespondencelog and len(applicantcorrespondencelog["emails"]) > 0: - template = applicantcorrespondenceservice().gettemplatebyid(applicantcorrespondencelog["templateid"]) - communicationemailservice().send(template, applicantcorrespondencelog) - return {'status': result.success, 'message':result.message,'id':result.identifier} , 200 - + # Call the service method + result = communicationwrapperservice().send_email( + requestid, ministryrequestid, rawrequestid, applicantcorrespondencelog + ) + return result except BusinessException: - return "Error happened while saving applicant correspondence log" , 500 - + return "Error happened while saving applicant correspondence log", 500 + # @staticmethod # @TRACER.trace() diff --git a/request-management-api/request_api/services/communicationwrapperservice.py b/request-management-api/request_api/services/communicationwrapperservice.py index 4e9b7eef9..7cafc462f 100644 --- a/request-management-api/request_api/services/communicationwrapperservice.py +++ b/request-management-api/request_api/services/communicationwrapperservice.py @@ -19,24 +19,53 @@ class communicationwrapperservice: """ - def send_email(self,requestid, ministryrequestid, applicantcorrespondencelog): + # def send_email(self,requestid, ministryrequestid, applicantcorrespondencelog): + # if ministryrequestid == 'None' or ministryrequestid is None or ("israwrequest" in applicantcorrespondencelog and applicantcorrespondencelog["israwrequest"]) is True: + # result = applicantcorrespondenceservice().saveapplicantcorrespondencelogforrawrequest(requestid, 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) + # else: + # if "emails" in applicantcorrespondencelog and len(applicantcorrespondencelog["emails"]) > 0: + # template = applicantcorrespondenceservice().gettemplatebyid(applicantcorrespondencelog["templateid"]) + # return communicationemailservice().send(template, applicantcorrespondencelog) + # return result + + def send_email(self, requestid, ministryrequestid, rawrequestid, 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()) + print("ministryrequestid1") + result = applicantcorrespondenceservice().saveapplicantcorrespondencelogforrawrequest(rawrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) else: + print("ministryrequestid2") 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) - else: - if "emails" in applicantcorrespondencelog and len(applicantcorrespondencelog["emails"]) > 0: - template = applicantcorrespondenceservice().gettemplatebyid(applicantcorrespondencelog["templateid"]) - return communicationemailservice().send(template, applicantcorrespondencelog) - return result - + # Handle fee processing templates + if self.__is_fee_processing(applicantcorrespondencelog["templateid"]): + if cfrfeeservice().getactivepayment(requestid, ministryrequestid) is not None: + requestservice().postfeeeventtoworkflow(requestid, ministryrequestid, "CANCELLED") + + if result.success == True: + _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']) + print("result2", result) + return {'status': result.success, 'message':result.message,'id':result.identifier} , 200 + # 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"]) + communicationemailservice().send(template, applicantcorrespondencelog) + return {'status': result.success, 'message':result.message,'id':result.identifier} , 200 + return {'status': result.success, 'message': result.message, 'id': result.identifier}, 200 def __handle_fee_email(self,requestid, ministryrequestid, applicantcorrespondencelog): if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != None: @@ -48,14 +77,14 @@ def __handle_fee_email(self,requestid, ministryrequestid, applicantcorrespondenc return requestservice().postcorrespondenceeventtoworkflow(requestid, ministryrequestid, result.identifier, applicantcorrespondencelog['attributes'], applicantcorrespondencelog['templateid']) def __is_fee_processing(self, templateid): - if applicantcorrespondenceservice().gettemplatebyid(templateid) in ['PAYONLINE','PAYOUTSTANDING']: - return True - return False - - def _is_fee_processing(templateid): if applicantcorrespondenceservice().gettemplatebyid(templateid).name in ['PAYONLINE','PAYOUTSTANDING']: return True return False + + # def _is_fee_processing(templateid): + # if applicantcorrespondenceservice().gettemplatebyid(templateid).name in ['PAYONLINE','PAYOUTSTANDING']: + # return True + # return False class CommuniationType(Enum): """Communication types.""" From 089bf9f84055ad88ece0d0ce6313b934442ea386 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Sun, 12 Jan 2025 16:58:21 -0800 Subject: [PATCH 55/87] Print --- .../resources/applicantcorrespondence.py | 26 +++---------------- .../services/communicationwrapperservice.py | 15 +++-------- 2 files changed, 7 insertions(+), 34 deletions(-) diff --git a/request-management-api/request_api/resources/applicantcorrespondence.py b/request-management-api/request_api/resources/applicantcorrespondence.py index adbe1458b..1b889de5f 100644 --- a/request-management-api/request_api/resources/applicantcorrespondence.py +++ b/request-management-api/request_api/resources/applicantcorrespondence.py @@ -93,31 +93,11 @@ def post(requestid, ministryrequestid): requestjson = request.get_json() applicantcorrespondencelog = FOIApplicantCorrespondenceSchema().load(data=requestjson) rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid) - - # Call the service method - result = communicationwrapperservice().send_email( - requestid, ministryrequestid, rawrequestid, applicantcorrespondencelog - ) - return result + result = communicationwrapperservice().send_email(requestid, ministryrequestid, rawrequestid, applicantcorrespondencelog) + return {'status': result.success, 'message': result.message, 'id': result.identifier}, 200 except BusinessException: return "Error happened while saving applicant correspondence log", 500 - - - # @staticmethod - # @TRACER.trace() - # @cross_origin(origins=allowedorigins()) - # @auth.require - # @auth.hasusertype('iao') - # 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 - # except BusinessException: - # return "Error happened while saving applicant correspondence log" , 500 - + @cors_preflight('POST,OPTIONS') @API.route('/foiflow/applicantcorrespondence/draft//') diff --git a/request-management-api/request_api/services/communicationwrapperservice.py b/request-management-api/request_api/services/communicationwrapperservice.py index 7cafc462f..7ac3587be 100644 --- a/request-management-api/request_api/services/communicationwrapperservice.py +++ b/request-management-api/request_api/services/communicationwrapperservice.py @@ -34,13 +34,12 @@ class communicationwrapperservice: # return communicationemailservice().send(template, applicantcorrespondencelog) # return result + def send_email(self, requestid, ministryrequestid, rawrequestid, applicantcorrespondencelog): # Save correspondence log based on request type if ministryrequestid == 'None' or ministryrequestid is None or ("israwrequest" in applicantcorrespondencelog and applicantcorrespondencelog["israwrequest"]) is True: - print("ministryrequestid1") result = applicantcorrespondenceservice().saveapplicantcorrespondencelogforrawrequest(rawrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) else: - print("ministryrequestid2") result = applicantcorrespondenceservice().saveapplicantcorrespondencelog(requestid, ministryrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) # Handle fee processing templates @@ -54,8 +53,6 @@ def send_email(self, requestid, ministryrequestid, rawrequestid, applicantcorres if _paymentexpirydate not in (None, ""): paymentservice().createpayment(requestid, ministryrequestid, _attributes, AuthHelper.getuserid()) requestservice().postcorrespondenceeventtoworkflow(requestid, ministryrequestid, result.identifier, applicantcorrespondencelog['attributes'], applicantcorrespondencelog['templateid']) - print("result2", result) - return {'status': result.success, 'message':result.message,'id':result.identifier} , 200 # Handle non-fee templates # Send email for non-fee templates with email recipients @@ -63,9 +60,9 @@ def send_email(self, requestid, ministryrequestid, rawrequestid, applicantcorres if "emails" in applicantcorrespondencelog and len(applicantcorrespondencelog["emails"]) > 0: template = applicantcorrespondenceservice().gettemplatebyid(applicantcorrespondencelog["templateid"]) communicationemailservice().send(template, applicantcorrespondencelog) - return {'status': result.success, 'message':result.message,'id':result.identifier} , 200 - return {'status': result.success, 'message': result.message, 'id': result.identifier}, 200 + return result + def __handle_fee_email(self,requestid, ministryrequestid, applicantcorrespondencelog): if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != None: @@ -76,15 +73,11 @@ def __handle_fee_email(self,requestid, ministryrequestid, applicantcorrespondenc paymentservice().createpayment(requestid, ministryrequestid, _attributes, AuthHelper.getuserid()) return requestservice().postcorrespondenceeventtoworkflow(requestid, ministryrequestid, result.identifier, applicantcorrespondencelog['attributes'], applicantcorrespondencelog['templateid']) + def __is_fee_processing(self, templateid): if applicantcorrespondenceservice().gettemplatebyid(templateid).name in ['PAYONLINE','PAYOUTSTANDING']: return True return False - - # def _is_fee_processing(templateid): - # if applicantcorrespondenceservice().gettemplatebyid(templateid).name in ['PAYONLINE','PAYOUTSTANDING']: - # return True - # return False class CommuniationType(Enum): """Communication types.""" From 8abc01e18ae33a1ce5df12bfacf96255c5aa608a Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Sun, 12 Jan 2025 17:12:05 -0800 Subject: [PATCH 56/87] Cleanup --- .../models/FOIRequestContactInformation.py | 2 +- .../resources/applicantcorrespondence.py | 1 - .../request_api/resources/foiemail.py | 2 -- .../services/communicationwrapperservice.py | 25 ++++++------------- .../services/email/senderservice.py | 1 - .../services/external/bpmservice.py | 5 ---- 6 files changed, 9 insertions(+), 27 deletions(-) diff --git a/request-management-api/request_api/models/FOIRequestContactInformation.py b/request-management-api/request_api/models/FOIRequestContactInformation.py index 1ac471c55..be1b7d6f3 100644 --- a/request-management-api/request_api/models/FOIRequestContactInformation.py +++ b/request-management-api/request_api/models/FOIRequestContactInformation.py @@ -41,7 +41,7 @@ class FOIRequestContactInformation(db.Model): def getrequestcontactinformation(cls,foirequest_id,foirequestversion): requestcontact_schema = FOIRequestContactInformationSchema(many=True) _contactinfos = db.session.query(FOIRequestContactInformation).filter(FOIRequestContactInformation.foirequest_id == foirequest_id , FOIRequestContactInformation.foirequestversion_id == foirequestversion).order_by(FOIRequestContactInformation.foirequestcontactid.asc()).all() - contactinfos = requestcontact_schema.dump(_contactinfos) + contactinfos = requestcontact_schema.dump(_contactinfos) return contactinfos diff --git a/request-management-api/request_api/resources/applicantcorrespondence.py b/request-management-api/request_api/resources/applicantcorrespondence.py index 1b889de5f..725302d55 100644 --- a/request-management-api/request_api/resources/applicantcorrespondence.py +++ b/request-management-api/request_api/resources/applicantcorrespondence.py @@ -34,7 +34,6 @@ from request_api.services.cfrfeeservice import cfrfeeservice from request_api.services.paymentservice import paymentservice from request_api.services.communicationwrapperservice import communicationwrapperservice -from request_api.services.communicationemailservice import communicationemailservice API = Namespace('FOIApplicantCorrespondenceLog', description='Endpoints for FOI Applicant Correspondence Log') TRACER = Tracer.get_instance() diff --git a/request-management-api/request_api/resources/foiemail.py b/request-management-api/request_api/resources/foiemail.py index 49db939a2..c175cc6f3 100644 --- a/request-management-api/request_api/resources/foiemail.py +++ b/request-management-api/request_api/resources/foiemail.py @@ -48,8 +48,6 @@ def post(requestid, ministryrequestid, servicename): try: requestjson = request.get_json() emailschema = FOIEmailSchema().load(requestjson) - print("requestjson", requestjson) - print("emailschema", emailschema) result = emailservice().send(servicename.upper(), requestid, ministryrequestid, emailschema) return json.dumps(result), 200 if result["success"] == True else 500 except ValueError as err: diff --git a/request-management-api/request_api/services/communicationwrapperservice.py b/request-management-api/request_api/services/communicationwrapperservice.py index 7ac3587be..99cdaeb38 100644 --- a/request-management-api/request_api/services/communicationwrapperservice.py +++ b/request-management-api/request_api/services/communicationwrapperservice.py @@ -44,34 +44,25 @@ def send_email(self, requestid, ministryrequestid, rawrequestid, applicantcorres # Handle fee processing templates if self.__is_fee_processing(applicantcorrespondencelog["templateid"]): - if cfrfeeservice().getactivepayment(requestid, ministryrequestid) is not None: - requestservice().postfeeeventtoworkflow(requestid, ministryrequestid, "CANCELLED") - - if result.success == True: - _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']) - - # Handle non-fee templates - # Send email for non-fee templates with email recipients + 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"]) 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") + + if result.success == True: _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']) + paymentservice().createpayment(requestid, ministryrequestid, _attributes, AuthHelper.getuserid()) + requestservice().postcorrespondenceeventtoworkflow(requestid, ministryrequestid, result.identifier, applicantcorrespondencelog['attributes'], applicantcorrespondencelog['templateid']) def __is_fee_processing(self, templateid): diff --git a/request-management-api/request_api/services/email/senderservice.py b/request-management-api/request_api/services/email/senderservice.py index e5c13d876..019fcadb2 100644 --- a/request-management-api/request_api/services/email/senderservice.py +++ b/request-management-api/request_api/services/email/senderservice.py @@ -80,7 +80,6 @@ def send(self, subject, content, _messageattachmentlist, emails, from_email = No smtpobj.ehlo() #smtpobj.login(MAIL_SRV_USERID, MAIL_SRV_PASSWORD) smtpobj.sendmail(msg['From'], msg['To'], msg.as_string()) - print("msgSTR", msg.as_string()) smtpobj.quit() logging.debug("End: Send email for request") return DefaultMethodResult(True,'Sent successfully', -1) diff --git a/request-management-api/request_api/services/external/bpmservice.py b/request-management-api/request_api/services/external/bpmservice.py index ba208d1ae..09534a129 100644 --- a/request-management-api/request_api/services/external/bpmservice.py +++ b/request-management-api/request_api/services/external/bpmservice.py @@ -22,9 +22,7 @@ def createinstance(self, messagequeue, message, token=None): _variabletype = VariableType.Integer.value if key in ["id"] else VariableType.String.value _variables["variables"][key] = {"type" : _variabletype, "value": message[key]} variableschema = VariableMessageSchema().dump(_variables) - print("createresponce", createresponce) createresponce = requests.post(self._getUrl_(None,self._geProcessDefinitionKey_(messagequeue)), data=json.dumps(variableschema), headers = self._getHeaders_(token)) - print("createresponce2", createresponce) if createresponce.ok: _createresponce = json.loads(createresponce.content) return _createresponce["id"] @@ -169,12 +167,9 @@ def _getserviceaccounttoken_(self): return auth_response.json().get('access_token') def _getHeaders_(self, token): - print("_getHeaders_1", token) """Generate headers.""" if token is None: - print("_getHeaders_2", token) token = self._getserviceaccounttoken_() - print("_getHeaders_3", token) return { "Authorization": "Bearer " + token, "Content-Type": "application/json", From acb1ac5e98acec6f48205793ab734f2d45831493 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Sun, 12 Jan 2025 17:14:28 -0800 Subject: [PATCH 57/87] Cleanup --- request-management-api/request_api/services/emailservice.py | 1 - .../request_api/services/unopenedreportservice.py | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/request-management-api/request_api/services/emailservice.py b/request-management-api/request_api/services/emailservice.py index cc3802630..08d24f823 100644 --- a/request-management-api/request_api/services/emailservice.py +++ b/request-management-api/request_api/services/emailservice.py @@ -35,7 +35,6 @@ def send(self, servicename, requestid, ministryrequestid, emailschema): _messageattachmentlist = self.__get_attachments(ministryrequestid, emailschema, servicename) self.__pre_send_correspondence_audit(requestid, ministryrequestid,emailschema, content, templateconfig().isnotreceipt(servicename), _messageattachmentlist) subject = templateconfig().getsubject(servicename, requestjson) - print("requestjson", requestjson) return senderservice().send(subject, _messagepart, _messageattachmentlist, requestjson.get("email")) except Exception as ex: logging.exception(ex) diff --git a/request-management-api/request_api/services/unopenedreportservice.py b/request-management-api/request_api/services/unopenedreportservice.py index 61fa1054a..67c18642b 100644 --- a/request-management-api/request_api/services/unopenedreportservice.py +++ b/request-management-api/request_api/services/unopenedreportservice.py @@ -68,11 +68,12 @@ async def generateunopenedreport(self): alerts.append({"request": request, "rank": 2, "potentialmatches": alert.potentialmatches}) UnopenedReport.bulkinsert(alertdbrows) alerts.sort(key=lambda a : a.get('potentialmatches', {'highscore': -1})['highscore']) + requestjson={"email": self.reportemail, "topic": "Unopened Report"} senderservice().send( subject="Intake Unopened Request Report: " + str(date.today()), content=self.generateemailhtml(alerts), _messageattachmentlist=[], - requestjson={"email": self.reportemail, "topic": "Unopened Report"} + emails=requestjson.get("email") ) return alerts From 37780be1baddc98c1fc51d1f5e72c35dc8a020e1 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Mon, 13 Jan 2025 09:25:29 -0800 Subject: [PATCH 58/87] Cleanup --- .../services/communicationwrapperservice.py | 45 ++++++------------- .../services/external/bpmservice.py | 2 +- 2 files changed, 15 insertions(+), 32 deletions(-) diff --git a/request-management-api/request_api/services/communicationwrapperservice.py b/request-management-api/request_api/services/communicationwrapperservice.py index 99cdaeb38..7e5ba28d6 100644 --- a/request-management-api/request_api/services/communicationwrapperservice.py +++ b/request-management-api/request_api/services/communicationwrapperservice.py @@ -19,22 +19,6 @@ class communicationwrapperservice: """ - # def send_email(self,requestid, ministryrequestid, applicantcorrespondencelog): - # if ministryrequestid == 'None' or ministryrequestid is None or ("israwrequest" in applicantcorrespondencelog and applicantcorrespondencelog["israwrequest"]) is True: - # result = applicantcorrespondenceservice().saveapplicantcorrespondencelogforrawrequest(requestid, 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) - # else: - # if "emails" in applicantcorrespondencelog and len(applicantcorrespondencelog["emails"]) > 0: - # template = applicantcorrespondenceservice().gettemplatebyid(applicantcorrespondencelog["templateid"]) - # return communicationemailservice().send(template, applicantcorrespondencelog) - # return result - - def send_email(self, requestid, ministryrequestid, rawrequestid, applicantcorrespondencelog): # Save correspondence log based on request type if ministryrequestid == 'None' or ministryrequestid is None or ("israwrequest" in applicantcorrespondencelog and applicantcorrespondencelog["israwrequest"]) is True: @@ -42,26 +26,25 @@ def send_email(self, requestid, ministryrequestid, rawrequestid, applicantcorres else: result = applicantcorrespondenceservice().saveapplicantcorrespondencelog(requestid, ministryrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) - # Handle fee processing templates - if self.__is_fee_processing(applicantcorrespondencelog["templateid"]): - 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"]) - communicationemailservice().send(template, applicantcorrespondencelog) - return result + if result.success == True: + # Handle fee processing templates + if self.__is_fee_processing(applicantcorrespondencelog["templateid"]): + 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"]) + communicationemailservice().send(template, applicantcorrespondencelog) + return result def __handle_fee_email(self, requestid, ministryrequestid, result, applicantcorrespondencelog): if cfrfeeservice().getactivepayment(requestid, ministryrequestid) is not None: requestservice().postfeeeventtoworkflow(requestid, ministryrequestid, "CANCELLED") - - if result.success == True: - _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()) + _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']) diff --git a/request-management-api/request_api/services/external/bpmservice.py b/request-management-api/request_api/services/external/bpmservice.py index 09534a129..1ef074eb0 100644 --- a/request-management-api/request_api/services/external/bpmservice.py +++ b/request-management-api/request_api/services/external/bpmservice.py @@ -169,7 +169,7 @@ def _getserviceaccounttoken_(self): def _getHeaders_(self, token): """Generate headers.""" if token is None: - token = self._getserviceaccounttoken_() + token = self._getserviceaccounttoken_(); return { "Authorization": "Bearer " + token, "Content-Type": "application/json", From 21bffca526b855b8ac6458696ae7d7b2604cc1a9 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Mon, 13 Jan 2025 10:32:53 -0800 Subject: [PATCH 59/87] Print EmailRequest --- request-management-api/request_api/services/emailservice.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/request-management-api/request_api/services/emailservice.py b/request-management-api/request_api/services/emailservice.py index 08d24f823..057ea4779 100644 --- a/request-management-api/request_api/services/emailservice.py +++ b/request-management-api/request_api/services/emailservice.py @@ -26,6 +26,9 @@ class emailservice: def send(self, servicename, requestid, ministryrequestid, emailschema): try: requestjson = requestservice().getrequestdetails(requestid,ministryrequestid) + increment_number = 1 # Initialize the number + print("requestjson", increment_number, requestjson) + increment_number += 1 # Increment the number _templatename = self.__getvaluefromschema(emailschema, "templatename") servicename = _templatename if servicename == ServiceName.correspondence.value.upper() else servicename _applicantcorrespondenceid = self.__getvaluefromschema(emailschema, "applicantcorrespondenceid") @@ -99,4 +102,6 @@ def __upload(self, filename, filebytes, ministryrequestid, requestjson, category logging.exception(ex) def __getvaluefromschema(self, emailschema, property): + schema = emailschema.get(property) if property in emailschema else None + print("schema", schema) return emailschema.get(property) if property in emailschema else None From 45dcce07a9cadacf4921aba1fe6751ba477a69f3 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Mon, 13 Jan 2025 10:53:21 -0800 Subject: [PATCH 60/87] Print Prev Code --- .../resources/applicantcorrespondence.py | 16 +++++- .../applicantcorrespondencelog.py | 54 ++++++++++++------- 2 files changed, 50 insertions(+), 20 deletions(-) diff --git a/request-management-api/request_api/resources/applicantcorrespondence.py b/request-management-api/request_api/resources/applicantcorrespondence.py index 725302d55..29ece3ef6 100644 --- a/request-management-api/request_api/resources/applicantcorrespondence.py +++ b/request-management-api/request_api/resources/applicantcorrespondence.py @@ -69,6 +69,19 @@ def get(): @API.route('/foiflow/applicantcorrespondence//') class FOIFlowApplicantCorrespondence(Resource): + # @staticmethod + # @TRACER.trace() + # @cross_origin(origins=allowedorigins()) + # @auth.require + # @auth.hasusertype('iao') + # def get(requestid, ministryrequestid): + # try: + # rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid) + # correspondencelogs = applicantcorrespondenceservice().getapplicantcorrespondencelogs(ministryrequestid, rawrequestid) + # return json.dumps(correspondencelogs) , 200 + # except BusinessException: + # return "Error happened while fetching applicant correspondence logs" , 500 + @staticmethod @TRACER.trace() @cross_origin(origins=allowedorigins()) @@ -76,8 +89,7 @@ class FOIFlowApplicantCorrespondence(Resource): @auth.hasusertype('iao') def get(requestid, ministryrequestid): try: - rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid) - correspondencelogs = applicantcorrespondenceservice().getapplicantcorrespondencelogs(ministryrequestid, rawrequestid) + correspondencelogs = applicantcorrespondenceservice().getapplicantcorrespondencelogs(ministryrequestid) return json.dumps(correspondencelogs) , 200 except BusinessException: return "Error happened while fetching applicant correspondence logs" , 500 diff --git a/request-management-api/request_api/services/applicantcorrespondence/applicantcorrespondencelog.py b/request-management-api/request_api/services/applicantcorrespondence/applicantcorrespondencelog.py index 4e2a21ec5..2b24ada27 100644 --- a/request-management-api/request_api/services/applicantcorrespondence/applicantcorrespondencelog.py +++ b/request-management-api/request_api/services/applicantcorrespondence/applicantcorrespondencelog.py @@ -28,35 +28,53 @@ def gettemplatebyid(self, templateid): """ Returns the active applicant correspondence templates """ return ApplicationCorrespondenceTemplate.get_template_by_id(templateid) - - def getapplicantcorrespondencelogs(self,ministryrequestid, rawrequestid): + + def getapplicantcorrespondencelogs(self,ministryrequestid): """ Returns the active applicant correspondence logs """ - _correspondencelogs = FOIApplicantCorrespondenceRawRequest.getapplicantcorrespondencesrawrequests(rawrequestid) - _correspondenceattachments = FOIApplicantCorrespondenceAttachmentRawRequest.getcorrespondenceattachmentsbyrawrequestid(rawrequestid) - _correspondenceemails = FOIApplicantCorrespondenceEmailRawRequest.getapplicantcorrespondenceemails(rawrequestid) - if ministryrequestid != 'None': - _correspondencelogs.extend(FOIApplicantCorrespondence.getapplicantcorrespondences(ministryrequestid)) - _correspondenceattachments.extend(FOIApplicantCorrespondenceAttachment.getcorrespondenceattachmentsbyministryid(ministryrequestid)) - _correspondenceemails.extend(FOIApplicantCorrespondenceEmail.getapplicantcorrespondenceemails(ministryrequestid)) + _correspondencelogs = FOIApplicantCorrespondence.getapplicantcorrespondences(ministryrequestid) correspondencelogs =[] for _correpondencelog in _correspondencelogs: attachments = [] - for _attachment in self.__getattachmentsbyid(_correspondenceattachments, _correpondencelog['applicantcorrespondenceid'], _correpondencelog['version']): + for _attachment in _correpondencelog['attachments']: attachment = { - "applicantcorrespondenceattachmentid" : _attachment['applicantcorrespondenceattachmentid'], - "documenturipath" : _attachment['attachmentdocumenturipath'], - "filename" : _attachment['attachmentfilename'], + "applicantcorrespondenceattachmentid" : _attachment.applicantcorrespondenceattachmentid, + "documenturipath" : _attachment.attachmentdocumenturipath, + "filename" : _attachment.attachmentfilename, } attachments.append(attachment) correpondencelog = self.__createcorrespondencelog(_correpondencelog, attachments) - #Email block - Begin - correpondencelog['emails'] = self.__getcorrespondenceemailbyid(_correspondenceemails, _correpondencelog['applicantcorrespondenceid'], _correpondencelog['version']) - #Email block - End correspondencelogs.append(correpondencelog) - # Since we're merging raw and ministry requests, resort by date - correspondencelogs.sort(key=lambda x: datetime.strptime(x['date'], '%Y %b %d | %I:%M %p'), reverse=True) return correspondencelogs + + # def getapplicantcorrespondencelogs(self,ministryrequestid, rawrequestid): + # """ Returns the active applicant correspondence logs + # """ + # _correspondencelogs = FOIApplicantCorrespondenceRawRequest.getapplicantcorrespondencesrawrequests(rawrequestid) + # _correspondenceattachments = FOIApplicantCorrespondenceAttachmentRawRequest.getcorrespondenceattachmentsbyrawrequestid(rawrequestid) + # _correspondenceemails = FOIApplicantCorrespondenceEmailRawRequest.getapplicantcorrespondenceemails(rawrequestid) + # if ministryrequestid != 'None': + # _correspondencelogs.extend(FOIApplicantCorrespondence.getapplicantcorrespondences(ministryrequestid)) + # _correspondenceattachments.extend(FOIApplicantCorrespondenceAttachment.getcorrespondenceattachmentsbyministryid(ministryrequestid)) + # _correspondenceemails.extend(FOIApplicantCorrespondenceEmail.getapplicantcorrespondenceemails(ministryrequestid)) + # correspondencelogs =[] + # for _correpondencelog in _correspondencelogs: + # attachments = [] + # for _attachment in self.__getattachmentsbyid(_correspondenceattachments, _correpondencelog['applicantcorrespondenceid'], _correpondencelog['version']): + # attachment = { + # "applicantcorrespondenceattachmentid" : _attachment['applicantcorrespondenceattachmentid'], + # "documenturipath" : _attachment['attachmentdocumenturipath'], + # "filename" : _attachment['attachmentfilename'], + # } + # attachments.append(attachment) + # correpondencelog = self.__createcorrespondencelog(_correpondencelog, attachments) + # #Email block - Begin + # correpondencelog['emails'] = self.__getcorrespondenceemailbyid(_correspondenceemails, _correpondencelog['applicantcorrespondenceid'], _correpondencelog['version']) + # #Email block - End + # correspondencelogs.append(correpondencelog) + # # Since we're merging raw and ministry requests, resort by date + # correspondencelogs.sort(key=lambda x: datetime.strptime(x['date'], '%Y %b %d | %I:%M %p'), reverse=True) + # return correspondencelogs def __getattachmentsbyid(self, attachments, correspondenceid, correspondenceversion): return [x for x in attachments if x['applicantcorrespondenceid'] == correspondenceid and x['applicantcorrespondence_version'] == correspondenceversion] From ac90513feeb25378c7bcaae38282d9c509352dd5 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Mon, 13 Jan 2025 10:59:31 -0800 Subject: [PATCH 61/87] Print correspondence --- .../applicantcorrespondence/applicantcorrespondencelog.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/request-management-api/request_api/services/applicantcorrespondence/applicantcorrespondencelog.py b/request-management-api/request_api/services/applicantcorrespondence/applicantcorrespondencelog.py index 2b24ada27..2872b040b 100644 --- a/request-management-api/request_api/services/applicantcorrespondence/applicantcorrespondencelog.py +++ b/request-management-api/request_api/services/applicantcorrespondence/applicantcorrespondencelog.py @@ -36,7 +36,7 @@ def getapplicantcorrespondencelogs(self,ministryrequestid): correspondencelogs =[] for _correpondencelog in _correspondencelogs: attachments = [] - for _attachment in _correpondencelog['attachments']: + for _attachment in _correpondencelog.get('attachments'): attachment = { "applicantcorrespondenceattachmentid" : _attachment.applicantcorrespondenceattachmentid, "documenturipath" : _attachment.attachmentdocumenturipath, From e50916c5e5225fc7fe2590efa54e1f39c498aac1 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Mon, 13 Jan 2025 11:14:11 -0800 Subject: [PATCH 62/87] Print applicantcorrespondences data --- .../models/FOIApplicantCorrespondences.py | 51 ++++++++++--------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/request-management-api/request_api/models/FOIApplicantCorrespondences.py b/request-management-api/request_api/models/FOIApplicantCorrespondences.py index a44593f4b..5462905bc 100644 --- a/request-management-api/request_api/models/FOIApplicantCorrespondences.py +++ b/request-management-api/request_api/models/FOIApplicantCorrespondences.py @@ -45,31 +45,36 @@ class FOIApplicantCorrespondence(db.Model): foiministryrequestversion_id=db.Column(db.Integer, db.ForeignKey('FOIMinistryRequests.version')) + # @classmethod + # def getapplicantcorrespondences(cls,ministryrequestid): + # correspondences = [] + # try: + # sql = """select distinct on (applicantcorrespondenceid) applicantcorrespondenceid, templateid , correspondencemessagejson , version, + # created_at, createdby, sentcorrespondencemessage, parentapplicantcorrespondenceid, sentby, sent_at, + # isdraft, isdeleted, isresponse, response_at + # from "FOIApplicantCorrespondences" fpa + # where foiministryrequest_id = :ministryrequestid + # order by applicantcorrespondenceid desc, version desc""" + # rs = db.session.execute(text(sql), {'ministryrequestid': ministryrequestid}) + # for row in rs: + # if row["isdeleted"] == False: + # correspondences.append({"applicantcorrespondenceid": row["applicantcorrespondenceid"], "templateid": row["templateid"], + # "correspondencemessagejson": row["correspondencemessagejson"], "version": row["version"], + # "created_at": row["created_at"], "createdby": row["createdby"], + # "sentcorrespondencemessage": row["sentcorrespondencemessage"], "parentapplicantcorrespondenceid": row["parentapplicantcorrespondenceid"], + # "sent_at": row["sent_at"], "sentby": row["sentby"], + # "isdraft": row["isdraft"], "isresponse": row["isresponse"], "response_at": row["response_at"]}) + # except Exception as ex: + # logging.error(ex) + # raise ex + # finally: + # db.session.close() + # return correspondences @classmethod def getapplicantcorrespondences(cls,ministryrequestid): - correspondences = [] - try: - sql = """select distinct on (applicantcorrespondenceid) applicantcorrespondenceid, templateid , correspondencemessagejson , version, - created_at, createdby, sentcorrespondencemessage, parentapplicantcorrespondenceid, sentby, sent_at, - isdraft, isdeleted, isresponse, response_at - from "FOIApplicantCorrespondences" fpa - where foiministryrequest_id = :ministryrequestid - order by applicantcorrespondenceid desc, version desc""" - rs = db.session.execute(text(sql), {'ministryrequestid': ministryrequestid}) - for row in rs: - if row["isdeleted"] == False: - correspondences.append({"applicantcorrespondenceid": row["applicantcorrespondenceid"], "templateid": row["templateid"], - "correspondencemessagejson": row["correspondencemessagejson"], "version": row["version"], - "created_at": row["created_at"], "createdby": row["createdby"], - "sentcorrespondencemessage": row["sentcorrespondencemessage"], "parentapplicantcorrespondenceid": row["parentapplicantcorrespondenceid"], - "sent_at": row["sent_at"], "sentby": row["sentby"], - "isdraft": row["isdraft"], "isresponse": row["isresponse"], "response_at": row["response_at"]}) - except Exception as ex: - logging.error(ex) - raise ex - finally: - db.session.close() - return correspondences + comment_schema = FOIApplicantCorrespondenceSchema(many=True) + query = db.session.query(FOIApplicantCorrespondence).filter(FOIApplicantCorrespondence.foiministryrequest_id == ministryrequestid).order_by(FOIApplicantCorrespondence.applicantcorrespondenceid.desc()).all() + return comment_schema.dump(query) @classmethod def getapplicantcorrespondencebyid(cls,applicantcorrespondenceid): From 4a5331d61de4158265eafee832b6eef48d8fc9a3 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Mon, 13 Jan 2025 11:31:59 -0800 Subject: [PATCH 63/87] Print correspondencelogs --- .../models/FOIApplicantCorrespondences.py | 51 ++++++++--------- .../resources/applicantcorrespondence.py | 28 +++++----- .../applicantcorrespondencelog.py | 55 +++++++------------ 3 files changed, 57 insertions(+), 77 deletions(-) diff --git a/request-management-api/request_api/models/FOIApplicantCorrespondences.py b/request-management-api/request_api/models/FOIApplicantCorrespondences.py index 5462905bc..a44593f4b 100644 --- a/request-management-api/request_api/models/FOIApplicantCorrespondences.py +++ b/request-management-api/request_api/models/FOIApplicantCorrespondences.py @@ -45,36 +45,31 @@ class FOIApplicantCorrespondence(db.Model): foiministryrequestversion_id=db.Column(db.Integer, db.ForeignKey('FOIMinistryRequests.version')) - # @classmethod - # def getapplicantcorrespondences(cls,ministryrequestid): - # correspondences = [] - # try: - # sql = """select distinct on (applicantcorrespondenceid) applicantcorrespondenceid, templateid , correspondencemessagejson , version, - # created_at, createdby, sentcorrespondencemessage, parentapplicantcorrespondenceid, sentby, sent_at, - # isdraft, isdeleted, isresponse, response_at - # from "FOIApplicantCorrespondences" fpa - # where foiministryrequest_id = :ministryrequestid - # order by applicantcorrespondenceid desc, version desc""" - # rs = db.session.execute(text(sql), {'ministryrequestid': ministryrequestid}) - # for row in rs: - # if row["isdeleted"] == False: - # correspondences.append({"applicantcorrespondenceid": row["applicantcorrespondenceid"], "templateid": row["templateid"], - # "correspondencemessagejson": row["correspondencemessagejson"], "version": row["version"], - # "created_at": row["created_at"], "createdby": row["createdby"], - # "sentcorrespondencemessage": row["sentcorrespondencemessage"], "parentapplicantcorrespondenceid": row["parentapplicantcorrespondenceid"], - # "sent_at": row["sent_at"], "sentby": row["sentby"], - # "isdraft": row["isdraft"], "isresponse": row["isresponse"], "response_at": row["response_at"]}) - # except Exception as ex: - # logging.error(ex) - # raise ex - # finally: - # db.session.close() - # return correspondences @classmethod def getapplicantcorrespondences(cls,ministryrequestid): - comment_schema = FOIApplicantCorrespondenceSchema(many=True) - query = db.session.query(FOIApplicantCorrespondence).filter(FOIApplicantCorrespondence.foiministryrequest_id == ministryrequestid).order_by(FOIApplicantCorrespondence.applicantcorrespondenceid.desc()).all() - return comment_schema.dump(query) + correspondences = [] + try: + sql = """select distinct on (applicantcorrespondenceid) applicantcorrespondenceid, templateid , correspondencemessagejson , version, + created_at, createdby, sentcorrespondencemessage, parentapplicantcorrespondenceid, sentby, sent_at, + isdraft, isdeleted, isresponse, response_at + from "FOIApplicantCorrespondences" fpa + where foiministryrequest_id = :ministryrequestid + order by applicantcorrespondenceid desc, version desc""" + rs = db.session.execute(text(sql), {'ministryrequestid': ministryrequestid}) + for row in rs: + if row["isdeleted"] == False: + correspondences.append({"applicantcorrespondenceid": row["applicantcorrespondenceid"], "templateid": row["templateid"], + "correspondencemessagejson": row["correspondencemessagejson"], "version": row["version"], + "created_at": row["created_at"], "createdby": row["createdby"], + "sentcorrespondencemessage": row["sentcorrespondencemessage"], "parentapplicantcorrespondenceid": row["parentapplicantcorrespondenceid"], + "sent_at": row["sent_at"], "sentby": row["sentby"], + "isdraft": row["isdraft"], "isresponse": row["isresponse"], "response_at": row["response_at"]}) + except Exception as ex: + logging.error(ex) + raise ex + finally: + db.session.close() + return correspondences @classmethod def getapplicantcorrespondencebyid(cls,applicantcorrespondenceid): diff --git a/request-management-api/request_api/resources/applicantcorrespondence.py b/request-management-api/request_api/resources/applicantcorrespondence.py index 29ece3ef6..510ab912b 100644 --- a/request-management-api/request_api/resources/applicantcorrespondence.py +++ b/request-management-api/request_api/resources/applicantcorrespondence.py @@ -69,19 +69,6 @@ def get(): @API.route('/foiflow/applicantcorrespondence//') class FOIFlowApplicantCorrespondence(Resource): - # @staticmethod - # @TRACER.trace() - # @cross_origin(origins=allowedorigins()) - # @auth.require - # @auth.hasusertype('iao') - # def get(requestid, ministryrequestid): - # try: - # rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid) - # correspondencelogs = applicantcorrespondenceservice().getapplicantcorrespondencelogs(ministryrequestid, rawrequestid) - # return json.dumps(correspondencelogs) , 200 - # except BusinessException: - # return "Error happened while fetching applicant correspondence logs" , 500 - @staticmethod @TRACER.trace() @cross_origin(origins=allowedorigins()) @@ -89,11 +76,24 @@ class FOIFlowApplicantCorrespondence(Resource): @auth.hasusertype('iao') def get(requestid, ministryrequestid): try: - correspondencelogs = applicantcorrespondenceservice().getapplicantcorrespondencelogs(ministryrequestid) + rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid) + correspondencelogs = applicantcorrespondenceservice().getapplicantcorrespondencelogs(ministryrequestid, rawrequestid) return json.dumps(correspondencelogs) , 200 except BusinessException: return "Error happened while fetching applicant correspondence logs" , 500 + # @staticmethod + # @TRACER.trace() + # @cross_origin(origins=allowedorigins()) + # @auth.require + # @auth.hasusertype('iao') + # def get(requestid, ministryrequestid): + # try: + # correspondencelogs = applicantcorrespondenceservice().getapplicantcorrespondencelogs(ministryrequestid) + # return json.dumps(correspondencelogs) , 200 + # except BusinessException: + # return "Error happened while fetching applicant correspondence logs" , 500 + @staticmethod @TRACER.trace() @cross_origin(origins=allowedorigins()) diff --git a/request-management-api/request_api/services/applicantcorrespondence/applicantcorrespondencelog.py b/request-management-api/request_api/services/applicantcorrespondence/applicantcorrespondencelog.py index 2872b040b..1c994a0a7 100644 --- a/request-management-api/request_api/services/applicantcorrespondence/applicantcorrespondencelog.py +++ b/request-management-api/request_api/services/applicantcorrespondence/applicantcorrespondencelog.py @@ -29,52 +29,37 @@ def gettemplatebyid(self, templateid): """ return ApplicationCorrespondenceTemplate.get_template_by_id(templateid) - def getapplicantcorrespondencelogs(self,ministryrequestid): + def getapplicantcorrespondencelogs(self,ministryrequestid, rawrequestid): """ Returns the active applicant correspondence logs """ - _correspondencelogs = FOIApplicantCorrespondence.getapplicantcorrespondences(ministryrequestid) + _correspondencelogs1 = FOIApplicantCorrespondence.getapplicantcorrespondences(ministryrequestid) + print("_correspondencelogs1", _correspondencelogs1) + _correspondencelogs = FOIApplicantCorrespondenceRawRequest.getapplicantcorrespondencesrawrequests(rawrequestid) + print("_correspondencelogs", _correspondencelogs) + _correspondenceattachments = FOIApplicantCorrespondenceAttachmentRawRequest.getcorrespondenceattachmentsbyrawrequestid(rawrequestid) + _correspondenceemails = FOIApplicantCorrespondenceEmailRawRequest.getapplicantcorrespondenceemails(rawrequestid) + if ministryrequestid != 'None': + _correspondencelogs.extend(FOIApplicantCorrespondence.getapplicantcorrespondences(ministryrequestid)) + _correspondenceattachments.extend(FOIApplicantCorrespondenceAttachment.getcorrespondenceattachmentsbyministryid(ministryrequestid)) + _correspondenceemails.extend(FOIApplicantCorrespondenceEmail.getapplicantcorrespondenceemails(ministryrequestid)) correspondencelogs =[] for _correpondencelog in _correspondencelogs: attachments = [] - for _attachment in _correpondencelog.get('attachments'): + for _attachment in self.__getattachmentsbyid(_correspondenceattachments, _correpondencelog['applicantcorrespondenceid'], _correpondencelog['version']): attachment = { - "applicantcorrespondenceattachmentid" : _attachment.applicantcorrespondenceattachmentid, - "documenturipath" : _attachment.attachmentdocumenturipath, - "filename" : _attachment.attachmentfilename, + "applicantcorrespondenceattachmentid" : _attachment['applicantcorrespondenceattachmentid'], + "documenturipath" : _attachment['attachmentdocumenturipath'], + "filename" : _attachment['attachmentfilename'], } attachments.append(attachment) correpondencelog = self.__createcorrespondencelog(_correpondencelog, attachments) + #Email block - Begin + correpondencelog['emails'] = self.__getcorrespondenceemailbyid(_correspondenceemails, _correpondencelog['applicantcorrespondenceid'], _correpondencelog['version']) + #Email block - End correspondencelogs.append(correpondencelog) + # Since we're merging raw and ministry requests, resort by date + correspondencelogs.sort(key=lambda x: datetime.strptime(x['date'], '%Y %b %d | %I:%M %p'), reverse=True) return correspondencelogs - - # def getapplicantcorrespondencelogs(self,ministryrequestid, rawrequestid): - # """ Returns the active applicant correspondence logs - # """ - # _correspondencelogs = FOIApplicantCorrespondenceRawRequest.getapplicantcorrespondencesrawrequests(rawrequestid) - # _correspondenceattachments = FOIApplicantCorrespondenceAttachmentRawRequest.getcorrespondenceattachmentsbyrawrequestid(rawrequestid) - # _correspondenceemails = FOIApplicantCorrespondenceEmailRawRequest.getapplicantcorrespondenceemails(rawrequestid) - # if ministryrequestid != 'None': - # _correspondencelogs.extend(FOIApplicantCorrespondence.getapplicantcorrespondences(ministryrequestid)) - # _correspondenceattachments.extend(FOIApplicantCorrespondenceAttachment.getcorrespondenceattachmentsbyministryid(ministryrequestid)) - # _correspondenceemails.extend(FOIApplicantCorrespondenceEmail.getapplicantcorrespondenceemails(ministryrequestid)) - # correspondencelogs =[] - # for _correpondencelog in _correspondencelogs: - # attachments = [] - # for _attachment in self.__getattachmentsbyid(_correspondenceattachments, _correpondencelog['applicantcorrespondenceid'], _correpondencelog['version']): - # attachment = { - # "applicantcorrespondenceattachmentid" : _attachment['applicantcorrespondenceattachmentid'], - # "documenturipath" : _attachment['attachmentdocumenturipath'], - # "filename" : _attachment['attachmentfilename'], - # } - # attachments.append(attachment) - # correpondencelog = self.__createcorrespondencelog(_correpondencelog, attachments) - # #Email block - Begin - # correpondencelog['emails'] = self.__getcorrespondenceemailbyid(_correspondenceemails, _correpondencelog['applicantcorrespondenceid'], _correpondencelog['version']) - # #Email block - End - # correspondencelogs.append(correpondencelog) - # # Since we're merging raw and ministry requests, resort by date - # correspondencelogs.sort(key=lambda x: datetime.strptime(x['date'], '%Y %b %d | %I:%M %p'), reverse=True) - # return correspondencelogs def __getattachmentsbyid(self, attachments, correspondenceid, correspondenceversion): return [x for x in attachments if x['applicantcorrespondenceid'] == correspondenceid and x['applicantcorrespondence_version'] == correspondenceversion] From 88389c29fbe03901a72f250813b8c79988c8ed32 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Mon, 13 Jan 2025 12:29:02 -0800 Subject: [PATCH 64/87] Print applicantcorrespondence --- .../request_api/resources/applicantcorrespondence.py | 12 ------------ .../applicantcorrespondencelog.py | 7 +++++-- .../request_api/services/emailservice.py | 1 + 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/request-management-api/request_api/resources/applicantcorrespondence.py b/request-management-api/request_api/resources/applicantcorrespondence.py index 510ab912b..725302d55 100644 --- a/request-management-api/request_api/resources/applicantcorrespondence.py +++ b/request-management-api/request_api/resources/applicantcorrespondence.py @@ -82,18 +82,6 @@ def get(requestid, ministryrequestid): except BusinessException: return "Error happened while fetching applicant correspondence logs" , 500 - # @staticmethod - # @TRACER.trace() - # @cross_origin(origins=allowedorigins()) - # @auth.require - # @auth.hasusertype('iao') - # def get(requestid, ministryrequestid): - # try: - # correspondencelogs = applicantcorrespondenceservice().getapplicantcorrespondencelogs(ministryrequestid) - # return json.dumps(correspondencelogs) , 200 - # except BusinessException: - # return "Error happened while fetching applicant correspondence logs" , 500 - @staticmethod @TRACER.trace() @cross_origin(origins=allowedorigins()) diff --git a/request-management-api/request_api/services/applicantcorrespondence/applicantcorrespondencelog.py b/request-management-api/request_api/services/applicantcorrespondence/applicantcorrespondencelog.py index 1c994a0a7..64026abbd 100644 --- a/request-management-api/request_api/services/applicantcorrespondence/applicantcorrespondencelog.py +++ b/request-management-api/request_api/services/applicantcorrespondence/applicantcorrespondencelog.py @@ -32,8 +32,6 @@ def gettemplatebyid(self, templateid): def getapplicantcorrespondencelogs(self,ministryrequestid, rawrequestid): """ Returns the active applicant correspondence logs """ - _correspondencelogs1 = FOIApplicantCorrespondence.getapplicantcorrespondences(ministryrequestid) - print("_correspondencelogs1", _correspondencelogs1) _correspondencelogs = FOIApplicantCorrespondenceRawRequest.getapplicantcorrespondencesrawrequests(rawrequestid) print("_correspondencelogs", _correspondencelogs) _correspondenceattachments = FOIApplicantCorrespondenceAttachmentRawRequest.getcorrespondenceattachmentsbyrawrequestid(rawrequestid) @@ -59,6 +57,7 @@ def getapplicantcorrespondencelogs(self,ministryrequestid, rawrequestid): correspondencelogs.append(correpondencelog) # Since we're merging raw and ministry requests, resort by date correspondencelogs.sort(key=lambda x: datetime.strptime(x['date'], '%Y %b %d | %I:%M %p'), reverse=True) + print("correspondencelogs", correspondencelogs) return correspondencelogs def __getattachmentsbyid(self, attachments, correspondenceid, correspondenceversion): @@ -93,6 +92,7 @@ def saveapplicantcorrespondencelog(self, requestid, ministryrequestid, data, use emails = data['emails'] if 'emails' in data else None applicantcorrespondence.response_at = data['responsedate'] if 'responsedate' in data and data['responsedate'] is not None else datetime.now() + print("saveapplicantcorrespondencelog", applicantcorrespondence) return FOIApplicantCorrespondence.saveapplicantcorrespondence(applicantcorrespondence,data['attachments'], emails) def saveapplicantcorrespondencelogforrawrequest(self, requestid, data, userid, isdraft=False): @@ -122,6 +122,7 @@ def saveapplicantcorrespondencelogforrawrequest(self, requestid, data, userid, i applicantcorrespondence.sentby = userid emails = data['emails'] if 'emails' in data else None applicantcorrespondence.response_at = data['responsedate'] if 'responsedate' in data and data['responsedate'] is not None else datetime.now() + print("saveapplicantcorrespondencelog2", applicantcorrespondence) return FOIApplicantCorrespondenceRawRequest.saveapplicantcorrespondence(applicantcorrespondence,data['attachments'], emails) def editapplicantcorrespondencelogforministry(self, ministryrequestid, data, userid): @@ -141,6 +142,7 @@ def editapplicantcorrespondencelogforministry(self, ministryrequestid, data, use updt_correspondence.isdraft = data['isdraft'] if 'correspondencemessagejson' in data and data['correspondencemessagejson'] is not None: updt_correspondence.correspondencemessagejson = data['correspondencemessagejson'] + print("saveapplicantcorrespondencelog3", updt_correspondence) response = FOIApplicantCorrespondence.saveapplicantcorrespondence(updt_correspondence, None, None) if response.success == True: attachresponse = self.__updateattachmentversionministry(data, userid) @@ -165,6 +167,7 @@ def editapplicantcorrespondencelogforrawrequest(self, rawrequestid, data, userid updt_correspondence.isdraft = data['isdraft'] if 'correspondencemessagejson' in data and data['correspondencemessagejson'] is not None: updt_correspondence.correspondencemessagejson = data['correspondencemessagejson'] + print("saveapplicantcorrespondencelog4", updt_correspondence) response = FOIApplicantCorrespondenceRawRequest.saveapplicantcorrespondence(updt_correspondence, None, None) if response.success == True: attachresponse = self.__updateattachmentversionrawrequest(data, userid) diff --git a/request-management-api/request_api/services/emailservice.py b/request-management-api/request_api/services/emailservice.py index 057ea4779..628ca3ab2 100644 --- a/request-management-api/request_api/services/emailservice.py +++ b/request-management-api/request_api/services/emailservice.py @@ -38,6 +38,7 @@ def send(self, servicename, requestid, ministryrequestid, emailschema): _messageattachmentlist = self.__get_attachments(ministryrequestid, emailschema, servicename) self.__pre_send_correspondence_audit(requestid, ministryrequestid,emailschema, content, templateconfig().isnotreceipt(servicename), _messageattachmentlist) subject = templateconfig().getsubject(servicename, requestjson) + print("requestjsonEmail", requestjson.get("email")) return senderservice().send(subject, _messagepart, _messageattachmentlist, requestjson.get("email")) except Exception as ex: logging.exception(ex) From 3ba7608153b1037c4d7204df651d027527ac92b9 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Mon, 13 Jan 2025 12:55:45 -0800 Subject: [PATCH 65/87] Print applicantcorrespondence --- .../request_api/resources/applicantcorrespondence.py | 3 +++ .../request_api/services/communicationwrapperservice.py | 1 + request-management-api/request_api/services/emailservice.py | 1 + 3 files changed, 5 insertions(+) diff --git a/request-management-api/request_api/resources/applicantcorrespondence.py b/request-management-api/request_api/resources/applicantcorrespondence.py index 725302d55..a80e75626 100644 --- a/request-management-api/request_api/resources/applicantcorrespondence.py +++ b/request-management-api/request_api/resources/applicantcorrespondence.py @@ -112,6 +112,7 @@ def post(requestid, ministryrequestid): correspondenceschemaobj = FOIApplicantCorrespondenceSchema().load(data=requestjson) rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid) if ministryrequestid != 'None' or "israwrequest" in correspondenceschemaobj and correspondenceschemaobj["israwrequest"] == False: + print("saveapplicantcorrespondencelog5", correspondenceschemaobj) result = applicantcorrespondenceservice().saveapplicantcorrespondencelog(rawrequestid, ministryrequestid, correspondenceschemaobj, AuthHelper.getuserid(), True) elif ministryrequestid == 'None' or "israwrequest" in correspondenceschemaobj and correspondenceschemaobj["israwrequest"] == True: result = applicantcorrespondenceservice().saveapplicantcorrespondencelogforrawrequest(rawrequestid, correspondenceschemaobj, AuthHelper.getuserid(), True) @@ -136,6 +137,7 @@ def post(requestid, ministryrequestid): if ministryrequestid == 'None' or "israwrequest" in applicantcorrespondencelog and applicantcorrespondencelog["israwrequest"] == True: result = applicantcorrespondenceservice().saveapplicantcorrespondencelogforrawrequest(rawrequestid, applicantcorrespondencelog, AuthHelper.getuserid(), True) else: + print("saveapplicantcorrespondencelog6", applicantcorrespondencelog) result = applicantcorrespondenceservice().saveapplicantcorrespondencelog(rawrequestid, ministryrequestid, applicantcorrespondencelog, AuthHelper.getuserid(), True) if result.success == True: return {'status': result.success, 'message':result.message,'id':result.identifier} , 200 @@ -213,6 +215,7 @@ def post(ministryrequestid, rawrequestid): if ministryrequestid == 'None' or 'israwrequest' in requestjson and requestjson['israwrequest'] == True: result = applicantcorrespondenceservice().saveapplicantcorrespondencelogforrawrequest(rawrequestidfromfoirequest, correspondenceemail, AuthHelper.getuserid()) else: + print("saveapplicantcorrespondencelog7", rawrequestidfromfoirequest) result = applicantcorrespondenceservice().saveapplicantcorrespondencelog(rawrequestidfromfoirequest, ministryrequestid, correspondenceemail, AuthHelper.getuserid()) return {'status': result.success, 'message':result.message,'id':result.identifier} , 200 diff --git a/request-management-api/request_api/services/communicationwrapperservice.py b/request-management-api/request_api/services/communicationwrapperservice.py index 7e5ba28d6..edd807aa4 100644 --- a/request-management-api/request_api/services/communicationwrapperservice.py +++ b/request-management-api/request_api/services/communicationwrapperservice.py @@ -24,6 +24,7 @@ def send_email(self, requestid, ministryrequestid, rawrequestid, applicantcorres if ministryrequestid == 'None' or ministryrequestid is None or ("israwrequest" in applicantcorrespondencelog and applicantcorrespondencelog["israwrequest"]) is True: result = applicantcorrespondenceservice().saveapplicantcorrespondencelogforrawrequest(rawrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) else: + print("saveapplicantcorrespondencelog8", applicantcorrespondencelog) result = applicantcorrespondenceservice().saveapplicantcorrespondencelog(requestid, ministryrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) if result.success == True: diff --git a/request-management-api/request_api/services/emailservice.py b/request-management-api/request_api/services/emailservice.py index 628ca3ab2..574af5b33 100644 --- a/request-management-api/request_api/services/emailservice.py +++ b/request-management-api/request_api/services/emailservice.py @@ -79,6 +79,7 @@ def __pre_send_correspondence_audit(self, requestid, ministryrequestid, emailsch "correspondencemessagejson": {"message": content}, "attachments": attachmentlist } + print("saveapplicantcorrespondencelog9", requestid) return applicantcorrespondenceservice().saveapplicantcorrespondencelog(requestid, ministryrequestid, data, 'system') From 07d317e0e34f528191cecea55f39ef263df96045 Mon Sep 17 00:00:00 2001 From: Milos Despotovic Date: Mon, 13 Jan 2025 13:07:01 -0800 Subject: [PATCH 66/87] Update operatingteamemails --- .../versions/3e8203b24730_create_operatingteamemails_table.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/request-management-api/migrations/versions/3e8203b24730_create_operatingteamemails_table.py b/request-management-api/migrations/versions/3e8203b24730_create_operatingteamemails_table.py index 0b6198938..a8b79fc38 100644 --- a/request-management-api/migrations/versions/3e8203b24730_create_operatingteamemails_table.py +++ b/request-management-api/migrations/versions/3e8203b24730_create_operatingteamemails_table.py @@ -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'), 'IAOResourceTeam@gov.bc.ca'), ((SELECT teamid FROM public."OperatingTeams" WHERE name = 'Children and Family Team'), 'IAO.ChildrenandEducationTeam@gov.bc.ca'), ((SELECT teamid FROM public."OperatingTeams" WHERE name = 'Children and Education Team'), 'IAO.ChildrenandEducationTeam@gov.bc.ca'), From f6cd70eec2bd75387d1f249f2c19bfc3b115e826 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Mon, 13 Jan 2025 13:43:36 -0800 Subject: [PATCH 67/87] Print Email Workflow --- request-management-api/request_api/services/emailservice.py | 1 - .../request_api/services/external/bpmservice.py | 6 ++++++ .../request_api/services/requestservice.py | 3 +++ .../request_api/services/workflowservice.py | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/request-management-api/request_api/services/emailservice.py b/request-management-api/request_api/services/emailservice.py index 574af5b33..6b1a308e5 100644 --- a/request-management-api/request_api/services/emailservice.py +++ b/request-management-api/request_api/services/emailservice.py @@ -105,5 +105,4 @@ def __upload(self, filename, filebytes, ministryrequestid, requestjson, category def __getvaluefromschema(self, emailschema, property): schema = emailschema.get(property) if property in emailschema else None - print("schema", schema) return emailschema.get(property) if property in emailschema else None diff --git a/request-management-api/request_api/services/external/bpmservice.py b/request-management-api/request_api/services/external/bpmservice.py index 1ef074eb0..8665332b0 100644 --- a/request-management-api/request_api/services/external/bpmservice.py +++ b/request-management-api/request_api/services/external/bpmservice.py @@ -66,6 +66,7 @@ def unopenedsave(self,processinstanceid, userid, messagetype, token=None): "assignedTo": VariableSchema().dump({"type" : VariableType.String.value, "value": userid}) } }) + print("messageschema2", messageschema) return self.__post_message(messagetype, messageschema, token) else: return @@ -79,6 +80,7 @@ def unopenedcomplete(self,processinstanceid, data, messagetype, token=None): "foiRequestMetaData": VariableSchema().dump({"data" : VariableType.String.value, "value": data}) } }) + print("messageschema3", messageschema) return self.__post_message(messagetype, messageschema, token) else: return @@ -111,6 +113,7 @@ def openedcomplete(self, wfinstanceid, filenumber, data, messagetype, token=None "processVariables":{ "foiRequestMetaData": VariableSchema().dump({"data" : VariableType.String.value, "value": data})} }) + print("messageschema4", messageschema) return self.__post_message(messagetype, messageschema, token) else: return @@ -125,6 +128,7 @@ def feeevent(self,axisrequestid, data, paymentstatus, token=None): "foiRequestMetaData": VariableSchema().dump({"data" : VariableType.String.value, "value": data}), "paymentstatus": VariableSchema().dump({"type" : VariableType.String.value, "value": paymentstatus})} }) + print("messageschema5", messageschema) return self.__post_message(MessageType.managepayment.value, messageschema, token) else: return @@ -139,6 +143,7 @@ def correspondanceevent(self,wfinstanceid, filenumber, data, token=None): "processVariables":{ "foiRequestMetaData": VariableSchema().dump({"data" : VariableType.String.value, "value": data})} }) + print("messageschema6", messageschema) return self.__post_message(MessageType.iaocorrenspodence.value, messageschema, token) else: return @@ -147,6 +152,7 @@ def reopenevent(self,processinstanceid, data, messagetype, token=None): return self.unopenedcomplete(processinstanceid, data, messagetype, token) def __post_message(self, messagetype, messageschema, token=None): + print("messageschema1", messageschema) return requests.post(self._getUrl_(messagetype), data=json.dumps(messageschema), headers = self._getHeaders_(token)) def _getUrl_(self, messagetype, definitionkey=None): diff --git a/request-management-api/request_api/services/requestservice.py b/request-management-api/request_api/services/requestservice.py index 121de75fa..c8310e1df 100644 --- a/request-management-api/request_api/services/requestservice.py +++ b/request-management-api/request_api/services/requestservice.py @@ -247,10 +247,13 @@ def postcorrespondenceeventtoworkflow( templateid, ): foirequestschema = self.getrequestdetails(requestid, ministryrequestid) + print("foirequestschema", foirequestschema) templatedetails = applicantcorrespondenceservice().gettemplatebyid(templateid) + print("templatedetails", templatedetails) wfinstanceid = workflowservice().syncwfinstance( "ministryrequest", ministryrequestid, True ) + print("wfinstanceid", wfinstanceid) workflowservice().postcorrenspodenceevent( wfinstanceid, ministryrequestid, diff --git a/request-management-api/request_api/services/workflowservice.py b/request-management-api/request_api/services/workflowservice.py index 1cbcbb1db..0e39963a3 100644 --- a/request-management-api/request_api/services/workflowservice.py +++ b/request-management-api/request_api/services/workflowservice.py @@ -95,6 +95,7 @@ def postcorrenspodenceevent(self, wfinstanceid, ministryid, requestsschema, appl filenumber = self.__getvaluefromschema(requestsschema,"idNumber") status = self.__getvaluefromschema(requestsschema,"currentState") metadata = json.dumps({"id": filenumber, "status": status , "ministryRequestID": ministryid, "paymentExpiryDate": paymentexpirydate, "axisRequestId": axisrequestid, "applicantcorrespondenceid": applicantcorrespondenceid, "templatename": templatename.replace(" ", "")}) + print("metadata", metadata) bpmservice().correspondanceevent(wfinstanceid, filenumber, metadata) def syncwfinstance(self, requesttype, requestid, isallactivity=False): From 953db5dd51bd5ecec4244f804075cdc9d64dc9e1 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Mon, 13 Jan 2025 15:00:22 -0800 Subject: [PATCH 68/87] Test Email Sender --- .../request_api/services/email/senderservice.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/request-management-api/request_api/services/email/senderservice.py b/request-management-api/request_api/services/email/senderservice.py index 019fcadb2..40ccfdad6 100644 --- a/request-management-api/request_api/services/email/senderservice.py +++ b/request-management-api/request_api/services/email/senderservice.py @@ -82,10 +82,12 @@ def send(self, subject, content, _messageattachmentlist, emails, from_email = No smtpobj.sendmail(msg['From'], msg['To'], msg.as_string()) smtpobj.quit() logging.debug("End: Send email for request") - return DefaultMethodResult(True,'Sent successfully', -1) + return {"success" : True, "message": "Sent successfully"} + # return DefaultMethodResult(True,'Sent successfully', -1) except Exception as e: logging.exception(e) - return DefaultMethodResult(False,'Unable to send', -1) + return {"success" : False, "message": "Unable to send"} + # return DefaultMethodResult(False,'Unable to send', -1) def read_outbox_as_bytes(self, servicekey, requestjson): From 18a19251d2a20cb773547bffc91909a53eb8b65c Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Mon, 13 Jan 2025 15:33:55 -0800 Subject: [PATCH 69/87] Cleanup Print --- .../request_api/resources/applicantcorrespondence.py | 3 --- .../applicantcorrespondence/applicantcorrespondencelog.py | 5 ----- request-management-api/request_api/services/emailservice.py | 6 ------ .../request_api/services/external/bpmservice.py | 6 ------ .../request_api/services/requestservice.py | 3 --- .../request_api/services/workflowservice.py | 1 - 6 files changed, 24 deletions(-) diff --git a/request-management-api/request_api/resources/applicantcorrespondence.py b/request-management-api/request_api/resources/applicantcorrespondence.py index a80e75626..725302d55 100644 --- a/request-management-api/request_api/resources/applicantcorrespondence.py +++ b/request-management-api/request_api/resources/applicantcorrespondence.py @@ -112,7 +112,6 @@ def post(requestid, ministryrequestid): correspondenceschemaobj = FOIApplicantCorrespondenceSchema().load(data=requestjson) rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid) if ministryrequestid != 'None' or "israwrequest" in correspondenceschemaobj and correspondenceschemaobj["israwrequest"] == False: - print("saveapplicantcorrespondencelog5", correspondenceschemaobj) result = applicantcorrespondenceservice().saveapplicantcorrespondencelog(rawrequestid, ministryrequestid, correspondenceschemaobj, AuthHelper.getuserid(), True) elif ministryrequestid == 'None' or "israwrequest" in correspondenceschemaobj and correspondenceschemaobj["israwrequest"] == True: result = applicantcorrespondenceservice().saveapplicantcorrespondencelogforrawrequest(rawrequestid, correspondenceschemaobj, AuthHelper.getuserid(), True) @@ -137,7 +136,6 @@ def post(requestid, ministryrequestid): if ministryrequestid == 'None' or "israwrequest" in applicantcorrespondencelog and applicantcorrespondencelog["israwrequest"] == True: result = applicantcorrespondenceservice().saveapplicantcorrespondencelogforrawrequest(rawrequestid, applicantcorrespondencelog, AuthHelper.getuserid(), True) else: - print("saveapplicantcorrespondencelog6", applicantcorrespondencelog) result = applicantcorrespondenceservice().saveapplicantcorrespondencelog(rawrequestid, ministryrequestid, applicantcorrespondencelog, AuthHelper.getuserid(), True) if result.success == True: return {'status': result.success, 'message':result.message,'id':result.identifier} , 200 @@ -215,7 +213,6 @@ def post(ministryrequestid, rawrequestid): if ministryrequestid == 'None' or 'israwrequest' in requestjson and requestjson['israwrequest'] == True: result = applicantcorrespondenceservice().saveapplicantcorrespondencelogforrawrequest(rawrequestidfromfoirequest, correspondenceemail, AuthHelper.getuserid()) else: - print("saveapplicantcorrespondencelog7", rawrequestidfromfoirequest) result = applicantcorrespondenceservice().saveapplicantcorrespondencelog(rawrequestidfromfoirequest, ministryrequestid, correspondenceemail, AuthHelper.getuserid()) return {'status': result.success, 'message':result.message,'id':result.identifier} , 200 diff --git a/request-management-api/request_api/services/applicantcorrespondence/applicantcorrespondencelog.py b/request-management-api/request_api/services/applicantcorrespondence/applicantcorrespondencelog.py index 64026abbd..25f014614 100644 --- a/request-management-api/request_api/services/applicantcorrespondence/applicantcorrespondencelog.py +++ b/request-management-api/request_api/services/applicantcorrespondence/applicantcorrespondencelog.py @@ -33,7 +33,6 @@ def getapplicantcorrespondencelogs(self,ministryrequestid, rawrequestid): """ Returns the active applicant correspondence logs """ _correspondencelogs = FOIApplicantCorrespondenceRawRequest.getapplicantcorrespondencesrawrequests(rawrequestid) - print("_correspondencelogs", _correspondencelogs) _correspondenceattachments = FOIApplicantCorrespondenceAttachmentRawRequest.getcorrespondenceattachmentsbyrawrequestid(rawrequestid) _correspondenceemails = FOIApplicantCorrespondenceEmailRawRequest.getapplicantcorrespondenceemails(rawrequestid) if ministryrequestid != 'None': @@ -57,7 +56,6 @@ def getapplicantcorrespondencelogs(self,ministryrequestid, rawrequestid): correspondencelogs.append(correpondencelog) # Since we're merging raw and ministry requests, resort by date correspondencelogs.sort(key=lambda x: datetime.strptime(x['date'], '%Y %b %d | %I:%M %p'), reverse=True) - print("correspondencelogs", correspondencelogs) return correspondencelogs def __getattachmentsbyid(self, attachments, correspondenceid, correspondenceversion): @@ -92,7 +90,6 @@ def saveapplicantcorrespondencelog(self, requestid, ministryrequestid, data, use emails = data['emails'] if 'emails' in data else None applicantcorrespondence.response_at = data['responsedate'] if 'responsedate' in data and data['responsedate'] is not None else datetime.now() - print("saveapplicantcorrespondencelog", applicantcorrespondence) return FOIApplicantCorrespondence.saveapplicantcorrespondence(applicantcorrespondence,data['attachments'], emails) def saveapplicantcorrespondencelogforrawrequest(self, requestid, data, userid, isdraft=False): @@ -122,7 +119,6 @@ def saveapplicantcorrespondencelogforrawrequest(self, requestid, data, userid, i applicantcorrespondence.sentby = userid emails = data['emails'] if 'emails' in data else None applicantcorrespondence.response_at = data['responsedate'] if 'responsedate' in data and data['responsedate'] is not None else datetime.now() - print("saveapplicantcorrespondencelog2", applicantcorrespondence) return FOIApplicantCorrespondenceRawRequest.saveapplicantcorrespondence(applicantcorrespondence,data['attachments'], emails) def editapplicantcorrespondencelogforministry(self, ministryrequestid, data, userid): @@ -167,7 +163,6 @@ def editapplicantcorrespondencelogforrawrequest(self, rawrequestid, data, userid updt_correspondence.isdraft = data['isdraft'] if 'correspondencemessagejson' in data and data['correspondencemessagejson'] is not None: updt_correspondence.correspondencemessagejson = data['correspondencemessagejson'] - print("saveapplicantcorrespondencelog4", updt_correspondence) response = FOIApplicantCorrespondenceRawRequest.saveapplicantcorrespondence(updt_correspondence, None, None) if response.success == True: attachresponse = self.__updateattachmentversionrawrequest(data, userid) diff --git a/request-management-api/request_api/services/emailservice.py b/request-management-api/request_api/services/emailservice.py index 6b1a308e5..08d24f823 100644 --- a/request-management-api/request_api/services/emailservice.py +++ b/request-management-api/request_api/services/emailservice.py @@ -26,9 +26,6 @@ class emailservice: def send(self, servicename, requestid, ministryrequestid, emailschema): try: requestjson = requestservice().getrequestdetails(requestid,ministryrequestid) - increment_number = 1 # Initialize the number - print("requestjson", increment_number, requestjson) - increment_number += 1 # Increment the number _templatename = self.__getvaluefromschema(emailschema, "templatename") servicename = _templatename if servicename == ServiceName.correspondence.value.upper() else servicename _applicantcorrespondenceid = self.__getvaluefromschema(emailschema, "applicantcorrespondenceid") @@ -38,7 +35,6 @@ def send(self, servicename, requestid, ministryrequestid, emailschema): _messageattachmentlist = self.__get_attachments(ministryrequestid, emailschema, servicename) self.__pre_send_correspondence_audit(requestid, ministryrequestid,emailschema, content, templateconfig().isnotreceipt(servicename), _messageattachmentlist) subject = templateconfig().getsubject(servicename, requestjson) - print("requestjsonEmail", requestjson.get("email")) return senderservice().send(subject, _messagepart, _messageattachmentlist, requestjson.get("email")) except Exception as ex: logging.exception(ex) @@ -79,7 +75,6 @@ def __pre_send_correspondence_audit(self, requestid, ministryrequestid, emailsch "correspondencemessagejson": {"message": content}, "attachments": attachmentlist } - print("saveapplicantcorrespondencelog9", requestid) return applicantcorrespondenceservice().saveapplicantcorrespondencelog(requestid, ministryrequestid, data, 'system') @@ -104,5 +99,4 @@ def __upload(self, filename, filebytes, ministryrequestid, requestjson, category logging.exception(ex) def __getvaluefromschema(self, emailschema, property): - schema = emailschema.get(property) if property in emailschema else None return emailschema.get(property) if property in emailschema else None diff --git a/request-management-api/request_api/services/external/bpmservice.py b/request-management-api/request_api/services/external/bpmservice.py index 8665332b0..1ef074eb0 100644 --- a/request-management-api/request_api/services/external/bpmservice.py +++ b/request-management-api/request_api/services/external/bpmservice.py @@ -66,7 +66,6 @@ def unopenedsave(self,processinstanceid, userid, messagetype, token=None): "assignedTo": VariableSchema().dump({"type" : VariableType.String.value, "value": userid}) } }) - print("messageschema2", messageschema) return self.__post_message(messagetype, messageschema, token) else: return @@ -80,7 +79,6 @@ def unopenedcomplete(self,processinstanceid, data, messagetype, token=None): "foiRequestMetaData": VariableSchema().dump({"data" : VariableType.String.value, "value": data}) } }) - print("messageschema3", messageschema) return self.__post_message(messagetype, messageschema, token) else: return @@ -113,7 +111,6 @@ def openedcomplete(self, wfinstanceid, filenumber, data, messagetype, token=None "processVariables":{ "foiRequestMetaData": VariableSchema().dump({"data" : VariableType.String.value, "value": data})} }) - print("messageschema4", messageschema) return self.__post_message(messagetype, messageschema, token) else: return @@ -128,7 +125,6 @@ def feeevent(self,axisrequestid, data, paymentstatus, token=None): "foiRequestMetaData": VariableSchema().dump({"data" : VariableType.String.value, "value": data}), "paymentstatus": VariableSchema().dump({"type" : VariableType.String.value, "value": paymentstatus})} }) - print("messageschema5", messageschema) return self.__post_message(MessageType.managepayment.value, messageschema, token) else: return @@ -143,7 +139,6 @@ def correspondanceevent(self,wfinstanceid, filenumber, data, token=None): "processVariables":{ "foiRequestMetaData": VariableSchema().dump({"data" : VariableType.String.value, "value": data})} }) - print("messageschema6", messageschema) return self.__post_message(MessageType.iaocorrenspodence.value, messageschema, token) else: return @@ -152,7 +147,6 @@ def reopenevent(self,processinstanceid, data, messagetype, token=None): return self.unopenedcomplete(processinstanceid, data, messagetype, token) def __post_message(self, messagetype, messageschema, token=None): - print("messageschema1", messageschema) return requests.post(self._getUrl_(messagetype), data=json.dumps(messageschema), headers = self._getHeaders_(token)) def _getUrl_(self, messagetype, definitionkey=None): diff --git a/request-management-api/request_api/services/requestservice.py b/request-management-api/request_api/services/requestservice.py index c8310e1df..121de75fa 100644 --- a/request-management-api/request_api/services/requestservice.py +++ b/request-management-api/request_api/services/requestservice.py @@ -247,13 +247,10 @@ def postcorrespondenceeventtoworkflow( templateid, ): foirequestschema = self.getrequestdetails(requestid, ministryrequestid) - print("foirequestschema", foirequestschema) templatedetails = applicantcorrespondenceservice().gettemplatebyid(templateid) - print("templatedetails", templatedetails) wfinstanceid = workflowservice().syncwfinstance( "ministryrequest", ministryrequestid, True ) - print("wfinstanceid", wfinstanceid) workflowservice().postcorrenspodenceevent( wfinstanceid, ministryrequestid, diff --git a/request-management-api/request_api/services/workflowservice.py b/request-management-api/request_api/services/workflowservice.py index 0e39963a3..1cbcbb1db 100644 --- a/request-management-api/request_api/services/workflowservice.py +++ b/request-management-api/request_api/services/workflowservice.py @@ -95,7 +95,6 @@ def postcorrenspodenceevent(self, wfinstanceid, ministryid, requestsschema, appl filenumber = self.__getvaluefromschema(requestsschema,"idNumber") status = self.__getvaluefromschema(requestsschema,"currentState") metadata = json.dumps({"id": filenumber, "status": status , "ministryRequestID": ministryid, "paymentExpiryDate": paymentexpirydate, "axisRequestId": axisrequestid, "applicantcorrespondenceid": applicantcorrespondenceid, "templatename": templatename.replace(" ", "")}) - print("metadata", metadata) bpmservice().correspondanceevent(wfinstanceid, filenumber, metadata) def syncwfinstance(self, requesttype, requestid, isallactivity=False): From 96d6e3032317e7ffa5bac0a921fb963c81e5881e Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Mon, 13 Jan 2025 16:30:32 -0800 Subject: [PATCH 70/87] Revert Test-Marshal --- .../resources/applicantcorrespondence.py | 13 +++--- .../applicantcorrespondencelog.py | 2 +- .../services/communicationwrapperservice.py | 43 +++++++++---------- .../services/email/senderservice.py | 11 ++--- .../services/unopenedreportservice.py | 3 +- 5 files changed, 32 insertions(+), 40 deletions(-) diff --git a/request-management-api/request_api/resources/applicantcorrespondence.py b/request-management-api/request_api/resources/applicantcorrespondence.py index 725302d55..365bf3132 100644 --- a/request-management-api/request_api/resources/applicantcorrespondence.py +++ b/request-management-api/request_api/resources/applicantcorrespondence.py @@ -90,14 +90,15 @@ def get(requestid, ministryrequestid): def post(requestid, ministryrequestid): try: requestjson = request.get_json() - applicantcorrespondencelog = FOIApplicantCorrespondenceSchema().load(data=requestjson) + applicantcorrespondencelog = FOIApplicantCorrespondenceSchema().load(data=requestjson) rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid) - result = communicationwrapperservice().send_email(requestid, ministryrequestid, rawrequestid, applicantcorrespondencelog) - return {'status': result.success, 'message': result.message, 'id': result.identifier}, 200 + result = communicationwrapperservice().send_email(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') @API.route('/foiflow/applicantcorrespondence/draft//') class FOIFlowApplicantCorrespondenceDraft(Resource): diff --git a/request-management-api/request_api/services/applicantcorrespondence/applicantcorrespondencelog.py b/request-management-api/request_api/services/applicantcorrespondence/applicantcorrespondencelog.py index 25f014614..78cdf5332 100644 --- a/request-management-api/request_api/services/applicantcorrespondence/applicantcorrespondencelog.py +++ b/request-management-api/request_api/services/applicantcorrespondence/applicantcorrespondencelog.py @@ -29,6 +29,7 @@ def gettemplatebyid(self, templateid): """ return ApplicationCorrespondenceTemplate.get_template_by_id(templateid) + def getapplicantcorrespondencelogs(self,ministryrequestid, rawrequestid): """ Returns the active applicant correspondence logs """ @@ -138,7 +139,6 @@ def editapplicantcorrespondencelogforministry(self, ministryrequestid, data, use updt_correspondence.isdraft = data['isdraft'] if 'correspondencemessagejson' in data and data['correspondencemessagejson'] is not None: updt_correspondence.correspondencemessagejson = data['correspondencemessagejson'] - print("saveapplicantcorrespondencelog3", updt_correspondence) response = FOIApplicantCorrespondence.saveapplicantcorrespondence(updt_correspondence, None, None) if response.success == True: attachresponse = self.__updateattachmentversionministry(data, userid) diff --git a/request-management-api/request_api/services/communicationwrapperservice.py b/request-management-api/request_api/services/communicationwrapperservice.py index edd807aa4..2375653e1 100644 --- a/request-management-api/request_api/services/communicationwrapperservice.py +++ b/request-management-api/request_api/services/communicationwrapperservice.py @@ -16,45 +16,42 @@ class communicationwrapperservice: """ FOI communication wrapper service - """ - - def send_email(self, requestid, ministryrequestid, rawrequestid, applicantcorrespondencelog): - # Save correspondence log based on request type + + def send_email(self,requestid, ministryrequestid, applicantcorrespondencelog): if ministryrequestid == 'None' or ministryrequestid is None or ("israwrequest" in applicantcorrespondencelog and applicantcorrespondencelog["israwrequest"]) is True: - result = applicantcorrespondenceservice().saveapplicantcorrespondencelogforrawrequest(rawrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) + result = applicantcorrespondenceservice().saveapplicantcorrespondencelogforrawrequest(requestid, applicantcorrespondencelog, AuthHelper.getuserid()) else: - print("saveapplicantcorrespondencelog8", applicantcorrespondencelog) result = applicantcorrespondenceservice().saveapplicantcorrespondencelog(requestid, ministryrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) - if result.success == True: - # Handle fee processing templates - if self.__is_fee_processing(applicantcorrespondencelog["templateid"]): - self.__handle_fee_email(requestid, ministryrequestid, result, applicantcorrespondencelog) - # Handle non-fee templates - Send email for non-fee templates with email recipients + # 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) else: if "emails" in applicantcorrespondencelog and len(applicantcorrespondencelog["emails"]) > 0: template = applicantcorrespondenceservice().gettemplatebyid(applicantcorrespondencelog["templateid"]) - communicationemailservice().send(template, applicantcorrespondencelog) - return result + return communicationemailservice().send(template, applicantcorrespondencelog) + return result - 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()) - requestservice().postcorrespondenceeventtoworkflow(requestid, ministryrequestid, result.identifier, applicantcorrespondencelog['attributes'], applicantcorrespondencelog['templateid']) + + def __handle_fee_email(self,requestid, ministryrequestid, applicantcorrespondencelog): + if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != 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']) + def __is_fee_processing(self, templateid): - if applicantcorrespondenceservice().gettemplatebyid(templateid).name in ['PAYONLINE','PAYOUTSTANDING']: + if applicantcorrespondenceservice().gettemplatebyid(templateid) in ['PAYONLINE','PAYOUTSTANDING']: return True return False class CommuniationType(Enum): """Communication types.""" FEE_PROCESSING = 'FEE_PROCESSING' - GENERAL = 'GENERAL' \ No newline at end of file + GENERAL = 'GENERAL' \ No newline at end of file diff --git a/request-management-api/request_api/services/email/senderservice.py b/request-management-api/request_api/services/email/senderservice.py index 40ccfdad6..58d6197c2 100644 --- a/request-management-api/request_api/services/email/senderservice.py +++ b/request-management-api/request_api/services/email/senderservice.py @@ -48,10 +48,7 @@ def send(self, subject, content, _messageattachmentlist, emails, from_email = No from_email = MAIL_FROM_ADDRESS msg['From'] = from_email - if isinstance(emails, list): - msg['To'] = ",".join(emails) - else: - msg['To'] = emails + msg['To'] = ",".join(emails) msg['Subject'] = subject formattedContent, embeddedImages = embeddedimagehandler().formatembeddedimage(content) part = MIMEText(formattedContent, "html") @@ -82,12 +79,10 @@ def send(self, subject, content, _messageattachmentlist, emails, from_email = No smtpobj.sendmail(msg['From'], msg['To'], msg.as_string()) smtpobj.quit() logging.debug("End: Send email for request") - return {"success" : True, "message": "Sent successfully"} - # return DefaultMethodResult(True,'Sent successfully', -1) + return DefaultMethodResult(True,'Sent successfully', -1) except Exception as e: logging.exception(e) - return {"success" : False, "message": "Unable to send"} - # return DefaultMethodResult(False,'Unable to send', -1) + return DefaultMethodResult(False,'Unable to send', -1) def read_outbox_as_bytes(self, servicekey, requestjson): diff --git a/request-management-api/request_api/services/unopenedreportservice.py b/request-management-api/request_api/services/unopenedreportservice.py index 67c18642b..61fa1054a 100644 --- a/request-management-api/request_api/services/unopenedreportservice.py +++ b/request-management-api/request_api/services/unopenedreportservice.py @@ -68,12 +68,11 @@ async def generateunopenedreport(self): alerts.append({"request": request, "rank": 2, "potentialmatches": alert.potentialmatches}) UnopenedReport.bulkinsert(alertdbrows) alerts.sort(key=lambda a : a.get('potentialmatches', {'highscore': -1})['highscore']) - requestjson={"email": self.reportemail, "topic": "Unopened Report"} senderservice().send( subject="Intake Unopened Request Report: " + str(date.today()), content=self.generateemailhtml(alerts), _messageattachmentlist=[], - emails=requestjson.get("email") + requestjson={"email": self.reportemail, "topic": "Unopened Report"} ) return alerts From 1b0b07570bc7fe1406aee4df1d5c345712fbe7e5 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Mon, 13 Jan 2025 16:46:33 -0800 Subject: [PATCH 71/87] Revert to original --- request-management-api/request_api/services/emailservice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/request-management-api/request_api/services/emailservice.py b/request-management-api/request_api/services/emailservice.py index 08d24f823..6df55855c 100644 --- a/request-management-api/request_api/services/emailservice.py +++ b/request-management-api/request_api/services/emailservice.py @@ -35,7 +35,7 @@ def send(self, servicename, requestid, ministryrequestid, emailschema): _messageattachmentlist = self.__get_attachments(ministryrequestid, emailschema, servicename) self.__pre_send_correspondence_audit(requestid, ministryrequestid,emailschema, content, templateconfig().isnotreceipt(servicename), _messageattachmentlist) subject = templateconfig().getsubject(servicename, requestjson) - return senderservice().send(subject, _messagepart, _messageattachmentlist, requestjson.get("email")) + return senderservice().send(subject, _messagepart, _messageattachmentlist, requestjson) except Exception as ex: logging.exception(ex) From 7c9dd00921c212d5d09a63eb9681279178a12ece Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Mon, 13 Jan 2025 16:54:16 -0800 Subject: [PATCH 72/87] FOIMOD-3450 - Fix issue on Autoemail, Duplicate Correspondence and PayURL --- .../resources/applicantcorrespondence.py | 9 ++--- .../services/communicationwrapperservice.py | 38 ++++++++++--------- .../services/email/senderservice.py | 9 +++-- .../request_api/services/emailservice.py | 2 +- .../services/unopenedreportservice.py | 3 +- 5 files changed, 33 insertions(+), 28 deletions(-) diff --git a/request-management-api/request_api/resources/applicantcorrespondence.py b/request-management-api/request_api/resources/applicantcorrespondence.py index 365bf3132..d33ecaf7e 100644 --- a/request-management-api/request_api/resources/applicantcorrespondence.py +++ b/request-management-api/request_api/resources/applicantcorrespondence.py @@ -90,13 +90,12 @@ def get(requestid, ministryrequestid): def post(requestid, ministryrequestid): try: requestjson = request.get_json() - applicantcorrespondencelog = FOIApplicantCorrespondenceSchema().load(data=requestjson) + 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 + result = communicationwrapperservice().send_email(requestid, ministryrequestid, rawrequestid, 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') diff --git a/request-management-api/request_api/services/communicationwrapperservice.py b/request-management-api/request_api/services/communicationwrapperservice.py index 2375653e1..cff18c1cd 100644 --- a/request-management-api/request_api/services/communicationwrapperservice.py +++ b/request-management-api/request_api/services/communicationwrapperservice.py @@ -18,40 +18,42 @@ class communicationwrapperservice: """ FOI communication wrapper service """ - def send_email(self,requestid, ministryrequestid, applicantcorrespondencelog): + def send_email(self, requestid, ministryrequestid, rawrequestid, 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"]): + 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 - - + 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']) + 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' \ No newline at end of file + GENERAL = 'GENERAL' \ No newline at end of file diff --git a/request-management-api/request_api/services/email/senderservice.py b/request-management-api/request_api/services/email/senderservice.py index 58d6197c2..c311630e1 100644 --- a/request-management-api/request_api/services/email/senderservice.py +++ b/request-management-api/request_api/services/email/senderservice.py @@ -48,7 +48,10 @@ def send(self, subject, content, _messageattachmentlist, emails, from_email = No from_email = MAIL_FROM_ADDRESS msg['From'] = from_email - msg['To'] = ",".join(emails) + if isinstance(emails, list): + msg['To'] = ",".join(emails) + else: + msg['To'] = emails msg['Subject'] = subject formattedContent, embeddedImages = embeddedimagehandler().formatembeddedimage(content) part = MIMEText(formattedContent, "html") @@ -79,10 +82,10 @@ def send(self, subject, content, _messageattachmentlist, emails, from_email = No smtpobj.sendmail(msg['From'], msg['To'], msg.as_string()) smtpobj.quit() logging.debug("End: Send email for request") - return DefaultMethodResult(True,'Sent successfully', -1) + return {"success" : True, "message": "Sent successfully", "identifier": -1} except Exception as e: logging.exception(e) - return DefaultMethodResult(False,'Unable to send', -1) + return {"success" : False, "message": "Unable to send", "identifier": -1} def read_outbox_as_bytes(self, servicekey, requestjson): diff --git a/request-management-api/request_api/services/emailservice.py b/request-management-api/request_api/services/emailservice.py index 6df55855c..08d24f823 100644 --- a/request-management-api/request_api/services/emailservice.py +++ b/request-management-api/request_api/services/emailservice.py @@ -35,7 +35,7 @@ def send(self, servicename, requestid, ministryrequestid, emailschema): _messageattachmentlist = self.__get_attachments(ministryrequestid, emailschema, servicename) self.__pre_send_correspondence_audit(requestid, ministryrequestid,emailschema, content, templateconfig().isnotreceipt(servicename), _messageattachmentlist) subject = templateconfig().getsubject(servicename, requestjson) - return senderservice().send(subject, _messagepart, _messageattachmentlist, requestjson) + return senderservice().send(subject, _messagepart, _messageattachmentlist, requestjson.get("email")) except Exception as ex: logging.exception(ex) diff --git a/request-management-api/request_api/services/unopenedreportservice.py b/request-management-api/request_api/services/unopenedreportservice.py index 61fa1054a..67c18642b 100644 --- a/request-management-api/request_api/services/unopenedreportservice.py +++ b/request-management-api/request_api/services/unopenedreportservice.py @@ -68,11 +68,12 @@ async def generateunopenedreport(self): alerts.append({"request": request, "rank": 2, "potentialmatches": alert.potentialmatches}) UnopenedReport.bulkinsert(alertdbrows) alerts.sort(key=lambda a : a.get('potentialmatches', {'highscore': -1})['highscore']) + requestjson={"email": self.reportemail, "topic": "Unopened Report"} senderservice().send( subject="Intake Unopened Request Report: " + str(date.today()), content=self.generateemailhtml(alerts), _messageattachmentlist=[], - requestjson={"email": self.reportemail, "topic": "Unopened Report"} + emails=requestjson.get("email") ) return alerts From f89190ee434ff78cff6251799c1dda47d7d914a9 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Mon, 13 Jan 2025 17:41:06 -0800 Subject: [PATCH 73/87] FOIMOD-3450 update code based on review --- .../request_api/resources/applicantcorrespondence.py | 2 +- .../services/communicationwrapperservice.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/request-management-api/request_api/resources/applicantcorrespondence.py b/request-management-api/request_api/resources/applicantcorrespondence.py index d33ecaf7e..5cacfcd5f 100644 --- a/request-management-api/request_api/resources/applicantcorrespondence.py +++ b/request-management-api/request_api/resources/applicantcorrespondence.py @@ -92,7 +92,7 @@ def post(requestid, ministryrequestid): requestjson = request.get_json() applicantcorrespondencelog = FOIApplicantCorrespondenceSchema().load(data=requestjson) rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid) - result = communicationwrapperservice().send_email(requestid, ministryrequestid, rawrequestid, applicantcorrespondencelog) + result = communicationwrapperservice().send_email(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 diff --git a/request-management-api/request_api/services/communicationwrapperservice.py b/request-management-api/request_api/services/communicationwrapperservice.py index cff18c1cd..09bb1dc23 100644 --- a/request-management-api/request_api/services/communicationwrapperservice.py +++ b/request-management-api/request_api/services/communicationwrapperservice.py @@ -18,10 +18,10 @@ class communicationwrapperservice: """ FOI communication wrapper service """ - def send_email(self, requestid, ministryrequestid, rawrequestid, applicantcorrespondencelog): + def send_email(self, requestid, 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(rawrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) + result = applicantcorrespondenceservice().saveapplicantcorrespondencelogforrawrequest(requestid, applicantcorrespondencelog, AuthHelper.getuserid()) else: result = applicantcorrespondenceservice().saveapplicantcorrespondencelog(requestid, ministryrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) @@ -29,13 +29,12 @@ def send_email(self, requestid, ministryrequestid, rawrequestid, applicantcorres # raw requests should never be fee emails so they would only get handled by else statement # Handle fee processing templates if self.__is_fee_processing(applicantcorrespondencelog["templateid"]): - self.__handle_fee_email(requestid, ministryrequestid, result, applicantcorrespondencelog) + 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"]) - communicationemailservice().send(template, applicantcorrespondencelog) - return result + return communicationemailservice().send(template, applicantcorrespondencelog) def __handle_fee_email(self, requestid, ministryrequestid, result, applicantcorrespondencelog): @@ -46,6 +45,7 @@ def __handle_fee_email(self, requestid, ministryrequestid, result, applicantcorr if _paymentexpirydate not in (None, ""): paymentservice().createpayment(requestid, ministryrequestid, _attributes, AuthHelper.getuserid()) requestservice().postcorrespondenceeventtoworkflow(requestid, ministryrequestid, result.identifier, applicantcorrespondencelog['attributes'], applicantcorrespondencelog['templateid']) + return result def __is_fee_processing(self, templateid): From 73977f765121bf17f244b6bc2e93b67d23dc3132 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Mon, 13 Jan 2025 18:25:08 -0800 Subject: [PATCH 74/87] Print requestid --- .../request_api/resources/applicantcorrespondence.py | 2 ++ .../request_api/services/communicationwrapperservice.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/request-management-api/request_api/resources/applicantcorrespondence.py b/request-management-api/request_api/resources/applicantcorrespondence.py index 5cacfcd5f..f239ae45c 100644 --- a/request-management-api/request_api/resources/applicantcorrespondence.py +++ b/request-management-api/request_api/resources/applicantcorrespondence.py @@ -92,6 +92,8 @@ def post(requestid, ministryrequestid): requestjson = request.get_json() applicantcorrespondencelog = FOIApplicantCorrespondenceSchema().load(data=requestjson) rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid) + print("requestid", requestid) + print("rawrequestid", rawrequestid) result = communicationwrapperservice().send_email(rawrequestid, ministryrequestid, applicantcorrespondencelog) return {'status': result.success, 'message': result.message, 'id': result.identifier}, 200 except BusinessException: diff --git a/request-management-api/request_api/services/communicationwrapperservice.py b/request-management-api/request_api/services/communicationwrapperservice.py index 09bb1dc23..b929b6769 100644 --- a/request-management-api/request_api/services/communicationwrapperservice.py +++ b/request-management-api/request_api/services/communicationwrapperservice.py @@ -29,12 +29,13 @@ def send_email(self, requestid, ministryrequestid, applicantcorrespondencelog): # raw requests should never be fee emails so they would only get handled by else statement # Handle fee processing templates if self.__is_fee_processing(applicantcorrespondencelog["templateid"]): - return self.__handle_fee_email(requestid, ministryrequestid, result, applicantcorrespondencelog) + 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, result, applicantcorrespondencelog): @@ -45,7 +46,6 @@ def __handle_fee_email(self, requestid, ministryrequestid, result, applicantcorr if _paymentexpirydate not in (None, ""): paymentservice().createpayment(requestid, ministryrequestid, _attributes, AuthHelper.getuserid()) requestservice().postcorrespondenceeventtoworkflow(requestid, ministryrequestid, result.identifier, applicantcorrespondencelog['attributes'], applicantcorrespondencelog['templateid']) - return result def __is_fee_processing(self, templateid): From cad7bcb73e5924e5c0732dd03940016fe18191ca Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Mon, 13 Jan 2025 18:31:10 -0800 Subject: [PATCH 75/87] Revert "Print requestid" This reverts commit 73977f765121bf17f244b6bc2e93b67d23dc3132. --- .../request_api/resources/applicantcorrespondence.py | 2 -- .../request_api/services/communicationwrapperservice.py | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/request-management-api/request_api/resources/applicantcorrespondence.py b/request-management-api/request_api/resources/applicantcorrespondence.py index f239ae45c..5cacfcd5f 100644 --- a/request-management-api/request_api/resources/applicantcorrespondence.py +++ b/request-management-api/request_api/resources/applicantcorrespondence.py @@ -92,8 +92,6 @@ def post(requestid, ministryrequestid): requestjson = request.get_json() applicantcorrespondencelog = FOIApplicantCorrespondenceSchema().load(data=requestjson) rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid) - print("requestid", requestid) - print("rawrequestid", rawrequestid) result = communicationwrapperservice().send_email(rawrequestid, ministryrequestid, applicantcorrespondencelog) return {'status': result.success, 'message': result.message, 'id': result.identifier}, 200 except BusinessException: diff --git a/request-management-api/request_api/services/communicationwrapperservice.py b/request-management-api/request_api/services/communicationwrapperservice.py index b929b6769..09bb1dc23 100644 --- a/request-management-api/request_api/services/communicationwrapperservice.py +++ b/request-management-api/request_api/services/communicationwrapperservice.py @@ -29,13 +29,12 @@ def send_email(self, requestid, ministryrequestid, applicantcorrespondencelog): # raw requests should never be fee emails so they would only get handled by else statement # Handle fee processing templates if self.__is_fee_processing(applicantcorrespondencelog["templateid"]): - self.__handle_fee_email(requestid, ministryrequestid, result, applicantcorrespondencelog) + 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, result, applicantcorrespondencelog): @@ -46,6 +45,7 @@ def __handle_fee_email(self, requestid, ministryrequestid, result, applicantcorr if _paymentexpirydate not in (None, ""): paymentservice().createpayment(requestid, ministryrequestid, _attributes, AuthHelper.getuserid()) requestservice().postcorrespondenceeventtoworkflow(requestid, ministryrequestid, result.identifier, applicantcorrespondencelog['attributes'], applicantcorrespondencelog['templateid']) + return result def __is_fee_processing(self, templateid): From 77460290f9698e7832252fd0e2f3abe03dc780ed Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Mon, 13 Jan 2025 18:35:46 -0800 Subject: [PATCH 76/87] Test Email --- .../request_api/resources/applicantcorrespondence.py | 2 +- .../request_api/services/communicationwrapperservice.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/request-management-api/request_api/resources/applicantcorrespondence.py b/request-management-api/request_api/resources/applicantcorrespondence.py index 5cacfcd5f..08d23dff9 100644 --- a/request-management-api/request_api/resources/applicantcorrespondence.py +++ b/request-management-api/request_api/resources/applicantcorrespondence.py @@ -92,7 +92,7 @@ def post(requestid, ministryrequestid): requestjson = request.get_json() applicantcorrespondencelog = FOIApplicantCorrespondenceSchema().load(data=requestjson) rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid) - result = communicationwrapperservice().send_email(rawrequestid, ministryrequestid, applicantcorrespondencelog) + 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 diff --git a/request-management-api/request_api/services/communicationwrapperservice.py b/request-management-api/request_api/services/communicationwrapperservice.py index 09bb1dc23..0b97a0497 100644 --- a/request-management-api/request_api/services/communicationwrapperservice.py +++ b/request-management-api/request_api/services/communicationwrapperservice.py @@ -18,10 +18,10 @@ 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()) From e97d8532c8d8b5e62aee57c0ed75f295fa06088f Mon Sep 17 00:00:00 2001 From: Milos Despotovic Date: Tue, 14 Jan 2025 16:56:14 -0800 Subject: [PATCH 77/87] Update endpoints to handle raw requests accurately --- .../FOIApplicantCorrespondencesRawRequests.py | 6 +-- .../resources/applicantcorrespondence.py | 50 +++++++++++++++---- .../request_api/services/requestservice.py | 2 - 3 files changed, 41 insertions(+), 17 deletions(-) diff --git a/request-management-api/request_api/models/FOIApplicantCorrespondencesRawRequests.py b/request-management-api/request_api/models/FOIApplicantCorrespondencesRawRequests.py index 997541d04..9d1a2ffab 100644 --- a/request-management-api/request_api/models/FOIApplicantCorrespondencesRawRequests.py +++ b/request-management-api/request_api/models/FOIApplicantCorrespondencesRawRequests.py @@ -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}) diff --git a/request-management-api/request_api/resources/applicantcorrespondence.py b/request-management-api/request_api/resources/applicantcorrespondence.py index 08d23dff9..1ccede98b 100644 --- a/request-management-api/request_api/resources/applicantcorrespondence.py +++ b/request-management-api/request_api/resources/applicantcorrespondence.py @@ -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: @@ -91,7 +94,10 @@ def post(requestid, ministryrequestid): try: requestjson = request.get_json() applicantcorrespondencelog = FOIApplicantCorrespondenceSchema().load(data=requestjson) - rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid) + 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: @@ -110,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: @@ -131,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) @@ -153,7 +165,10 @@ class FOIFlowApplicantCorrespondenceDraft(Resource): def post(ministryrequestid, rawrequestid, correspondenceid): try: requestjson = request.get_json() - rawrequestidfromfoirequest = requestservice().getrawrequestidbyfoirequestid(rawrequestid) + if ministryrequestid == 'None': + rawrequestidfromfoirequest = rawrequestid + else: + rawrequestidfromfoirequest = requestservice().getrawrequestidbyfoirequestid(rawrequestid) if ministryrequestid == 'None' or "israwrequest" in requestjson and requestjson["israwrequest"] == True: rawresult = applicantcorrespondenceservice().deleteapplicantcorrespondencelograwrequest(rawrequestidfromfoirequest, correspondenceid, AuthHelper.getuserid()) return {'status': rawresult.success, 'message':rawresult.message,'id':rawresult.identifier} , 200 @@ -177,7 +192,10 @@ class FOIFlowApplicantCorrespondenceEmail(Resource): def post(ministryrequestid, rawrequestid): try: requestjson = request.get_json() - rawrequestidfromfoirequest = requestservice().getrawrequestidbyfoirequestid(rawrequestid) + if ministryrequestid == 'None': + rawrequestidfromfoirequest = rawrequestid + else: + rawrequestidfromfoirequest = requestservice().getrawrequestidbyfoirequestid(rawrequestid) correspondenceemail = FOIApplicantCorrespondenceEmailSchema().load(data=requestjson) result = correspondenceemailservice().savecorrespondenceemail(ministryrequestid, rawrequestidfromfoirequest, correspondenceemail, AuthHelper.getuserid()) @@ -191,7 +209,10 @@ def post(ministryrequestid, rawrequestid): @auth.require def get(ministryrequestid, rawrequestid): try: - rawrequestidfromfoirequest = requestservice().getrawrequestidbyfoirequestid(rawrequestid) + if ministryrequestid == 'None': + rawrequestidfromfoirequest = rawrequestid + else: + rawrequestidfromfoirequest = requestservice().getrawrequestidbyfoirequestid(rawrequestid) correspondenceemails = correspondenceemailservice().getcorrespondenceemails(ministryrequestid, rawrequestidfromfoirequest) return json.dumps(correspondenceemails) , 200 except BusinessException: @@ -208,7 +229,10 @@ class FOIFlowApplicantCorrespondenceResponse(Resource): def post(ministryrequestid, rawrequestid): try: requestjson = request.get_json() - rawrequestidfromfoirequest = requestservice().getrawrequestidbyfoirequestid(rawrequestid) + if ministryrequestid == 'None': + rawrequestidfromfoirequest = rawrequestid + else: + rawrequestidfromfoirequest = 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()) @@ -230,7 +254,10 @@ class FOIFlowApplicantCorrespondenceEditResponse(Resource): @auth.require def post(ministryrequestid, rawrequestid): try: - rawrequestidfromfoirequest = requestservice().getrawrequestidbyfoirequestid(rawrequestid) + if ministryrequestid == 'None': + rawrequestidfromfoirequest = rawrequestid + else: + rawrequestidfromfoirequest = requestservice().getrawrequestidbyfoirequestid(rawrequestid) requestjson = request.get_json() correspondenceemail = FOIApplicantCorrespondenceEditResponseSchema().load(data=requestjson) if ministryrequestid == 'None' or 'israwrequest' in requestjson and requestjson['israwrequest'] == True: @@ -253,7 +280,10 @@ class FOIFlowApplicantCorrespondenceResponse(Resource): def post(ministryrequestid, rawrequestid, correspondenceid): try: requestjson = request.get_json() - rawrequestidfromfoirequest = requestservice().getrawrequestidbyfoirequestid(rawrequestid) + if ministryrequestid == 'None': + rawrequestidfromfoirequest = rawrequestid + else: + rawrequestidfromfoirequest = requestservice().getrawrequestidbyfoirequestid(rawrequestid) if ministryrequestid == 'None' or 'israwrequest' in requestjson and requestjson['israwrequest'] == True: rawresult = applicantcorrespondenceservice().deleteapplicantcorrespondencelograwrequest(rawrequestidfromfoirequest, correspondenceid, AuthHelper.getuserid()) return {'status': rawresult.success, 'message':rawresult.message,'id':rawresult.identifier} , 200 diff --git a/request-management-api/request_api/services/requestservice.py b/request-management-api/request_api/services/requestservice.py index 121de75fa..2128c9e25 100644 --- a/request-management-api/request_api/services/requestservice.py +++ b/request-management-api/request_api/services/requestservice.py @@ -158,8 +158,6 @@ def getrawrequestidbyfoirequestid(self, foirequestid): if foirequestid == 'undefined': return None rawrequestid = requestservicegetter().getrawrequestidbyfoirequestid(foirequestid) - if rawrequestid is None: - rawrequestid = foirequestid return rawrequestid def getrequestdetailsforministry( From d1eedf7cd77edef57503fa23e95d4699c08504cc Mon Sep 17 00:00:00 2001 From: Milos Despotovic Date: Tue, 14 Jan 2025 17:04:28 -0800 Subject: [PATCH 78/87] Change variable name --- .../resources/applicantcorrespondence.py | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/request-management-api/request_api/resources/applicantcorrespondence.py b/request-management-api/request_api/resources/applicantcorrespondence.py index 1ccede98b..e5dc8c0a3 100644 --- a/request-management-api/request_api/resources/applicantcorrespondence.py +++ b/request-management-api/request_api/resources/applicantcorrespondence.py @@ -166,14 +166,14 @@ def post(ministryrequestid, rawrequestid, correspondenceid): try: requestjson = request.get_json() if ministryrequestid == 'None': - rawrequestidfromfoirequest = rawrequestid + rawrequestidforrequest = rawrequestid else: - rawrequestidfromfoirequest = requestservice().getrawrequestidbyfoirequestid(rawrequestid) + 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 @@ -193,11 +193,11 @@ def post(ministryrequestid, rawrequestid): try: requestjson = request.get_json() if ministryrequestid == 'None': - rawrequestidfromfoirequest = rawrequestid + rawrequestidforrequest = rawrequestid else: - rawrequestidfromfoirequest = requestservice().getrawrequestidbyfoirequestid(rawrequestid) + 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: @@ -210,10 +210,10 @@ def post(ministryrequestid, rawrequestid): def get(ministryrequestid, rawrequestid): try: if ministryrequestid == 'None': - rawrequestidfromfoirequest = rawrequestid + rawrequestidforrequest = rawrequestid else: - rawrequestidfromfoirequest = requestservice().getrawrequestidbyfoirequestid(rawrequestid) - correspondenceemails = correspondenceemailservice().getcorrespondenceemails(ministryrequestid, rawrequestidfromfoirequest) + rawrequestidforrequest = requestservice().getrawrequestidbyfoirequestid(rawrequestid) + correspondenceemails = correspondenceemailservice().getcorrespondenceemails(ministryrequestid, rawrequestidforrequest) return json.dumps(correspondenceemails) , 200 except BusinessException: return "Unable to retrieve correspondence emails" , 500 @@ -230,14 +230,14 @@ def post(ministryrequestid, rawrequestid): try: requestjson = request.get_json() if ministryrequestid == 'None': - rawrequestidfromfoirequest = rawrequestid + rawrequestidforrequest = rawrequestid else: - rawrequestidfromfoirequest = requestservice().getrawrequestidbyfoirequestid(rawrequestid) + 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: @@ -255,13 +255,13 @@ class FOIFlowApplicantCorrespondenceEditResponse(Resource): def post(ministryrequestid, rawrequestid): try: if ministryrequestid == 'None': - rawrequestidfromfoirequest = rawrequestid + rawrequestidforrequest = rawrequestid else: - rawrequestidfromfoirequest = requestservice().getrawrequestidbyfoirequestid(rawrequestid) + 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()) @@ -281,14 +281,14 @@ def post(ministryrequestid, rawrequestid, correspondenceid): try: requestjson = request.get_json() if ministryrequestid == 'None': - rawrequestidfromfoirequest = rawrequestid + rawrequestidforrequest = rawrequestid else: - rawrequestidfromfoirequest = requestservice().getrawrequestidbyfoirequestid(rawrequestid) + 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 From 0e4427a9c2b768f5f788f4d50f552ad5bb48c7aa Mon Sep 17 00:00:00 2001 From: Milos Despotovic Date: Wed, 15 Jan 2025 11:30:50 -0800 Subject: [PATCH 79/87] Fix error handling issue --- .../request_api/resources/applicantcorrespondence.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/request-management-api/request_api/resources/applicantcorrespondence.py b/request-management-api/request_api/resources/applicantcorrespondence.py index e5dc8c0a3..2f975532d 100644 --- a/request-management-api/request_api/resources/applicantcorrespondence.py +++ b/request-management-api/request_api/resources/applicantcorrespondence.py @@ -99,7 +99,7 @@ def post(requestid, ministryrequestid): else: rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid) result = communicationwrapperservice().send_email(requestid, rawrequestid, ministryrequestid, applicantcorrespondencelog) - return {'status': result.success, 'message': result.message, 'id': result.identifier}, 200 + return {'status': result['success'], 'message': result['message'], 'id': result['identifier']}, 200 except BusinessException: return "Error happened while saving applicant correspondence log", 500 From 7e136d17ab0dcc681cd574ac1244046bb4d77b64 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Wed, 15 Jan 2025 12:11:45 -0800 Subject: [PATCH 80/87] Revert "Merge pull request #5525 from bcgov/test-marshal-MD-correspondenceupdate" This reverts commit 2da801aaec9cb2a784ffe2e84d4a0cbb5a111d67, reversing changes made to d5eebfbb80aa189012530215c570f987b7301741. --- .../request_api/resources/applicantcorrespondence.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/request-management-api/request_api/resources/applicantcorrespondence.py b/request-management-api/request_api/resources/applicantcorrespondence.py index 2f975532d..e5dc8c0a3 100644 --- a/request-management-api/request_api/resources/applicantcorrespondence.py +++ b/request-management-api/request_api/resources/applicantcorrespondence.py @@ -99,7 +99,7 @@ def post(requestid, ministryrequestid): else: rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid) result = communicationwrapperservice().send_email(requestid, rawrequestid, ministryrequestid, applicantcorrespondencelog) - return {'status': result['success'], 'message': result['message'], 'id': result['identifier']}, 200 + return {'status': result.success, 'message': result.message, 'id': result.identifier}, 200 except BusinessException: return "Error happened while saving applicant correspondence log", 500 From 5d70a0fd558e54f6c3e5553f895c794dd3417e08 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Wed, 15 Jan 2025 12:39:34 -0800 Subject: [PATCH 81/87] Print cfrfee --- request-management-api/request_api/services/cfrfeeservice.py | 2 ++ request-management-api/request_api/services/fee_service.py | 1 + .../request_api/services/foirequest/requestservicegetter.py | 1 + 3 files changed, 4 insertions(+) diff --git a/request-management-api/request_api/services/cfrfeeservice.py b/request-management-api/request_api/services/cfrfeeservice.py index 3dd4cc5fc..58a36b7cf 100644 --- a/request-management-api/request_api/services/cfrfeeservice.py +++ b/request-management-api/request_api/services/cfrfeeservice.py @@ -75,10 +75,12 @@ def __preparecfrfee(self, ministryrequestid, data={}, getprevious=True): def getcfrfee(self, ministryrequestid): cfrfee = FOIRequestCFRFee.getcfrfee(ministryrequestid) + print("cfrfee", cfrfee) return self.__formatcfrfee(cfrfee) def getapprovedcfrfee(self, ministryrequestid): cfrfee = FOIRequestCFRFee.getapprovedcfrfee(ministryrequestid) + print("approvedcfrfee", cfrfee) return self.__formatcfrfee(cfrfee) diff --git a/request-management-api/request_api/services/fee_service.py b/request-management-api/request_api/services/fee_service.py index a68a6dd31..6eae4481e 100644 --- a/request-management-api/request_api/services/fee_service.py +++ b/request-management-api/request_api/services/fee_service.py @@ -69,6 +69,7 @@ def init_payment(self, pay_request: Dict): total = self._get_cfr_fee(self.request_id, pay_request) else: total = quantity * self.fee_code.fee + print("total", total) self.payment = Payment( fee_code_id=self.fee_code.fee_code_id, quantity=quantity, diff --git a/request-management-api/request_api/services/foirequest/requestservicegetter.py b/request-management-api/request_api/services/foirequest/requestservicegetter.py index 14c43eb74..ee793620e 100644 --- a/request-management-api/request_api/services/foirequest/requestservicegetter.py +++ b/request-management-api/request_api/services/foirequest/requestservicegetter.py @@ -117,6 +117,7 @@ def getrequestdetails(self,foirequestid, foiministryrequestid): requestdetails = self.getrequest(foirequestid, foiministryrequestid) approvedcfrfee = cfrfeeservice().getapprovedcfrfee(foiministryrequestid) cfrfee = cfrfeeservice().getcfrfee(foiministryrequestid) + print("cfrfee2", cfrfee) payment = paymentservice().getpayment(foirequestid, foiministryrequestid) if approvedcfrfee is not None and approvedcfrfee != {}: requestdetails['cfrfee'] = approvedcfrfee From 30f5277d9d4a7125974a492351f6d8d50f50e95e Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Wed, 15 Jan 2025 12:58:45 -0800 Subject: [PATCH 82/87] Revert "Print cfrfee" This reverts commit 5d70a0fd558e54f6c3e5553f895c794dd3417e08. --- request-management-api/request_api/services/cfrfeeservice.py | 2 -- request-management-api/request_api/services/fee_service.py | 1 - .../request_api/services/foirequest/requestservicegetter.py | 1 - 3 files changed, 4 deletions(-) diff --git a/request-management-api/request_api/services/cfrfeeservice.py b/request-management-api/request_api/services/cfrfeeservice.py index 58a36b7cf..3dd4cc5fc 100644 --- a/request-management-api/request_api/services/cfrfeeservice.py +++ b/request-management-api/request_api/services/cfrfeeservice.py @@ -75,12 +75,10 @@ def __preparecfrfee(self, ministryrequestid, data={}, getprevious=True): def getcfrfee(self, ministryrequestid): cfrfee = FOIRequestCFRFee.getcfrfee(ministryrequestid) - print("cfrfee", cfrfee) return self.__formatcfrfee(cfrfee) def getapprovedcfrfee(self, ministryrequestid): cfrfee = FOIRequestCFRFee.getapprovedcfrfee(ministryrequestid) - print("approvedcfrfee", cfrfee) return self.__formatcfrfee(cfrfee) diff --git a/request-management-api/request_api/services/fee_service.py b/request-management-api/request_api/services/fee_service.py index 6eae4481e..a68a6dd31 100644 --- a/request-management-api/request_api/services/fee_service.py +++ b/request-management-api/request_api/services/fee_service.py @@ -69,7 +69,6 @@ def init_payment(self, pay_request: Dict): total = self._get_cfr_fee(self.request_id, pay_request) else: total = quantity * self.fee_code.fee - print("total", total) self.payment = Payment( fee_code_id=self.fee_code.fee_code_id, quantity=quantity, diff --git a/request-management-api/request_api/services/foirequest/requestservicegetter.py b/request-management-api/request_api/services/foirequest/requestservicegetter.py index ee793620e..14c43eb74 100644 --- a/request-management-api/request_api/services/foirequest/requestservicegetter.py +++ b/request-management-api/request_api/services/foirequest/requestservicegetter.py @@ -117,7 +117,6 @@ def getrequestdetails(self,foirequestid, foiministryrequestid): requestdetails = self.getrequest(foirequestid, foiministryrequestid) approvedcfrfee = cfrfeeservice().getapprovedcfrfee(foiministryrequestid) cfrfee = cfrfeeservice().getcfrfee(foiministryrequestid) - print("cfrfee2", cfrfee) payment = paymentservice().getpayment(foirequestid, foiministryrequestid) if approvedcfrfee is not None and approvedcfrfee != {}: requestdetails['cfrfee'] = approvedcfrfee From 00d595796e29397afd1c8cafc2d222f1f1300097 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Wed, 15 Jan 2025 13:05:40 -0800 Subject: [PATCH 83/87] Print url_params_dict --- request-management-api/request_api/services/fee_service.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/request-management-api/request_api/services/fee_service.py b/request-management-api/request_api/services/fee_service.py index a68a6dd31..004b4ad7e 100644 --- a/request-management-api/request_api/services/fee_service.py +++ b/request-management-api/request_api/services/fee_service.py @@ -77,6 +77,7 @@ def init_payment(self, pay_request: Dict): request_id=self.request_id ).flush() + print("self_payment", self.payment) self.payment.paybc_url = self._get_paybc_url(self.fee_code, return_route) self.payment.transaction_number = self._get_transaction_number() self.payment.commit() @@ -173,6 +174,7 @@ def _get_paybc_url(self, fee_code: FeeCode, return_route): 'revenue': self._get_gl_coding(self.payment.total, revenue_account) } + print("url_params_dict", url_params_dict) url_params = urlencode(url_params_dict) # unquote is used below so that unescaped url string can be hashed url_params_dict['hashValue'] = HashService.encode(unquote_plus(url_params)) From 611ce0ed97893077e63611ef27704d9f9c538d0e Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Wed, 15 Jan 2025 13:58:28 -0800 Subject: [PATCH 84/87] Print request_json --- request-management-api/request_api/resources/fee.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/request-management-api/request_api/resources/fee.py b/request-management-api/request_api/resources/fee.py index b3b8216ef..c9b12e86d 100644 --- a/request-management-api/request_api/resources/fee.py +++ b/request-management-api/request_api/resources/fee.py @@ -61,6 +61,8 @@ def post(request_id: int): try: request_json = request.get_json() fee_service: FeeService = FeeService(request_id=request_id, code=request_json['fee_code']) + print("request_id", request_id) + print("request_json", request_json) pay_response = fee_service.init_payment(request_json) return pay_response, 201 except BusinessException as e: From 5c0890559951aa5b52c83c41c7ea7e4d2242d4e9 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Wed, 15 Jan 2025 15:47:28 -0800 Subject: [PATCH 85/87] Revert "Print url_params_dict" This reverts commit 00d595796e29397afd1c8cafc2d222f1f1300097. --- request-management-api/request_api/services/fee_service.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/request-management-api/request_api/services/fee_service.py b/request-management-api/request_api/services/fee_service.py index 004b4ad7e..a68a6dd31 100644 --- a/request-management-api/request_api/services/fee_service.py +++ b/request-management-api/request_api/services/fee_service.py @@ -77,7 +77,6 @@ def init_payment(self, pay_request: Dict): request_id=self.request_id ).flush() - print("self_payment", self.payment) self.payment.paybc_url = self._get_paybc_url(self.fee_code, return_route) self.payment.transaction_number = self._get_transaction_number() self.payment.commit() @@ -174,7 +173,6 @@ def _get_paybc_url(self, fee_code: FeeCode, return_route): 'revenue': self._get_gl_coding(self.payment.total, revenue_account) } - print("url_params_dict", url_params_dict) url_params = urlencode(url_params_dict) # unquote is used below so that unescaped url string can be hashed url_params_dict['hashValue'] = HashService.encode(unquote_plus(url_params)) From f8ab00fa815a251f1dffe24eb7846d02af5df450 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Wed, 15 Jan 2025 15:47:39 -0800 Subject: [PATCH 86/87] Revert "Print request_json" This reverts commit 611ce0ed97893077e63611ef27704d9f9c538d0e. --- request-management-api/request_api/resources/fee.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/request-management-api/request_api/resources/fee.py b/request-management-api/request_api/resources/fee.py index c9b12e86d..b3b8216ef 100644 --- a/request-management-api/request_api/resources/fee.py +++ b/request-management-api/request_api/resources/fee.py @@ -61,8 +61,6 @@ def post(request_id: int): try: request_json = request.get_json() fee_service: FeeService = FeeService(request_id=request_id, code=request_json['fee_code']) - print("request_id", request_id) - print("request_json", request_json) pay_response = fee_service.init_payment(request_json) return pay_response, 201 except BusinessException as e: From 594d88d309f71d8b8cd063770d67e7929d8a08b1 Mon Sep 17 00:00:00 2001 From: Jocelyn Cabildo Date: Wed, 15 Jan 2025 16:00:06 -0800 Subject: [PATCH 87/87] Update ApplicantCorrespondence Result --- .../request_api/resources/applicantcorrespondence.py | 2 +- .../request_api/services/communicationwrapperservice.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/request-management-api/request_api/resources/applicantcorrespondence.py b/request-management-api/request_api/resources/applicantcorrespondence.py index e5dc8c0a3..2f975532d 100644 --- a/request-management-api/request_api/resources/applicantcorrespondence.py +++ b/request-management-api/request_api/resources/applicantcorrespondence.py @@ -99,7 +99,7 @@ def post(requestid, ministryrequestid): else: rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid) result = communicationwrapperservice().send_email(requestid, rawrequestid, ministryrequestid, applicantcorrespondencelog) - return {'status': result.success, 'message': result.message, 'id': result.identifier}, 200 + return {'status': result['success'], 'message': result['message'], 'id': result['identifier']}, 200 except BusinessException: return "Error happened while saving applicant correspondence log", 500 diff --git a/request-management-api/request_api/services/communicationwrapperservice.py b/request-management-api/request_api/services/communicationwrapperservice.py index 0b97a0497..dc287f658 100644 --- a/request-management-api/request_api/services/communicationwrapperservice.py +++ b/request-management-api/request_api/services/communicationwrapperservice.py @@ -45,7 +45,7 @@ def __handle_fee_email(self, requestid, ministryrequestid, result, applicantcorr if _paymentexpirydate not in (None, ""): paymentservice().createpayment(requestid, ministryrequestid, _attributes, AuthHelper.getuserid()) requestservice().postcorrespondenceeventtoworkflow(requestid, ministryrequestid, result.identifier, applicantcorrespondencelog['attributes'], applicantcorrespondencelog['templateid']) - return result + return {"success" : True, "message": "Sent successfully", "identifier": -1} def __is_fee_processing(self, templateid):