Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test marshal sync #5217

Merged
merged 35 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
93260bf
Merge pull request #5141 from bcgov/dev-marshal-MD-merge-main
milosdes Apr 9, 2024
10be2bb
Add records ready for review to enum and request filters
milosdes Apr 10, 2024
1f96b2e
Add records ready for review state to filter
milosdes Apr 10, 2024
53d6e25
Added RTT and notification for RTT attachments
Apr 15, 2024
ff51bf0
remove printf statements
Apr 15, 2024
70756e4
Added attachment upload event to the json files
Apr 15, 2024
731536d
Merge pull request #5142 from bcgov/dev-marshal-MD-3085
milosdes Apr 15, 2024
4dbd1eb
Added the migration script for attachement upload event
antsand Apr 15, 2024
ea139b6
Updated notification code to include RRT message
antsand Apr 15, 2024
b89bae4
Remove all print statements
antsand Apr 15, 2024
bb09559
Merge branch 'shiva-RRT-2965' into dev-marshal-shiva-2965-RRT
antsand Apr 15, 2024
12ee340
Merge pull request #5148 from bcgov/dev-marshal-shiva-2965-RRT
antsand Apr 15, 2024
8b5b9dd
Remove custom unassigned queue for separate IAO teams
milosdes Apr 16, 2024
d2f38b6
Merge pull request #5149 from bcgov/dev-marshal-MD-3084
milosdes Apr 16, 2024
3cb5d86
Added comment and scanning team notifcation for attachement service
antsand Apr 18, 2024
038c1b6
Fix RRT indententation
antsand Apr 22, 2024
db5f194
Updated RRT flow and fixes
antsand Apr 23, 2024
4f7bd02
Remove RRT and call it from the parent
antsand Apr 23, 2024
233720c
Remove comments
antsand Apr 24, 2024
8a93e29
Fixed comments
antsand Apr 26, 2024
0c68a08
Merge pull request #5152 from bcgov/dev-marshal-shiva-2965-RRT
antsand Apr 27, 2024
1498d9a
Fix for RAW request
antsand Apr 29, 2024
26b35bd
Updated PR comments
antsand May 1, 2024
160352b
remove print statements
antsand May 1, 2024
2cf1d0e
fix print
antsand May 1, 2024
1271f87
remove print
antsand May 1, 2024
6e829c3
remove print
antsand May 1, 2024
1b52035
Merge pull request #5169 from bcgov/dev-marshal-shiva-2965-RRT
antsand May 1, 2024
3890eae
Merge remote-tracking branch 'origin' into test-marshal-RRT-2965
May 2, 2024
1de04bf
Merge branch 'test-marshal' into test-marshal-RRT-2965
antsand May 2, 2024
6663ac7
Merge pull request #5181 from bcgov/test-marshal-RRT-2965
antsand May 7, 2024
2ea65a4
Merge branch 'test-marshal' into dev-marshal
nkan-aot2 May 8, 2024
1104c26
Merge branch 'test-marshal' into dev-marshal
nkan-aot2 May 8, 2024
afad6ea
fix rrt migration order
nkan-aot2 May 9, 2024
4e8b946
Merge branch 'test-marshal' into dev-marshal
nkan-aot2 May 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions forms-flow-web/src/constants/FOI/statusEnum.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,13 @@ const AttachmentCategories = Object.freeze({
bgcolor: "#595959",
type: ["tag"],
},
{
name: "rrt",
tags: ["rrt"],
display: "RRT",
bgcolor: "#003366",
type: ["tag"],
},
{
// transition: Response -> On hold
name: "response-onhold",
Expand Down
4 changes: 4 additions & 0 deletions notification-manager/common/notificationtypes.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,9 @@
"oipcduereminder": {
"name": "OIPC Due Reminder",
"notificationtypelabel": "oipcduereminder"
},
"attachmentuploadevent": {
"name": "Attachment Upload Event",
"notificationtypelabel": "attachmentuploadevent"
}
}
4 changes: 4 additions & 0 deletions request-management-api/common/notificationtypes.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,9 @@
"oipcduereminder": {
"name": "OIPC Due Reminder",
"notificationtypelabel": "oipcduereminder"
},
"attachmentuploadevent": {
"name": "Attachment Upload Event",
"notificationtypelabel": "attachmentuploadevent"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""Add RTT tag

Revision ID: e698b39da6bd
Revises: c590239f1b2f
Create Date: 2024-04-15 08:17:20.554269

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'e698b39da6bd'
down_revision = 'c590239f1b2f'
branch_labels = None
depends_on = None

def upgrade():
op.execute('INSERT INTO public."NotificationTypes"(name, description, isactive,notificationtypelabel ) VALUES (\'Attachment Upload Event\', \'Attachment Upload Event\', true, \'attachmentuploadevent\');')

def downgrade():
op.execute('DELETE FROM public."NotificationTypes" WHERE name = \'Attachment Upload Event\';')
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def getrequests(cls, group = None):
elif (group in ProcessingTeamWithKeycloackGroup.list()):
_ministryrequestids = _session.query(distinct(FOIMinistryRequest.foiministryrequestid)).filter(and_(FOIMinistryRequest.isactive == True), and_(and_(FOIMinistryRequest.assignedgroup == group),and_(FOIMinistryRequest.requeststatuslabel.in_([StateName.open.name,StateName.callforrecords.name,StateName.closed.name,StateName.recordsreview.name,StateName.feeestimate.name,StateName.consult.name,StateName.ministrysignoff.value,StateName.onhold.name,StateName.response.name,StateName.peerreview.name,StateName.tagging.name,StateName.readytoscan.name])))).all()
else:
_ministryrequestids = _session.query(distinct(FOIMinistryRequest.foiministryrequestid)).filter(and_(FOIMinistryRequest.isactive == True), or_(and_(FOIMinistryRequest.assignedgroup == group),and_(FOIMinistryRequest.assignedministrygroup == group,or_(FOIMinistryRequest.requeststatuslabel.in_([StateName.callforrecords.name,StateName.recordsreview.name,StateName.feeestimate.name,StateName.consult.name,StateName.ministrysignoff.name,StateName.onhold.name,StateName.deduplication.name,StateName.harmsassessment.name,StateName.response.name,StateName.peerreview.name,StateName.tagging.name,StateName.readytoscan.name]))))).all()
_ministryrequestids = _session.query(distinct(FOIMinistryRequest.foiministryrequestid)).filter(and_(FOIMinistryRequest.isactive == True), or_(and_(FOIMinistryRequest.assignedgroup == group),and_(FOIMinistryRequest.assignedministrygroup == group,or_(FOIMinistryRequest.requeststatuslabel.in_([StateName.callforrecords.name,StateName.recordsreview.name,StateName.recordsreadyforreview.name,StateName.feeestimate.name,StateName.consult.name,StateName.ministrysignoff.name,StateName.onhold.name,StateName.deduplication.name,StateName.harmsassessment.name,StateName.response.name,StateName.peerreview.name,StateName.tagging.name,StateName.readytoscan.name]))))).all()

_requests = []
ministryrequest_schema = FOIMinistryRequestSchema()
Expand Down
3 changes: 3 additions & 0 deletions request-management-api/request_api/resources/foidocument.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from request_api.utils.util import cors_preflight, allowedorigins
from request_api.exceptions import BusinessException, Error
from request_api.services.documentservice import documentservice
from request_api.services.eventservice import eventservice
from request_api.schemas.foidocument import CreateDocumentSchema, RenameDocumentSchema, ReplaceDocumentSchema, ReclassifyDocumentSchema
import json
from marshmallow import Schema, fields, validate, ValidationError
Expand Down Expand Up @@ -73,6 +74,8 @@ def post(requestid, requesttype):
requestjson = request.get_json()
documentschema = CreateDocumentSchema().load(requestjson)
result = documentservice().createrequestdocument(requestid, documentschema, AuthHelper.getuserid(), requesttype)
if result.success == True:
eventservice().attachmenteventservice(requestid, documentschema['documents'], AuthHelper.getuserid(), requesttype)
return {'status': result.success, 'message':result.message} , 200
except ValidationError as err:
return {'status': False, 'message': str(err)}, 400
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from request_api.schemas.foidocument import CreateDocumentSchema
from request_api.services.external.storageservice import storageservice
from request_api.models.FOIApplicantCorrespondenceAttachments import FOIApplicantCorrespondenceAttachment
from request_api.services.eventservice import eventservice
from request_api.utils.enums import RequestType
import logging

Expand Down
60 changes: 60 additions & 0 deletions request-management-api/request_api/services/events/attachment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@

from request_api.services.commons.duecalculator import duecalculator
from request_api.services.notificationservice import notificationservice
from request_api.services.commentservice import commentservice
from request_api.models.FOIMinistryRequests import FOIMinistryRequest
from request_api.models.FOIRequestComments import FOIRequestComment
from request_api.models.FOIRawRequests import FOIRawRequest
from request_api.models.NotificationTypes import NotificationType
from request_api.exceptions import BusinessException
from request_api.models.default_method_result import DefaultMethodResult
from flask import current_app

class attachmentevent():
""" FOI Attachment Event management service

"""
def createattachmentevent(self, requestid, userid, documents, requesttype):
try:
for document in documents:
if 'rrt' in document['category']:
#Create notification event for RRT document
ministryversion = self.__getversionforrequest(requestid, requesttype)
message = self.notificationmessage('RRT', requestid)
notificationtype = NotificationType().getnotificationtypeid(self.__notificationtype())
ret = self.__createnotification(message, requestid, notificationtype, userid, requesttype)
comment = self.__createcomment(requestid, message, ministryversion, userid, requesttype)
return DefaultMethodResult(True, 'Attachment notification succedded', requestid) # ad the request id to the message
return DefaultMethodResult(True, 'No RTT attachment found' , requestid)
except BusinessException as exception:
current_app.logger.error("%s,%s" % ('Attachment upload notification error', exception.message))
return DefaultMethodResult(False,'Attachemnt notifications failed')

def __createnotification(self, message, requestid, notificationtype, userid, requesttype):
if message is not None:
return notificationservice().createnotification({"message" : message}, requestid, requesttype , notificationtype, userid)

def __createcomment(self, requestid, message, ministryversion, userid, requesttype):
if message is not None:
if requesttype == "ministryrequest":
_comment = {"ministryrequestid": requestid, "version": ministryversion, "comment": message}
return commentservice().createcomments(_comment, userid, 2)
else:
_comment = {"requestid": requestid, "version": ministryversion, "comment": message}
return commentservice().createrawrequestcomment(_comment, userid, 2)

def notificationmessage(self, type, ministryrequestid):
return f"{type} Attachment Uploaded on FOI Request {ministryrequestid}"

def __notificationtype(self):
return "Attachment Upload Event"

def __getversionforrequest(self, requestid, requesttype):
""" Returns the active version of the request id based on type.
"""
if requesttype == "ministryrequest":
document = FOIMinistryRequest.getversionforrequest(requestid)
else:
document = FOIRawRequest.getversionforrequest(requestid)
if document:
return document[0]
12 changes: 11 additions & 1 deletion request-management-api/request_api/services/eventservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from request_api.services.events.oipcduedate import oipcduedateevent
from request_api.services.events.extension import extensionevent
from request_api.services.events.cfrfeeform import cfrfeeformevent
from request_api.services.events.attachment import attachmentevent
from request_api.services.events.payment import paymentevent
from request_api.services.events.email import emailevent
from request_api.services.events.section5pending import section5pendingevent
Expand Down Expand Up @@ -58,7 +59,7 @@ def posteventforaxisextension(self, ministryrequestid, extensionids, userid, use
current_app.logger.error("FOI Notification failed for event for extension= %s" % (extensionid))
except BusinessException as exception:
self.__logbusinessexception(exception)

def postreminderevent(self):
try:
cfreventresponse = cfrdateevent().createdueevent()
Expand Down Expand Up @@ -140,5 +141,14 @@ def __posteventforsanctioncfrfeeform(self, ministryrequestid, userid, username):
cfrfeeeventresponse = cfrfeeformevent().createstatetransitionevent(ministryrequestid, userid, username)
if cfrfeeeventresponse.success == False:
current_app.logger.error("FOI Notification failed for event for CFRFEEFORM= %s" % (ministryrequestid))
except BusinessException as exception:
self.__logbusinessexception(exception)

def attachmenteventservice(self, ministryrequestid, document, userid, requesttype):
try:
attachmenteventresponse = attachmentevent().createattachmentevent(ministryrequestid, userid, document, requesttype)
if attachmenteventresponse.success == False:
current_app.logger.error("FOI Notification failed for event for attachment= %s" % (document['category']))
return attachmenteventresponse
except BusinessException as exception:
self.__logbusinessexception(exception)
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ def getnotificationusers(self, notificationtype, requesttype, userid, foirequest
elif 'Group Members' in notificationtype:
_users = self.__getgroupmembers(foirequest["assignedministrygroup"])
elif 'Watcher' in notificationtype:
_users = self.__getwatchers(notificationtype, foirequest, requesttype, requestjson)
_users = self.__getwatchers(notificationtype, foirequest, requesttype, requestjson)
elif 'Attachment Upload Event' in notificationtype:
_users = self.__getgroupmembers('scanningteam') + self.__getassignees(foirequest, requesttype, notificationtype) + self.__getwatchers(notificationtype, foirequest, requesttype, requestjson)
else:
_users = self.__getassignees(foirequest, requesttype, notificationtype) + self.__getwatchers(notificationtype, foirequest, requesttype)
for user in _users:
Expand Down Expand Up @@ -129,5 +131,4 @@ def __getgroupmembers(self,groupid):
for user in usergroupfromkeycloak[0].get("members"):
notificationusers.append({"userid":user["username"], "usertype":notificationusertypelabel})
return notificationusers
return []

return []
Loading