def create_graph_data_node_for_structure_node(node, slot=None, path=None, slot_path=None): if slot_path: slot = get_node_for_path(slot_path) if not path: path = get_good_path_for_structure_node(node, slot, slot_path) if slot: if not slot_path: slot_path = slot.get_a_path() origin_group = [slot_path + '.' + str(n.get_index(slot)) for n in node.sources.filter(parents__in=[slot]).all()] origin_group += [n.get_a_path() for n in node.sources.exclude(parents__in=[slot]).all()] else: origin_group = [n.get_a_path() for n in node.sources.all()] graph_data_node = dict( path=path, authorGroup=[create_user_info(a) for a in node.text.authors.all()], follows=node.votes.count(), spamFlags=node.spam_flags.count(), unFollows=node.get_unfollows(), newFollows=node.get_newfollows(), title=node.title, originGroup=[o.rstrip('/') for o in origin_group] ) return graph_data_node
def create_graph_data_node_for_structure_node(node, slot=None, path=None, slot_path=None): if slot_path: slot = get_node_for_path(slot_path) if not path: path = get_good_path_for_structure_node(node, slot, slot_path) if slot: if not slot_path: slot_path = slot.get_a_path() origin_group = [ slot_path + '.' + str(n.get_index(slot)) for n in node.sources.filter(parents__in=[slot]).all() ] origin_group += [ n.get_a_path() for n in node.sources.exclude(parents__in=[slot]).all() ] else: origin_group = [n.get_a_path() for n in node.sources.all()] graph_data_node = dict( path=path, authorGroup=[create_user_info(a) for a in node.text.authors.all()], follows=node.votes.count(), spamFlags=node.spam_flags.count(), unFollows=node.get_unfollows(), newFollows=node.get_newfollows(), title=node.title, originGroup=[o.rstrip('/') for o in origin_group]) return graph_data_node
def create_paragraph_list_for_node(node, path, depth=1): paragraphs = [create_paragraph_for_node(node, path, depth=depth)] for slot in backend.get_ordered_children_for(node): favorite = slot.favorite slot_path = path + "/" + slot.title fav_path = get_good_path_for_structure_node(favorite, slot, slot_path) paragraphs += create_paragraph_list_for_node(favorite, fav_path, depth=depth + 1) return paragraphs
def store_structure_node(path, wiki_text, author): slot_path = path.rsplit('.', 1)[0] slot = get_node_for_path(slot_path) structure = backend.parse(wiki_text, None) structure_node = backend.create_structure_from_structure_node_schema( structure, slot, [author]) # add auto follow create_vote(author, [structure_node]) return structure_node, get_good_path_for_structure_node(structure_node, slot, slot_path)
def store_structure_node(path, wiki_text, author, argument=None): slot_path = path.rsplit('.', 1)[0] slot = get_node_for_path(slot_path) structure_schema = backend.parse(wiki_text, None) clone_candidates = None if argument: clone_candidates = slot.children.all() structure_node = backend.create_structure_from_structure_node_schema( structure_schema, slot, author, clone_candidates) # add auto follow create_vote(author, [structure_node]) return structure_node, get_good_path_for_structure_node(structure_node, slot, slot_path)
def store_derivate(path, arg_text, arg_type, derivate_wiki_text, author): node = get_node_for_path(path) arg_title, arg_text = backend.split_title_from_text(arg_text) slot_path = path.rsplit('.', 1)[0] slot = get_node_for_path(slot_path) structure_schema = backend.parse(derivate_wiki_text, None) score_tree = build_score_tree(node, structure_schema) new_node, path_couples = backend.create_derivate_from_structure_node_schema( structure_schema, slot, author, node, score_tree, arg_type, arg_title, arg_text) new_path = get_good_path_for_structure_node(new_node, slot, slot_path) return new_path, path_couples