Пример #1
0
def compile_subscriptions(node, event_type, event=None, level=0):
    """Recurse through node and parents for subscriptions.

    :param node: current node
    :param event_type: Generally node_subscriptions_available
    :param event: Particular event such a file_updated that has specific file subs
    :param level: How deep the recursion is
    :return: a dict of notification types with lists of users.
    """
    subscriptions = check_node(node, event_type)
    if event:
        subscriptions = check_node(
            node, event)  # Gets particular event subscriptions
        parent_subscriptions = compile_subscriptions(
            node, event_type, level=level + 1)  # get node and parent subs
    elif node.parent_id:
        parent_subscriptions = \
            compile_subscriptions(AbstractNode.load(node.parent_id), event_type, level=level + 1)
    else:
        parent_subscriptions = check_node(None, event_type)
    for notification_type in parent_subscriptions:
        p_sub_n = parent_subscriptions[notification_type]
        p_sub_n.extend(subscriptions[notification_type])
        for nt in subscriptions:
            if notification_type != nt:
                p_sub_n = list(set(p_sub_n).difference(set(subscriptions[nt])))
        if level == 0:
            p_sub_n, removed = utils.separate_users(node, p_sub_n)
        parent_subscriptions[notification_type] = p_sub_n
    return parent_subscriptions
Пример #2
0
def subscriptions_node_permissions(node, warn_subscription, remove_subscription):
    for notification in constants.NOTIFICATION_TYPES:
        subbed, removed = utils.separate_users(node, warn_subscription[notification])
        warn_subscription[notification] = subbed
        remove_subscription[notification].extend(removed)
        remove_subscription[notification] = list(set(remove_subscription[notification]))
    return warn_subscription, remove_subscription
Пример #3
0
def compile_subscriptions(node, event_type, event=None, level=0):
    """Recurse through node and parents for subscriptions.

    :param node: current node
    :param event_type: Generally node_subscriptions_available
    :param event: Particular event such a file_updated that has specific file subs
    :param level: How deep the recursion is
    :return: a dict of notification types with lists of users.
    """
    subscriptions = check_node(node, event_type)
    if event:
        subscriptions = check_node(node, event)  # Gets particular event subscriptions
        parent_subscriptions = compile_subscriptions(node, event_type, level=level + 1)  # get node and parent subs
    elif getattr(node, 'parent_id', False):
        parent_subscriptions = \
            compile_subscriptions(AbstractNode.load(node.parent_id), event_type, level=level + 1)
    else:
        parent_subscriptions = check_node(None, event_type)
    for notification_type in parent_subscriptions:
        p_sub_n = parent_subscriptions[notification_type]
        p_sub_n.extend(subscriptions[notification_type])
        for nt in subscriptions:
            if notification_type != nt:
                p_sub_n = list(set(p_sub_n).difference(set(subscriptions[nt])))
        if level == 0:
            p_sub_n, removed = utils.separate_users(node, p_sub_n)
        parent_subscriptions[notification_type] = p_sub_n
    return parent_subscriptions
Пример #4
0
def subscriptions_node_permissions(node, warn_subscription,
                                   remove_subscription):
    for notification in constants.NOTIFICATION_TYPES:
        subbed, removed = utils.separate_users(node,
                                               warn_subscription[notification])
        warn_subscription[notification] = subbed
        remove_subscription[notification].extend(removed)
        remove_subscription[notification] = list(
            set(remove_subscription[notification]))
    return warn_subscription, remove_subscription