diff --git a/request-management-api/request_api/models/FOIMinistryRequests.py b/request-management-api/request_api/models/FOIMinistryRequests.py index 97e089955..40db46ec4 100644 --- a/request-management-api/request_api/models/FOIMinistryRequests.py +++ b/request-management-api/request_api/models/FOIMinistryRequests.py @@ -1364,7 +1364,7 @@ def getaxisrequestidforrequest(cls,requestid, ministryrequestid): def getmetadata(cls,ministryrequestid): requestdetails = {} try: - sql = """select fmr.version, assignedto, fa.firstname, fa.lastname, pa.bcgovcode, fmr.programareaid, f.requesttype + sql = """select fmr.version, assignedto, fa.firstname, fa.lastname, pa.bcgovcode, fmr.programareaid, f.requesttype, fmr.isoipcreview from "FOIMinistryRequests" fmr join "FOIRequests" f on fmr.foirequest_id = f.foirequestid and fmr.foirequestversion_id = f."version" FULL OUTER JOIN "FOIAssignees" fa ON fa.username = fmr.assignedto INNER JOIN "ProgramAreas" pa ON pa.programareaid = fmr.programareaid @@ -1379,6 +1379,7 @@ def getmetadata(cls,ministryrequestid): requestdetails["version"] = row["version"] requestdetails["programareaid"] = row["programareaid"] requestdetails["requesttype"] = row["requesttype"] + requestdetails["isoipcreview"] = row["isoipcreview"] except Exception as ex: logging.error(ex) raise ex diff --git a/request-management-api/request_api/services/events/oipc.py b/request-management-api/request_api/services/events/oipc.py index 15b9b22ce..a440a1104 100644 --- a/request-management-api/request_api/services/events/oipc.py +++ b/request-management-api/request_api/services/events/oipc.py @@ -19,10 +19,14 @@ class oipcevent: """ def createoipcevent(self, requestid, userid): + ministryrequest = FOIMinistryRequest.getmetadata(requestid) + if ministryrequest["isoipcreview"] in (None, False): + notificationservice().dismissnotifications_by_requestid_type(requestid, "ministryrequest", self.__notificationtype()) + return DefaultMethodResult(True,'No change',requestid) inquiryoutcomes = oipcservice().getinquiryoutcomes() - version = FOIMinistryRequest.getversionforrequest(requestid) + version = ministryrequest["version"] curoipcs = FOIRequestOIPC.getoipc(requestid, version) - prevoipcs = FOIRequestOIPC.getoipc(requestid, version[0]-1) + prevoipcs = FOIRequestOIPC.getoipc(requestid, version-1) oipcsummary = self.__maintained(curoipcs, prevoipcs, inquiryoutcomes) if oipcsummary is None or (oipcsummary and len(oipcsummary) <1): return DefaultMethodResult(True,'No change',requestid) diff --git a/request-management-api/request_api/services/notificationservice.py b/request-management-api/request_api/services/notificationservice.py index 1e2c91a13..89f8643a9 100644 --- a/request-management-api/request_api/services/notificationservice.py +++ b/request-management-api/request_api/services/notificationservice.py @@ -117,6 +117,17 @@ def dismissnotifications_by_requestid_type_userid(self, requestid, requesttype, _ids = FOIRawRequestNotification.getnotificationidsbynumberandtype('U-00' + str(foirequest['requestid']), notificationtypelabels[0]) self.__deletenotificationbyuserandid(requesttype, _ids, userid) + def dismissnotifications_by_requestid_type(self, requestid, requesttype, notificationtype): + notificationtypelabels = self.__getcleanupnotificationids(notificationtype) + foirequest = self.getrequest(requestid, requesttype) + if requesttype == "ministryrequest": + idnumber = foirequest["filenumber"] + _ids = FOIRequestNotification.getnotificationidsbynumberandtype(idnumber, notificationtypelabels) + else: + _ids = FOIRawRequestNotification.getnotificationidsbynumberandtype('U-00' + str(foirequest['requestid']), notificationtypelabels[0]) + self.__deletenotificationids(requesttype, _ids) + + def __createnotification(self, message, requestid, requesttype, notificationtype, userid, foirequest, requestjson=None): notification = self.__preparenotification(message, requesttype, notificationtype, userid, foirequest, requestjson) if notification is not None: