def users_to_remove(source_event, source_node, new_node):
 NotificationSubscription = apps.get_model('osf.NotificationSubscription')
 removed_users = {key: [] for key in constants.NOTIFICATION_TYPES}
 if (source_node == new_node):
  return removed_users
 old_sub = NotificationSubscription.load(to_subscription_key(source_node._id, source_event))
 old_node_sub = NotificationSubscription.load(to_subscription_key(source_node._id, '_'.join(source_event.split('_')[(-2):])))
 if ((not old_sub) and (not old_node_sub)):
  return removed_users
 for notification_type in constants.NOTIFICATION_TYPES:
  users = (list(getattr(old_sub, notification_type).values_list('guids___id', flat=True)) + list(getattr(old_node_sub, notification_type).values_list('guids___id', flat=True)))
  (subbed, removed_users[notification_type]) = separate_users(new_node, users)
 return removed_users

def users_to_remove ( source_event , source_node , new_node ) : NotificationSubscription = apps . get_model ( 'osf.NotificationSubscription' ) removed_users = { key : [ ] for key in constants . NOTIFICATION_TYPES } if ( source_node == new_node ) : return removed_users old_sub = NotificationSubscription . load ( to_subscription_key ( source_node . _id , source_event ) ) old_node_sub = NotificationSubscription . load ( to_subscription_key ( source_node . _id , '_' . join ( source_event . split ( '_' ) [ ( - 2 ) : ] ) ) ) if ( ( not old_sub ) and ( not old_node_sub ) ) : return removed_users for notification_type in constants . NOTIFICATION_TYPES : users = ( list ( getattr ( old_sub , notification_type ) . values_list ( 'guids___id' , flat = True ) ) + list ( getattr ( old_node_sub , notification_type ) . values_list ( 'guids___id' , flat = True ) ) ) ( subbed , removed_users [ notification_type ] ) = separate_users ( new_node , users ) return removed_users
find users that do not have permissions on new_node .