def move_subscription(remove_users, source_event, source_node, new_event, new_node):
 NotificationSubscription = apps.get_model('osf.NotificationSubscription')
 OSFUser = apps.get_model('osf.OSFUser')
 if (source_node == new_node):
  return
 old_sub = NotificationSubscription.load(to_subscription_key(source_node._id, source_event))
 if (not old_sub):
  return
 elif old_sub:
  old_sub._id = to_subscription_key(new_node._id, new_event)
  old_sub.event_name = new_event
  old_sub.owner = new_node
 new_sub = old_sub
 new_sub.save()
 for notification_type in constants.NOTIFICATION_TYPES:
  if new_sub:
   for user_id in remove_users[notification_type]:
    related_manager = getattr(new_sub, notification_type, None)
    subscriptions = (related_manager.all() if related_manager else [])
    if (user_id in subscriptions):
     user = OSFUser.load(user_id)
     new_sub.remove_user_from_subscription(user)

def move_subscription ( remove_users , source_event , source_node , new_event , new_node ) : NotificationSubscription = apps . get_model ( 'osf.NotificationSubscription' ) OSFUser = apps . get_model ( 'osf.OSFUser' ) if ( source_node == new_node ) : return old_sub = NotificationSubscription . load ( to_subscription_key ( source_node . _id , source_event ) ) if ( not old_sub ) : return elif old_sub : old_sub . _id = to_subscription_key ( new_node . _id , new_event ) old_sub . event_name = new_event old_sub . owner = new_node new_sub = old_sub new_sub . save ( ) for notification_type in constants . NOTIFICATION_TYPES : if new_sub : for user_id in remove_users [ notification_type ] : related_manager = getattr ( new_sub , notification_type , None ) subscriptions = ( related_manager . all ( ) if related_manager else [ ] ) if ( user_id in subscriptions ) : user = OSFUser . load ( user_id ) new_sub . remove_user_from_subscription ( user )
moves subscription from old_node to new_node .