comparison roundup/hyperdb.py @ 5261:53a853c06e9a

Fixed quiet history filter for linked items. Test for same fixed. The original test didn't cover the case where the linked item in the history/journal wasn't the same type as the item on which the history was generated. This now pulls the history on a user who has been linked to the nosy field of an issue.
author John Rouillard <rouilj@ieee.org>
date Mon, 28 Aug 2017 21:51:12 -0400
parents 29949f41cefb
children 20084e2b48c3
comparison
equal deleted inserted replaced
5260:29949f41cefb 5261:53a853c06e9a
1020 raise ValueError('Journalling is disabled for this class') 1020 raise ValueError('Journalling is disabled for this class')
1021 1021
1022 perm = self.db.security.hasPermission 1022 perm = self.db.security.hasPermission
1023 journal = [] 1023 journal = []
1024 1024
1025 debug_logging = logger.isEnabledFor(logging.DEBUG)
1026
1027 uid=self.db.getuid() # id of the person requesting the history 1025 uid=self.db.getuid() # id of the person requesting the history
1028 1026
1029 for j in self.db.getjournal(self.classname, nodeid): 1027 for j in self.db.getjournal(self.classname, nodeid):
1030 # hide/remove journal entry if: 1028 # hide/remove journal entry if:
1031 # property is quiet 1029 # property is quiet
1032 # property is not (viewable or editable) 1030 # property is not (viewable or editable)
1033 id, evt_date, user, action, args = j 1031 id, evt_date, user, action, args = j
1034 if debug_logging: 1032 if logger.isEnabledFor(logging.DEBUG):
1035 j_repr = "%s"%(j,) 1033 j_repr = "%s"%(j,)
1036 else: 1034 else:
1037 j_repr='' 1035 j_repr=''
1038 if args and type(args) == type({}): 1036 if args and type(args) == type({}):
1039 for key in args.keys(): 1037 for key in args.keys():
1059 " all props removed in: %s", 1057 " all props removed in: %s",
1060 self.classname, nodeid, j_repr) 1058 self.classname, nodeid, j_repr)
1061 continue 1059 continue
1062 journal.append(j) 1060 journal.append(j)
1063 elif action in ['link', 'unlink' ] and type(args) == type(()): 1061 elif action in ['link', 'unlink' ] and type(args) == type(()):
1064 # hide/remove journal entry if: 1062 # definitions:
1065 # link property (key) is quiet 1063 # myself - object whose history is being filtered
1066 # link property is not (viewable or editable) 1064 # linkee - object/class whose property is changing to
1067 # id/object (linkcl, linkid) that is linked/unlinked is not 1065 # include/remove myself
1068 # (viewable or editable) 1066 # link property - property of the linkee class that is changing
1067 #
1068 # Remove the history item if
1069 # linkee.link property (key) is quiet
1070 # linkee class.link property is not (viewable or editable)
1071 # to user
1072 # [ should linkee object.link property is not
1073 # (viewable or editable) to user be included?? ]
1074 # linkee object (linkcl, linkid) is not
1075 # (viewable or editable) to user
1069 if len(args) == 3: 1076 if len(args) == 3:
1070 '''
1071 # e.g. for issue3 blockedby adds link to issue5 with: 1077 # e.g. for issue3 blockedby adds link to issue5 with:
1072 # j = id, evt_date, user, action, args 1078 # j = id, evt_date, user, action, args
1073 # 3|20170528045201.484|5|link|('issue', '5', 'blockedby') 1079 # 3|20170528045201.484|5|link|('issue', '5', 'blockedby')
1074 linkcl, linkid, key = args 1080 linkcl, linkid, key = args
1075 cls = self.db.getclass(linkcl) 1081 cls = self.db.getclass(linkcl)
1076 # is the updated property quiet? 1082 # is the updated property quiet?
1077 if skipquiet and self.properties[key].quiet: 1083 if skipquiet and cls.properties[key].quiet:
1078 logger.debug("skipping quiet property" 1084 logger.debug("skipping quiet property: "
1079 " %s::%s in %s", 1085 "%s %sed %s%s",
1080 self.classname, key, j_repr) 1086 j_repr, action, self.classname, nodeid)
1081 continue 1087 continue
1082 # property check on item we want history for 1088 # can user view the property in linkee class
1083 if enforceperm and not (perm("View", 1089 if enforceperm and not (perm("View",
1084 uid, 1090 uid,
1085 self.classname, 1091 linkcl,
1086 property=key) or perm("Edit", 1092 property=key) or perm("Edit",
1087 uid, 1093 uid,
1088 self.classname, 1094 linkcl,
1089 property=key)): 1095 property=key)):
1090 logger.debug("skipping unaccessible property %s::%s seen by user%s in %s", 1096 logger.debug("skipping unaccessible property: "
1091 self.classname, key, uid, j_repr) 1097 "%s with uid %s %sed %s%s",
1098 j_repr, uid, action,
1099 self.classname, nodeid)
1092 continue 1100 continue
1093 # check on object linked 1101 # check access to linkee object
1094 if enforceperm and not (perm("View", 1102 if enforceperm and not (perm("View",
1095 uid, 1103 uid,
1096 cls.classname, 1104 cls.classname,
1097 itemid=linkid) or perm("Edit", 1105 itemid=linkid) or perm("Edit",
1098 uid, 1106 uid,
1099 cls.classname, 1107 cls.classname,
1100 itemid=linkid)): 1108 itemid=linkid)):
1101 logger.debug("skipping unaccessible target %s%s for user%s in %s", 1109 logger.debug("skipping unaccessible object: "
1102 cls.classname, linkid, uid, j_repr) 1110 "%s uid %s %sed %s%s",
1111 j_repr, uid, action,
1112 self.classname, nodeid)
1103 continue 1113 continue
1104 '''
1105 journal.append(j) 1114 journal.append(j)
1106 else: 1115 else:
1107 logger.error("Invalid %s journal entry for %s%s: %s", 1116 logger.error("Invalid %s journal entry for %s%s: %s",
1108 action, self.classname, nodeid, j) 1117 action, self.classname, nodeid, j)
1109 elif action in ['create', 'retired', 'restored']: 1118 elif action in ['create', 'retired', 'restored']:

Roundup Issue Tracker: http://roundup-tracker.org/