Skip to content

Commit

Permalink
Merge pull request #4981 from bcgov/test-marshal-DV-4707-1
Browse files Browse the repository at this point in the history
groupmember notification fix
  • Loading branch information
divyav-aot authored Jan 9, 2024
2 parents efa8b27 + 8545646 commit 4054e4e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def getnotificationtypelabel(self, notificationtype):
if notificationtype_format in notificationtypes_cache:
return notificationtypes_cache[notificationtype_format]['notificationtypelabel']
else:
print("Notification type not found in cache. Fetching from DB", notificationtype)
print("Notification type not found in json. Fetching from DB", notificationtype)
id = NotificationType().getnotificationtypeid(notificationtype)
if id is not None:
return id['notificationtypelabel']
Expand All @@ -44,7 +44,7 @@ def getnotificationusertypelabel(self, notificationusertype):
if notificationusertype_format in notificationusertypes_cache:
return notificationusertypes_cache[notificationusertype_format]['notificationusertypelabel']
else:
print("Notification user type not found in cache. Fetching from DB", notificationusertype)
print("Notification user type not found in json. Fetching from DB", notificationusertype)
id = NotificationUserType().getnotificationusertypesid(notificationusertype)
if id is not None:
return id['notificationusertypelabel']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ def __getwatchers(self, notificationtype, foirequest, requesttype, requestjson=N

def __getassignees(self, foirequest, requesttype, notificationtype, requestjson=None):
notificationusers = []
notificationtypelabel = notificationconfig().getnotificationusertypelabel("Assignee")
notificationusertypelabel = notificationconfig().getnotificationusertypelabel("Assignee")
if notificationtype == 'User Assignment Removal':
notificationusers.append({"userid": requestjson['userid'], "usertype":notificationtypelabel})
notificationusers.append({"userid": requestjson['userid'], "usertype":notificationusertypelabel})
else:
if requesttype == "ministryrequest" and foirequest["assignedministryperson"] is not None and (notificationtype == 'Ministry Assignment' or 'Assignment' not in notificationtype):
notificationusers.append({"userid":foirequest["assignedministryperson"], "usertype":notificationtypelabel})
notificationusers.append({"userid":foirequest["assignedministryperson"], "usertype":notificationusertypelabel})
if self.__isministryonly(notificationtype) == False and foirequest["assignedto"] is not None and foirequest["assignedto"] != '' and (notificationtype == 'IAO Assignment' or 'Assignment' not in notificationtype):
notificationusers.append({"userid":foirequest["assignedto"], "usertype":notificationtypelabel})
notificationusers.append({"userid":foirequest["assignedto"], "usertype":notificationusertypelabel})
return notificationusers

def __isministryonly(self, notificationtype):
Expand Down Expand Up @@ -123,11 +123,11 @@ def __preparetaggeduser(self, data):

def __getgroupmembers(self,groupid):
notificationusers = []
notificationtypelabel = notificationconfig().getnotificationtypelabel("Group Members")
notificationusertypelabel = notificationconfig().getnotificationusertypelabel("Group Members")
usergroupfromkeycloak= KeycloakAdminService().getmembersbygroupname(groupid)
if usergroupfromkeycloak is not None and len(usergroupfromkeycloak) > 0:
for user in usergroupfromkeycloak[0].get("members"):
notificationusers.append({"userid":user["username"], "usertype":notificationtypelabel})
notificationusers.append({"userid":user["username"], "usertype":notificationusertypelabel})
return notificationusers
return []

Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,11 @@ def __dismissnotificationbyuser(self, userid):
return DefaultMethodResult(False,'Unable to delete the notifications',userid)

def __dismissnotificationbytype(self, userid, type):
typeid = notificationconfig().getnotificationusertypelabel(type)
requestnotificationids = self.__getdismissparentidsbyuserandtype("ministryrequest", userid, typeid)
requestnotification = FOIRequestNotificationUser.dismissnotificationbyuserandtype(userid, typeid)
rawnotificationids = self.__getdismissparentidsbyuserandtype("rawrequest", userid, typeid)
rawnotification = FOIRawRequestNotificationUser.dismissnotificationbyuserandtype(userid, typeid)
notificationusertypelabel = notificationconfig().getnotificationusertypelabel(type)
requestnotificationids = self.__getdismissparentidsbyuserandtype("ministryrequest", userid, notificationusertypelabel)
requestnotification = FOIRequestNotificationUser.dismissnotificationbyuserandtype(userid, notificationusertypelabel)
rawnotificationids = self.__getdismissparentidsbyuserandtype("rawrequest", userid, notificationusertypelabel)
rawnotification = FOIRawRequestNotificationUser.dismissnotificationbyuserandtype(userid, notificationusertypelabel)
prequestnotification = FOIRequestNotification.dismissnotification(requestnotificationids)
prawnotification = FOIRawRequestNotification.dismissnotification(rawnotificationids)
if requestnotification.success == True and rawnotification.success == True and prequestnotification.success == True and prawnotification.success == True:
Expand Down Expand Up @@ -243,11 +243,11 @@ def __getdismissparentidsbyuser(self, requesttype, userid):
_notficationids = FOIRawRequestNotificationUser.getnotificationsbyuser(userid)
return self.__filterdismissparentids(_notficationids)

def __getdismissparentidsbyuserandtype(self, requesttype, userid, typeid):
def __getdismissparentidsbyuserandtype(self, requesttype, userid, notificationusertypelabel):
if requesttype == "ministryrequest":
_notficationids = FOIRequestNotificationUser.getnotificationsbyuserandtype(userid, typeid)
_notficationids = FOIRequestNotificationUser.getnotificationsbyuserandtype(userid, notificationusertypelabel)
else:
_notficationids = FOIRawRequestNotificationUser.getnotificationsbyuserandtype(userid, typeid)
_notficationids = FOIRawRequestNotificationUser.getnotificationsbyuserandtype(userid, notificationusertypelabel)
return self.__filterdismissparentids(_notficationids)

def __filterdismissparentids(self,_notficationids):
Expand Down

0 comments on commit 4054e4e

Please sign in to comment.