-
Notifications
You must be signed in to change notification settings - Fork 3
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
Dev marshal shiva 2965 rrt #5152
Changes from 2 commits
3cb5d86
038c1b6
db5f194
4f7bd02
233720c
8a93e29
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
from request_api.models.FOIApplicantCorrespondenceAttachments import FOIApplicantCorrespondenceAttachment | ||
from request_api.services.eventservice import eventservice | ||
from request_api.utils.enums import RequestType | ||
from request_api.services.events.attachment import attachmentevent | ||
import logging | ||
|
||
import json | ||
|
@@ -92,14 +93,6 @@ def copyrequestdocuments(self, ministryrequestid, documents, userid): | |
|
||
def createministryrequestdocument(self, ministryrequestid, documentschema, userid): | ||
version = self.__getversionforrequest(ministryrequestid, "ministryrequest") | ||
for document in documentschema['documents']: | ||
if 'rrt' in document['category']: | ||
#Create notification event for RRT document | ||
message = f'RRT Uploaded on FOI Request {ministryrequestid}' | ||
eventservice().attachmentevent(ministryrequestid, document, userid, "add", message) | ||
#if 'rrt' in documentschema['documents']['category']: | ||
#Create notification event for RRT document | ||
# eventservice().posteventforextension(ministryrequestid, '', userid, '' , "add") | ||
return FOIMinistryRequestDocument.createdocuments(ministryrequestid, version, documentschema['documents'], userid) | ||
|
||
def createrawrequestdocument(self, requestid, documentschema, userid): | ||
|
@@ -145,6 +138,10 @@ def uploadpersonaldocuments(self, requestid, attachments): | |
attachmentlist.append(attachmentresponse) | ||
|
||
documentschema = CreateDocumentSchema().load({'documents': attachmentlist}) | ||
for document in documentschema['documents']: | ||
# Add attachment event here as we need to pass in the document | ||
# to the event service to identify if the document is an RRT document. | ||
attachmenteventresponse = attachmentevent().createattachmentevent(requestid, userid, document) | ||
return self.createrequestdocument(requestid, documentschema, None, "rawrequest") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As discussed, attachmentevent call should be at resource level not at the service level. |
||
|
||
def getattachments(self, requestid, requesttype, category): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,11 +13,17 @@ class attachmentevent(): | |
""" FOI Attachment Event management service | ||
|
||
""" | ||
def createattachmentevent(self, ministryrequestid, message, userid, event): | ||
def createattachmentevent(self, ministryrequestid, userid, document): | ||
try: | ||
notificationtype = NotificationType().getnotificationtypeid(self.__notificationtype()) | ||
self.__createnotification(message, ministryrequestid, notificationtype, userid) | ||
return DefaultMethodResult(True, message, '') | ||
if 'rrt' in document['category']: | ||
#Create notification event for RRT document | ||
print(f"RRT Uploaded on FOI Request {ministryrequestid}") | ||
#message = f'RRT Uploaded on FOI Request {ministryrequestid}' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comment |
||
message = self.notificationmessage('RRT', ministryrequestid) | ||
notificationtype = NotificationType().getnotificationtypeid(self.__notificationtype()) | ||
self.__createnotification(message, ministryrequestid, notificationtype, userid) | ||
self.__createcomment(ministryrequestid, message) | ||
return DefaultMethodResult(True, message, '') | ||
except BusinessException as exception: | ||
current_app.logger.error("%s,%s" % ('Attachment upload notification error', exception.message)) | ||
return DefaultMethodResult(False,'Attachemnt notifications failed') | ||
|
@@ -26,8 +32,22 @@ def __createnotification(self, message, requestid, notificationtype, userid): | |
if message is not None: | ||
return notificationservice().createnotification({"message" : message}, requestid, "ministryrequest", notificationtype, userid) | ||
|
||
def notificationmessage(self, type): | ||
return f"{type} Attachment Uploaded" | ||
def __createcomment(self, ministryrequestid, message): | ||
if message is not None: | ||
_comment = self.__preparecomment(ministryrequestid, message) | ||
return commentservice().createcomments(_comment, self.__defaultuserid(), 2) | ||
|
||
def __preparecomment(self, ministryrequestid, message): | ||
_comment = dict() | ||
_comment['comment'] = message | ||
_comment['ministryrequestid'] = ministryrequestid | ||
_comment['version'] = None | ||
_comment['taggedusers'] = None | ||
_comment['parentcommentid'] = None | ||
return _comment | ||
antsand marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def notificationmessage(self, type, ministryrequestid): | ||
return f"{type} Attachment Uploaded on FOI Request {ministryrequestid}" | ||
|
||
def __notificationtype(self): | ||
return "Attachment Upload Event" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,9 @@ class notificationuser: | |
|
||
def getnotificationusers(self, notificationtype, requesttype, userid, foirequest, requestjson=None): | ||
notificationusers = [] | ||
print("notificationtype", notificationtype) | ||
print("requesttype", requesttype) | ||
print("foirequest", foirequest) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comments |
||
if 'User Assignment Removal' == notificationtype: | ||
_users = self.__getassignees(foirequest, requesttype, notificationtype, requestjson) | ||
elif 'Assignment' in notificationtype: | ||
|
@@ -26,7 +29,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.__getscanningteam() | ||
else: | ||
_users = self.__getassignees(foirequest, requesttype, notificationtype) + self.__getwatchers(notificationtype, foirequest, requesttype) | ||
for user in _users: | ||
|
@@ -130,4 +135,14 @@ def __getgroupmembers(self,groupid): | |
notificationusers.append({"userid":user["username"], "usertype":notificationusertypelabel}) | ||
return notificationusers | ||
return [] | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please make the necessary changes mentioned in accordance with callstack. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @antsand , use __getgroupmembers method. |
||
def __getscanningteam(self): | ||
notificationusers = [] | ||
print("Sending notification to scanning team") | ||
notificationusertypelabel = notificationconfig().getnotificationusertypelabel("Group Members") | ||
usergroupfromkeycloak= KeycloakAdminService().getmembersbygroupname("scanningteam") | ||
if usergroupfromkeycloak is not None and len(usergroupfromkeycloak) > 0: | ||
for user in usergroupfromkeycloak[0].get("members"): | ||
notificationusers.append({"userid":user["username"], "usertype":notificationusertypelabel}) | ||
return notificationusers | ||
return [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove unnecessary import