src/pyams_content/workflow/notify.py
changeset 529 5bd7496f674f
parent 152 363efe154011
child 1429 9b93fdd5ba30
equal deleted inserted replaced
528:15f595c8c4b0 529:5bd7496f674f
    59 
    59 
    60     def get_target(self):
    60     def get_target(self):
    61         notified_roles = self.context.user_data['transition'].user_data['notify_roles']
    61         notified_roles = self.context.user_data['transition'].user_data['notify_roles']
    62         if '*' in notified_roles:
    62         if '*' in notified_roles:
    63             return {}
    63             return {}
       
    64         notification_source = self.context.context
    64         principals = set()
    65         principals = set()
    65         for context in lineage(self.context.context):
    66         for context in lineage(notification_source):
    66             protection = IProtectedObject(context, None)
    67             protection = IProtectedObject(context, None)
    67             if protection is not None:
    68             if protection is not None:
    68                 for role_id in notified_roles:
    69                 for role_id in notified_roles:
    69                     for principal in protection.get_principals(role_id):
    70                     for principal in protection.get_principals(role_id):
    70                         if role_id == MANAGER_ROLE:
    71                         if role_id == MANAGER_ROLE:
    71                             if principal in self.context.context.managers:
    72                             if principal in notification_source.managers:
    72                                 principals.add(principal)
    73                                 principals.add(principal)
    73                             else:
    74                             else:
    74                                 restrictions = IManagerRestrictions(self.context.context, None)
    75                                 restrictions = IManagerRestrictions(notification_source, None)
    75                                 if restrictions is not None:
    76                                 if restrictions is not None:
    76                                     principal_restrictions = restrictions.get_restrictions(principal)
    77                                     principal_restrictions = restrictions.get_restrictions(principal)
    77                                     if principal_restrictions.check_access(self.context.context,
    78                                     if principal_restrictions.check_access(notification_source,
    78                                                                            MANAGE_CONTENT_PERMISSION):
    79                                                                            MANAGE_CONTENT_PERMISSION):
    79                                         principals.add(principal)
    80                                         principals.add(principal)
    80                         else:
    81                         else:
    81                             principals.add(principal)
    82                             principals.add(principal)
    82         source_id = self.context.source['id']
    83         source_id = self.context.source['id']