def setUp(self):
        self.hans = create_user('hans')
        self.hugo = create_user('hugo')

        self.root = get_root_node()
        self.slot1 = create_slot('Wahlprogramm')
        self.root.append_child(self.slot1)
        self.structureNode1 = create_structureNode('LangerWahlprogrammTitel',
                                                   authors=[self.hans])
        self.slot1.append_child(self.structureNode1)
        self.slot11 = create_slot('Transparenz')
        self.structureNode1.append_child(self.slot11)
        self.textnode11 = create_textNode('Traaaansparenz', authors=[self.hans])
        self.slot11.append_child(self.textnode11)
        self.slot12 = create_slot('Bildung')
        self.structureNode1.append_child(self.slot12)
        self.textnode12 = create_textNode('Biiildung', authors=[self.hans])
        self.slot12.append_child(self.textnode12)
        self.slot13 = create_slot('Datenschutz')
        self.structureNode1.append_child(self.slot13)
        self.textnode13 = create_textNode('Daaatenschutz', authors=[self.hans])
        self.slot13.append_child(self.textnode13)

        self.arguments = []
        for i in range(1, 25):
            arg = create_argument(self.textnode11, 'p', "Argument" + str(i),
                                  "Text of argument no. " + str(i), [self.hugo, self.hans])
            create_vote(self.hugo, [arg])
            if i % 2 == 1:
                create_vote(self.hans, [arg])
                create_spam_flag(self.hugo, [arg])
            self.arguments.append(arg)
Example #2
0
def generate_refinement(origin, proposal, argument, slot, user):
    derivate = create_structureNode(long_title=proposal['heading'],
                                    text=proposal['text'],
                                    authors=[user])
    slot.append_child(derivate)

    create_vote(user, [derivate])  # auto-follow

    for child in proposal['subsections']:
        if not re.match(SHORT_TITLE, child['shorttitle']):
            raise InvalidShortTitle('Invalid short-title: "{}"'.format(
                child['shorttitle']))
        if 'text' in child:
            if origin.children.filter(title=child['shorttitle']).count() > 0:
                raise InvalidShortTitle(
                    'ShortTitle {} is already taken'.format(
                        child['shorttitle']))
            child_slot = create_slot(child['shorttitle'])
            derivate.append_child(child_slot)
            generate_proposal_node_with_subsections(child_slot, child, user)
        else:
            child_slots = origin.children.filter(title=child['shorttitle'])
            if child_slots.count() == 0:
                raise InvalidShortTitle('Unknown short title {}'.format(
                    child['shorttitle']))
            derivate.append_child(child_slots[0])
    origin.add_derivate(derivate,
                        arg_type="con",
                        title=argument['heading'],
                        text=argument['text'],
                        authors=[user])
    return derivate
Example #3
0
 def test_get_newfollows_on_node_with_same_votes_than_source_returns_0(self):
     n = create_structureNode('Foo')
     n2 = create_structureNode('Foo2')
     n.add_derivate(n2)
     create_vote(self.hans, [n, n2])
     create_vote(self.hugo, [n, n2])
     self.assertEqual(n2.get_newfollows(), 0)
Example #4
0
def generate_refinement(origin, proposal, argument, slot, user):
    derivate = create_structureNode(
        long_title=proposal['heading'], text=proposal['text'], authors=[user])
    slot.append_child(derivate)

    create_vote(user, [derivate])  # auto-follow

    for child in proposal['subsections']:
        if not re.match(SHORT_TITLE, child['shorttitle']):
            raise InvalidShortTitle('Invalid short-title: "{}"'.
                                    format(child['shorttitle']))
        if 'text' in child:
            if origin.children.filter(title=child['shorttitle']).count() > 0:
                raise InvalidShortTitle('ShortTitle {} is already taken'.
                                        format(child['shorttitle']))
            child_slot = create_slot(child['shorttitle'])
            derivate.append_child(child_slot)
            generate_proposal_node_with_subsections(child_slot, child, user)
        else:
            child_slots = origin.children.filter(title=child['shorttitle'])
            if child_slots.count() == 0:
                raise InvalidShortTitle('Unknown short title {}'.
                                        format(child['shorttitle']))
            derivate.append_child(child_slots[0])
    origin.add_derivate(derivate,
                        arg_type="con",
                        title=argument['heading'],
                        text=argument['text'],
                        authors=[user])
    return derivate
Example #5
0
 def test_get_unfollows_with_an_unfollow_returns_1(self):
     n = create_structureNode('Foo')
     n2 = create_structureNode('Foo2')
     n.add_derivate(n2)
     create_vote(self.hans, [n])
     create_vote(self.hugo, [n, n2])
     self.assertEqual(n2.get_unfollows(), 1)
    def setUp(self):
        self.hans = create_user('hans')
        self.hugo = create_user('hugo')

        self.root = get_root_node()
        self.slot1 = create_slot('Wahlprogramm')
        self.root.append_child(self.slot1)
        self.structureNode1 = create_structureNode('LangerWahlprogrammTitel',
                                                   authors=[self.hans])
        self.slot1.append_child(self.structureNode1)
        self.slot11 = create_slot('Transparenz')
        self.structureNode1.append_child(self.slot11)
        self.textnode11 = create_textNode('Traaaansparenz',
                                          authors=[self.hans])
        self.slot11.append_child(self.textnode11)
        self.slot12 = create_slot('Bildung')
        self.structureNode1.append_child(self.slot12)
        self.textnode12 = create_textNode('Biiildung', authors=[self.hans])
        self.slot12.append_child(self.textnode12)
        self.slot13 = create_slot('Datenschutz')
        self.structureNode1.append_child(self.slot13)
        self.textnode13 = create_textNode('Daaatenschutz', authors=[self.hans])
        self.slot13.append_child(self.textnode13)

        self.arguments = []
        for i in range(1, 25):
            arg = create_argument(self.textnode11, 'p', "Argument" + str(i),
                                  "Text of argument no. " + str(i),
                                  [self.hugo, self.hans])
            create_vote(self.hugo, [arg])
            if i % 2 == 1:
                create_vote(self.hans, [arg])
                create_spam_flag(self.hugo, [arg])
            self.arguments.append(arg)
Example #7
0
 def test_get_newfollows_with_2_newfollows_returns_2(self):
     n = create_structureNode('Foo')
     n2 = create_structureNode('Foo2')
     n.add_derivate(n2)
     create_vote(self.hans, [n2])
     create_vote(self.hugo, [n2])
     self.assertEqual(n2.get_newfollows(), 2)
Example #8
0
    def test_load_microblogging_for_followed_nodes(self):
        create_nodes_for_path("foo.1")
        foo2 = create_nodes_for_path("foo.2")
        foo1bar1 = create_nodes_for_path("foo.1/bar.1")

        hugo = create_user("hugo")
        create_vote(hugo, [foo2])
        create_vote(hugo, [foo1bar1])

        posts = [
            create_post("posted at node", hugo, location='foo.2'),
            create_post("reference /foo.2", hugo, location=''),
            create_post("reference /foo.1/bar.1", hugo, location='foo.2')
        ]

        wrong_posts = [
            create_post("posted somewhere", hugo, location='foo.1'),
            create_post("reference wrong /foo.1", hugo, location=''),
            create_post("neither", hugo, location='')
        ]

        response = self.client.get(
            reverse('load_microblogging_for_followed_nodes',
                    kwargs={'name': 'hugo'}))
        res = json.loads(response.content)["loadMicrobloggingResponse"]

        response_id_list = [m["microblogID"] for m in res]
        for post in posts:
            self.assertIn(post.id, response_id_list)
        for post in wrong_posts:
            self.assertNotIn(post.id, response_id_list)
        self.assertEqual(len(res), 3)
Example #9
0
 def test_get_newfollows_does_count_votes_and_not_users(self):
     n = create_structureNode('Foo')
     n2 = create_structureNode('Foo2')
     n.add_derivate(n2)
     create_vote(self.hans, [n])
     create_vote(self.hans, [n2])
     self.assertEqual(n2.get_newfollows(), 1)
Example #10
0
    def setUp(self):
        self.hans = create_user('hans')
        self.hugo = create_user('hugo')

        self.root = get_root_node()
        self.slot1 = create_slot('Wahlprogramm')
        self.root.append_child(self.slot1)
        self.textnode1 = create_textNode('LangerWahlprogrammTitel',
                                         authors=[self.hans])
        self.slot1.append_child(self.textnode1)
        self.slot2 = create_slot('Grundsatzprogramm')
        self.root.append_child(self.slot2)
        self.textnode2 = create_textNode('LangerGrundsatzTitel',
                                         authors=[self.hugo])
        self.slot2.append_child(self.textnode2)
        self.slot3 = create_slot('Organisatorisches')
        self.root.append_child(self.slot3)
        self.textnode31 = create_textNode('Langweilig1', authors=[self.hans])
        self.textnode32 = create_textNode('Langweilig2', authors=[self.hugo])
        self.textnode33 = create_textNode('Langweilig3',
                                          authors=[self.hans, self.hugo])
        self.slot3.append_child(self.textnode31)
        self.slot3.append_child(self.textnode32)
        self.slot3.append_child(self.textnode33)
        create_vote(self.hans, [self.textnode33])
        self.top_slots = [self.slot1, self.slot2, self.slot3]
        self.short_titles = ['Wahlprogramm', 'Grundsatzprogramm',
                             'Organisatorisches']
        self.full_titles = ['LangerWahlprogrammTitel', 'LangerGrundsatzTitel',
                            'Langweilig3']
        self.authors = [[self.hans], [self.hugo], [self.hans, self.hugo]]
Example #11
0
    def setUp(self):
        self.hans = create_user('hans')
        self.hugo = create_user('hugo')

        self.root = get_root_node()
        self.slot1 = create_slot('Wahlprogramm')
        self.root.append_child(self.slot1)
        self.textnode1 = create_textNode('LangerWahlprogrammTitel',
                                         authors=[self.hans])
        self.slot1.append_child(self.textnode1)
        self.slot2 = create_slot('Grundsatzprogramm')
        self.root.append_child(self.slot2)
        self.textnode2 = create_textNode('LangerGrundsatzTitel',
                                         authors=[self.hugo])
        self.slot2.append_child(self.textnode2)
        self.slot3 = create_slot('Organisatorisches')
        self.root.append_child(self.slot3)
        self.textnode31 = create_textNode('Langweilig1', authors=[self.hans])
        self.textnode32 = create_textNode('Langweilig2', authors=[self.hugo])
        self.textnode33 = create_textNode('Langweilig3',
                                          authors=[self.hans, self.hugo])
        self.slot3.append_child(self.textnode31)
        self.slot3.append_child(self.textnode32)
        self.slot3.append_child(self.textnode33)
        create_vote(self.hans, [self.textnode33])
        self.top_slots = [self.slot1, self.slot2, self.slot3]
        self.short_titles = ['Wahlprogramm', 'Grundsatzprogramm',
                             'Organisatorisches']
        self.full_titles = ['LangerWahlprogrammTitel', 'LangerGrundsatzTitel',
                            'Langweilig3']
        self.authors = [[self.hans], [self.hugo], [self.hans, self.hugo]]
Example #12
0
    def test_load_microblogging_for_followed_nodes(self):
        create_nodes_for_path("foo.1")
        foo2 = create_nodes_for_path("foo.2")
        foo1bar1 = create_nodes_for_path("foo.1/bar.1")

        hugo = create_user("hugo")
        create_vote(hugo, [foo2])
        create_vote(hugo, [foo1bar1])

        posts = [create_post("posted at node", hugo, location='foo.2'),
                 create_post("reference /foo.2", hugo, location=''),
                 create_post("reference /foo.1/bar.1", hugo, location='foo.2')]

        wrong_posts = [create_post("posted somewhere", hugo, location='foo.1'),
                       create_post("reference wrong /foo.1", hugo, location=''),
                       create_post("neither", hugo, location='')]

        response = self.client.get(
            reverse('load_microblogging_for_followed_nodes',
                    kwargs={'name': 'hugo'}))
        res = json.loads(response.content)["loadMicrobloggingResponse"]

        response_id_list = [m["microblogID"] for m in res]
        for post in posts:
            self.assertIn(post.id, response_id_list)
        for post in wrong_posts:
            self.assertNotIn(post.id, response_id_list)
        self.assertEqual(len(res), 3)
Example #13
0
 def test_get_unfollows_counts_votes_from_multiple_sources_only_once(self):
     n1 = create_structureNode('Foo1')
     n2 = create_structureNode('Foo2')
     d = create_structureNode('Foo12')
     n1.add_derivate(d)
     n2.add_derivate(d)
     create_vote(self.hans, [n1, n2])
     self.assertEqual(d.get_unfollows(), 1)
Example #14
0
 def setUp(self):
     self.root = get_root_node()
     self.mustermann = create_user("Mustermann")
     self.slot = create_slot("Flopp")
     self.root.append_child(self.slot)
     self.text1 = create_textNode("Initial Text", "Dumdidum",
                                  [self.mustermann])
     self.slot.append_child(self.text1)
     create_vote(self.mustermann, [self.text1])
Example #15
0
def store_derivate(path, arg_text, arg_type, derivate_wiki_text, author):
    new_node, new_path = store_structure_node(path, derivate_wiki_text, author)
    node = get_node_for_path(path)
    arg_title, arg_text = backend.split_title_from_text(arg_text)
    arg = node.add_derivate(new_node, arg_type=arg_type,
                            title=arg_title,
                            text=arg_text, authors=[author])
    # add auto follow
    create_vote(author, [arg])
    return new_path
Example #16
0
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)
Example #17
0
def store_argument(path, arg_text, arg_type, author):
    node = get_node_for_path(path)
    title, arg_text = backend.split_title_from_text(arg_text)
    original_argument = create_argument(node, arg_type, title, arg_text,
                                        [author])
    # add auto follow
    create_vote(author, [original_argument])
    # copy argument for all derivates
    for d in node.traverse_derivates():
        new_argument = create_argument(d, arg_type, title, arg_text, [author])
        original_argument.add_derivate(new_argument)
    return path + "." + arg_type + "." + str(node.arguments.count())
Example #18
0
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)
Example #19
0
    def setUp(self):
        self.hans = create_user('hans')
        self.hugo = create_user('hugo')

        self.root = get_root_node()
        self.slot1 = create_slot('Wahlprogramm')
        self.root.append_child(self.slot1)
        self.textnode1 = create_textNode('LangerWahlprogrammTitel',
                                         authors=[self.hans])
        self.slot1.append_child(self.textnode1)
        self.slot2 = create_slot('Grundsatzprogramm')
        self.root.append_child(self.slot2)
        self.textnode2 = create_textNode('LangerGrundsatzTitel',
                                         authors=[self.hugo])
        self.slot2.append_child(self.textnode2)
        self.slot3 = create_slot('Organisatorisches')
        self.root.append_child(self.slot3)
        self.textnode31 = create_textNode('Langweilig1', authors=[self.hans])
        self.textnode32 = create_textNode('Langweilig2', authors=[self.hugo])
        self.textnode33 = create_textNode('Langweilig3',
                                          authors=[self.hans, self.hugo])
        self.slot3.append_child(self.textnode31)
        self.slot3.append_child(self.textnode32)
        self.textnode32d = create_textNode('Langweilig2 anders',
                                           authors=[self.hans, self.hugo])
        self.slot3.append_child(self.textnode32d)
        self.textnode32.add_derivate(self.textnode32d)
        create_vote(self.hans, [self.textnode32, self.textnode32d])
        self.slot3.append_child(self.textnode33)
        self.textnode33d = create_textNode('Langweilig3 anders',
                                           authors=[self.hans, self.hugo])
        self.slot3.append_child(self.textnode33d)
        self.textnode33.add_derivate(self.textnode33d)
        create_spam_flag(self.hugo, [self.textnode33d])
        create_vote(self.hans, [self.textnode33])
        self.nodes = [self.textnode31, self.textnode32, self.textnode32d,
                      self.textnode33, self.textnode33d]
        self.authorGroups = [[create_user_info(self.hans)],
                             [create_user_info(self.hugo)],
                             [create_user_info(self.hans),
                              create_user_info(self.hugo)],
                             [create_user_info(self.hans),
                              create_user_info(self.hugo)],
                             [create_user_info(self.hans),
                              create_user_info(self.hugo)]]
        self.follows = [0, 1, 1, 1, 0]
        self.spamFlags = [0, 0, 0, 0, 1]
        self.unFollows = [0, 0, 0, 0, 1]
        self.newFollows = [0, 1, 0, 1, 0]
        self.originGroups = [[], [], ['Organisatorisches.2'], [],
                             ['Organisatorisches.4']]
Example #20
0
    def setUp(self):
        self.hans = create_user('hans')
        self.hugo = create_user('hugo')

        self.root = get_root_node()
        self.slot1 = create_slot('Wahlprogramm')
        self.root.append_child(self.slot1)
        self.textnode1 = create_textNode('LangerWahlprogrammTitel',
                                         authors=[self.hans])
        self.slot1.append_child(self.textnode1)
        self.slot2 = create_slot('Grundsatzprogramm')
        self.root.append_child(self.slot2)
        self.textnode2 = create_textNode('LangerGrundsatzTitel',
                                         authors=[self.hugo])
        self.slot2.append_child(self.textnode2)
        self.slot3 = create_slot('Organisatorisches')
        self.root.append_child(self.slot3)
        self.textnode31 = create_textNode('Langweilig1', authors=[self.hans])
        self.textnode32 = create_textNode('Langweilig2', authors=[self.hugo])
        self.textnode33 = create_textNode('Langweilig3',
                                          authors=[self.hans, self.hugo])
        self.slot3.append_child(self.textnode31)
        self.slot3.append_child(self.textnode32)
        self.textnode32d = create_textNode('Langweilig2 anders',
                                           authors=[self.hans, self.hugo])
        self.slot3.append_child(self.textnode32d)
        self.textnode32.add_derivate(self.textnode32d)
        create_vote(self.hans, [self.textnode32, self.textnode32d])
        self.slot3.append_child(self.textnode33)
        self.textnode33d = create_textNode('Langweilig3 anders',
                                           authors=[self.hans, self.hugo])
        self.slot3.append_child(self.textnode33d)
        self.textnode33.add_derivate(self.textnode33d)
        create_spam_flag(self.hugo, [self.textnode33d])
        create_vote(self.hans, [self.textnode33])
        self.nodes = [self.textnode31, self.textnode32, self.textnode32d,
                      self.textnode33, self.textnode33d]
        self.authorGroups = [[create_user_info(self.hans)],
                             [create_user_info(self.hugo)],
                             [create_user_info(self.hans),
                              create_user_info(self.hugo)],
                             [create_user_info(self.hans),
                              create_user_info(self.hugo)],
                             [create_user_info(self.hans),
                              create_user_info(self.hugo)]]
        self.follows = [0, 1, 1, 1, 0]
        self.spamFlags = [0, 0, 0, 0, 1]
        self.unFollows = [0, 0, 0, 0, 1]
        self.newFollows = [0, 1, 0, 1, 0]
        self.originGroups = [[], [], ['Organisatorisches.2'], [],
                             ['Organisatorisches.4']]
Example #21
0
    def setUp(self):
        self.hans = create_user('hans')
        self.hugo = create_user('hugo')

        self.root = get_root_node()
        self.slot1 = create_slot('Wahlprogramm')
        self.root.append_child(self.slot1)
        self.structureNode1 = create_structureNode('LangerWahlprogrammTitel',
                                                   authors=[self.hans])
        self.slot1.append_child(self.structureNode1)
        self.slot11 = create_slot('Transparenz')
        self.structureNode1.append_child(self.slot11)
        self.textnode11 = create_textNode('Traaaansparenz',
                                          authors=[self.hans])
        self.slot11.append_child(self.textnode11)
        self.slot12 = create_slot('Bildung')
        self.structureNode1.append_child(self.slot12)
        self.textnode12 = create_textNode('Biiildung', authors=[self.hans])
        self.slot12.append_child(self.textnode12)
        self.slot13 = create_slot('Datenschutz')
        self.structureNode1.append_child(self.slot13)
        self.textnode13 = create_textNode('Daaatenschutz', authors=[self.hans])
        self.slot13.append_child(self.textnode13)

        self.slot2 = create_slot('Grundsatzprogramm')
        self.root.append_child(self.slot2)
        self.textnode2 = create_textNode('LangerGrundsatzTitel',
                                         authors=[self.hugo])
        self.slot2.append_child(self.textnode2)

        self.slot3 = create_slot('Organisatorisches')
        self.root.append_child(self.slot3)
        self.textnode31 = create_textNode('Langweilig1', authors=[self.hans])
        self.textnode32 = create_textNode('Langweilig2', authors=[self.hugo])
        self.textnode33 = create_textNode('Langweilig3',
                                          authors=[self.hans, self.hugo])
        self.slot3.append_child(self.textnode31)
        self.slot3.append_child(self.textnode32)
        self.slot3.append_child(self.textnode33)
        create_vote(self.hans, [self.textnode33])

        self.top_slots = [self.slot1, self.slot2, self.slot3]
        self.child_slots = [self.slot11, self.slot12, self.slot13]
        self.short_titles = [
            'Wahlprogramm', 'Grundsatzprogramm', 'Organisatorisches'
        ]
        self.full_titles = [
            'LangerWahlprogrammTitel', 'LangerGrundsatzTitel', 'Langweilig3'
        ]
        self.authors = [[self.hans], [self.hugo], [self.hans, self.hugo]]
Example #22
0
    def test_add_derivate_creates_transitive_votes(self):
        n = create_structureNode("Source", authors=[self.hans])
        self.foo.append_child(n)
        v1 = create_vote(self.hans, [n])
        v2 = create_vote(self.hugo, [n])
        d = create_structureNode("Derivate", authors=[self.hans])
        self.foo.append_child(d)
        n.add_derivate(d, arg_type='n')

        self.assertIn(n, v1.nodes.all())
        self.assertIn(d, v1.nodes.all())
        self.assertEqual(v1.nodes.count(), 2)
        self.assertIn(n, v2.nodes.all())
        self.assertIn(d, v2.nodes.all())
        self.assertEqual(v2.nodes.count(), 2)
        self.assertEqual(d.votes.count(), 2)
Example #23
0
 def setUp(self):
     self.root = get_root_node()
     self.hugo = create_user("Hugo", password="******", groups=['voters'])
     self.ulf = create_user("Ulf", password="******", groups=['voters'])
     self.permela = create_user("Permela", password="******")
     self.slot = create_slot("Slot")
     self.root.append_child(self.slot)
     self.text = create_textNode("Bla", "Blubb", [self.hugo])
     self.slot.append_child(self.text)
     self.mid = create_textNode("Bla derivate", "Blubb2", [self.hugo])
     self.slot.append_child(self.mid)
     self.text.add_derivate(self.mid, arg_type='c', title="dagegen")
     self.leaf1 = create_textNode("Bla leaf 1", "Blubb3", [self.hugo])
     self.slot.append_child(self.leaf1)
     self.mid.add_derivate(self.leaf1, arg_type='c', title="dagegen2")
     self.mid2 = create_textNode("Bla derivate 2", "Blubb4", [self.hugo])
     self.slot.append_child(self.mid2)
     self.mid.add_derivate(self.mid2, arg_type='c', title="dagegen")
     self.leaf2 = create_textNode("Bla leaf 2", "Blubb5", [self.hugo])
     self.slot.append_child(self.leaf2)
     self.mid2.add_derivate(self.leaf2, arg_type='c', title="dagegen")
     self.follow = create_vote(
         self.hugo,
         [self.text, self.mid, self.leaf1, self.mid2, self.leaf2])
     self.arg1 = create_argument(self.text, "con", "Wrong!", "Bad!",
                                 [self.hugo])
Example #24
0
 def setUp(self):
     self.n = create_structureNode("woot")
     self.n1 = create_structureNode("foo1")
     self.n2 = create_structureNode("foo2")
     self.n1.add_derivate(self.n2)
     self.hugo = create_user("hugo")
     self.v = create_vote(self.hugo, [self.n1, self.n2])
Example #25
0
def generate_proposal_node_with_subsections(slot, proposal, user):
    proposal_node = create_structureNode(
        long_title=proposal['heading'], text=proposal['text'], authors=[user])
    slot.append_child(proposal_node)
    create_vote(user, [proposal_node])  # auto-follow

    for child in proposal['subsections']:
        if not re.match(SHORT_TITLE, child['shorttitle']):
            raise InvalidShortTitle('Invalid short-title: "{}"'.
                                    format(child['shorttitle']))

        child_slot = create_slot(child['shorttitle'])
        proposal_node.append_child(child_slot)
        generate_proposal_node_with_subsections(child_slot, child, user)

    return proposal_node
Example #26
0
 def setUp(self):
     self.n = create_structureNode("woot")
     self.n1 = create_structureNode("foo1")
     self.n2 = create_structureNode("foo2")
     self.n1.add_derivate(self.n2)
     self.hugo = create_user("hugo")
     self.v = create_vote(self.hugo, [self.n1, self.n2])
Example #27
0
 def setUp(self):
     self.root = get_root_node()
     self.hugo = create_user("Hugo", password="******", groups=['voters'])
     self.ulf = create_user("Ulf", password="******", groups=['voters'])
     self.permela = create_user("Permela", password="******")
     self.slot = create_slot("Slot")
     self.root.append_child(self.slot)
     self.text = create_textNode("Bla", "Blubb", [self.hugo])
     self.slot.append_child(self.text)
     self.mid = create_textNode("Bla derivate", "Blubb2", [self.hugo])
     self.slot.append_child(self.mid)
     self.text.add_derivate(self.mid, arg_type='c', title="dagegen")
     self.leaf1 = create_textNode("Bla leaf 1", "Blubb3", [self.hugo])
     self.slot.append_child(self.leaf1)
     self.mid.add_derivate(self.leaf1, arg_type='c', title="dagegen2")
     self.mid2 = create_textNode("Bla derivate 2", "Blubb4", [self.hugo])
     self.slot.append_child(self.mid2)
     self.mid.add_derivate(self.mid2, arg_type='c', title="dagegen")
     self.leaf2 = create_textNode("Bla leaf 2", "Blubb5", [self.hugo])
     self.slot.append_child(self.leaf2)
     self.mid2.add_derivate(self.leaf2, arg_type='c', title="dagegen")
     self.follow = create_vote(self.hugo,
                               [self.text, self.mid, self.leaf1, self.mid2,
                                self.leaf2])
     self.arg1 = create_argument(self.text, "con", "Wrong!", "Bad!",
                                 [self.hugo])
Example #28
0
    def setUp(self):
        self.hans = create_user('hans')
        self.hugo = create_user('hugo')

        self.root = get_root_node()
        self.slot1 = create_slot('Wahlprogramm')
        self.root.append_child(self.slot1)
        self.structureNode1 = create_structureNode('LangerWahlprogrammTitel',
                                                   authors=[self.hans])
        self.slot1.append_child(self.structureNode1)
        self.slot11 = create_slot('Transparenz')
        self.structureNode1.append_child(self.slot11)
        self.textnode11 = create_textNode('Traaaansparenz', authors=[self.hans])
        self.slot11.append_child(self.textnode11)
        self.slot12 = create_slot('Bildung')
        self.structureNode1.append_child(self.slot12)
        self.textnode12 = create_textNode('Biiildung', authors=[self.hans])
        self.slot12.append_child(self.textnode12)
        self.slot13 = create_slot('Datenschutz')
        self.structureNode1.append_child(self.slot13)
        self.textnode13 = create_textNode('Daaatenschutz', authors=[self.hans])
        self.slot13.append_child(self.textnode13)

        self.slot2 = create_slot('Grundsatzprogramm')
        self.root.append_child(self.slot2)
        self.textnode2 = create_textNode('LangerGrundsatzTitel',
                                         authors=[self.hugo])
        self.slot2.append_child(self.textnode2)

        self.slot3 = create_slot('Organisatorisches')
        self.root.append_child(self.slot3)
        self.textnode31 = create_textNode('Langweilig1', authors=[self.hans])
        self.textnode32 = create_textNode('Langweilig2', authors=[self.hugo])
        self.textnode33 = create_textNode('Langweilig3',
                                          authors=[self.hans, self.hugo])
        self.slot3.append_child(self.textnode31)
        self.slot3.append_child(self.textnode32)
        self.slot3.append_child(self.textnode33)
        create_vote(self.hans, [self.textnode33])

        self.top_slots = [self.slot1, self.slot2, self.slot3]
        self.child_slots = [self.slot11, self.slot12, self.slot13]
        self.short_titles = ['Wahlprogramm', 'Grundsatzprogramm',
                             'Organisatorisches']
        self.full_titles = ['LangerWahlprogrammTitel', 'LangerGrundsatzTitel',
                            'Langweilig3']
        self.authors = [[self.hans], [self.hugo], [self.hans, self.hugo]]
Example #29
0
def generate_proposal_node_with_subsections(slot, proposal, user):
    proposal_node = create_structureNode(long_title=proposal['heading'],
                                         text=proposal['text'],
                                         authors=[user])
    slot.append_child(proposal_node)
    create_vote(user, [proposal_node])  # auto-follow

    for child in proposal['subsections']:
        if not re.match(SHORT_TITLE, child['shorttitle']):
            raise InvalidShortTitle('Invalid short-title: "{}"'.format(
                child['shorttitle']))

        child_slot = create_slot(child['shorttitle'])
        proposal_node.append_child(child_slot)
        generate_proposal_node_with_subsections(child_slot, child, user)

    return proposal_node
Example #30
0
    def setUp(self):
        self.hans = create_user("hans")
        self.hugo = create_user("hugo")

        self.root = get_root_node()
        self.slot1 = create_slot("Wahlprogramm")
        self.root.append_child(self.slot1)
        self.structureNode1 = create_structureNode("LangerWahlprogrammTitel", authors=[self.hans])
        self.slot1.append_child(self.structureNode1)
        self.slot11 = create_slot("Transparenz")
        self.structureNode1.append_child(self.slot11)
        self.textnode11 = create_textNode("Traaaansparenz", authors=[self.hans])
        self.slot11.append_child(self.textnode11)
        self.slot12 = create_slot("Bildung")
        self.structureNode1.append_child(self.slot12)
        self.textnode12 = create_textNode("Biiildung", authors=[self.hans])
        self.slot12.append_child(self.textnode12)
        self.slot13 = create_slot("Datenschutz")
        self.structureNode1.append_child(self.slot13)
        self.textnode13 = create_textNode("Daaatenschutz", authors=[self.hans])
        self.slot13.append_child(self.textnode13)

        self.slot2 = create_slot("Grundsatzprogramm")
        self.root.append_child(self.slot2)
        self.textnode2 = create_textNode("LangerGrundsatzTitel", authors=[self.hugo])
        self.slot2.append_child(self.textnode2)

        self.slot3 = create_slot("Organisatorisches")
        self.root.append_child(self.slot3)
        self.textnode31 = create_textNode("Langweilig1", authors=[self.hans])
        self.textnode32 = create_textNode("Langweilig2", authors=[self.hugo])
        self.textnode33 = create_textNode("Langweilig3", authors=[self.hans, self.hugo])
        self.slot3.append_child(self.textnode31)
        self.slot3.append_child(self.textnode32)
        self.slot3.append_child(self.textnode33)
        create_vote(self.hans, [self.textnode33])

        self.top_slots = [self.slot1, self.slot2, self.slot3]
        self.child_slots = [self.slot11, self.slot12, self.slot13]
        self.short_titles = ["Wahlprogramm", "Grundsatzprogramm", "Organisatorisches"]
        self.full_titles = ["LangerWahlprogrammTitel", "LangerGrundsatzTitel", "Langweilig3"]
        self.authors = [[self.hans], [self.hugo], [self.hans, self.hugo]]
Example #31
0
 def test_mail_notify_new_argument(self):
     hugo = create_user("hugo")
     hugo.email = "*****@*****.**"
     hugo.profile.wants_mail_notification = True
     hugo.save()
     max = create_user("max")
     max.email = "*****@*****.**"
     max.profile.wants_mail_notification = True
     max.save()
     berta = create_user("berta")
     berta.email = "*****@*****.**"
     berta.profile.wants_mail_notification = False
     berta.save()
     post = create_post('System Message', hugo)
     node = create_nodes_for_path('/foo.1', [hugo])
     create_vote(hugo, [node])
     create_vote(max, [node])
     create_vote(berta, [node])
     create_argument(node, 'n', 'Bla', 'Blubb', [hugo])
     notify_new_argument(node, post)
     self.assertEqual(len(mail.outbox), 1)
     m = mail.outbox[0]
     self.assertEqual(m.to, [])
     self.assertEqual(m.bcc, ['*****@*****.**', '*****@*****.**'])
     self.assertIn('System Message', m.body)
     self.assertGreater(len(m.subject), 0)
Example #32
0
    def setUp(self):
        self.horst = create_user('horst')
        self.udo = create_user('udo')

        self.root = get_root_node()
        self.slot1 = create_slot('soon_empty')
        self.root.append_child(self.slot1)
        self.node = create_structureNode('To be or not to be', 'never both')
        self.slot1.append_child(self.node)
        self.arg = create_argument(self.node, 'c', "no", "lyrics")
        self.path = 'soon_empty.1'
        self.child_slot = create_slot('or_to_pee')
        self.node.append_child(self.child_slot)
        self.child = create_structureNode('or to pee')
        self.child_slot.append_child(self.child)

        TextCache.objects.create(path=self.path, paragraphs="doesn't matter")
        IndexCache.objects.create(path=self.path, index_nodes="doesn't matter")

        self.slot2 = create_slot('verfassungswiedrig')
        self.root.append_child(self.slot2)
        self.source = create_structureNode('BöserTitel', 'gewöhnlicher text')
        self.slot2.append_child(self.source)
        self.derivate = create_structureNode('BöserTitel',
                                             'verfassungswiedriger text')
        self.slot2.append_child(self.derivate)
        self.source.add_derivate(self.derivate, arg_type='con',
                                 title="zuSchwach", text="muss fieser werden",
                                 authors=[self.udo])

        self.source_path = 'verfassungswiedrig.1'
        self.derivate_path = 'verfassungswiedrig.2'

        create_vote(self.udo, [self.node])
        create_vote(self.horst, [self.source, self.node])
        create_spam_flag(self.horst, [self.node])

        create_post('i reference /verfassungswiedrig.1 because i like it ',
                    self.horst, self.path)
Example #33
0
 def setUp(self):
     self.root = get_root_node()
     self.hugo = create_user("Hugo", password="******", groups=['voters'])
     self.permela = create_user("Permela", password="******")
     self.slot = create_slot("Slot")
     self.root.append_child(self.slot)
     self.text = create_textNode("Bla", "Blubb", [self.hugo])
     self.slot.append_child(self.text)
     self.mid = create_textNode("Bla derivate", "Blubb2", [self.hugo])
     self.slot.append_child(self.mid)
     self.text.add_derivate(self.mid, arg_type='n')
     self.leaf1 = create_textNode("Bla leaf 1", "Blubb3", [self.hugo])
     self.slot.append_child(self.leaf1)
     self.mid.add_derivate(self.leaf1, arg_type='n')
     self.mid2 = create_textNode("Bla derivate 2", "Blubb4", [self.hugo])
     self.slot.append_child(self.mid2)
     self.mid.add_derivate(self.mid2, arg_type='n')
     self.leaf2 = create_textNode("Bla leaf 2", "Blubb5", [self.hugo])
     self.slot.append_child(self.leaf2)
     self.mid2.add_derivate(self.leaf2, arg_type='n')
     self.follow = create_vote(self.hugo,
                               [self.text, self.mid, self.leaf1, self.mid2,
                                self.leaf2])
Example #34
0
 def setUp(self):
     self.root = get_root_node()
     self.hugo = create_user("Hugo", password="******", groups=['voters'])
     self.permela = create_user("Permela", password="******")
     self.slot = create_slot("Slot")
     self.root.append_child(self.slot)
     self.text = create_textNode("Bla", "Blubb", [self.hugo])
     self.slot.append_child(self.text)
     self.mid = create_textNode("Bla derivate", "Blubb2", [self.hugo])
     self.slot.append_child(self.mid)
     self.text.add_derivate(self.mid, arg_type='n')
     self.leaf1 = create_textNode("Bla leaf 1", "Blubb3", [self.hugo])
     self.slot.append_child(self.leaf1)
     self.mid.add_derivate(self.leaf1, arg_type='n')
     self.mid2 = create_textNode("Bla derivate 2", "Blubb4", [self.hugo])
     self.slot.append_child(self.mid2)
     self.mid.add_derivate(self.mid2, arg_type='n')
     self.leaf2 = create_textNode("Bla leaf 2", "Blubb5", [self.hugo])
     self.slot.append_child(self.leaf2)
     self.mid2.add_derivate(self.leaf2, arg_type='n')
     self.follow = create_vote(
         self.hugo,
         [self.text, self.mid, self.leaf1, self.mid2, self.leaf2])
Example #35
0
    def setUp(self):
        self.hans = create_user('hans')
        self.hugo = create_user('hugo')

        self.root = get_root_node()
        self.slot1 = create_slot('Wahlprogramm')
        self.root.append_child(self.slot1)
        self.structureNode1 = create_structureNode(
            'LangerWahlprogrammTitel',
            text="Einleitungstext",
            authors=[self.hans])
        self.slot1.append_child(self.structureNode1)
        self.slot11 = create_slot('Transparenz')
        self.structureNode1.append_child(self.slot11)
        self.structureNode11 = create_structureNode(
            'Traaaansparenz',
            text="Transparenz ist wichtig.",
            authors=[self.hans])
        self.slot11.append_child(self.structureNode11)
        self.slot111 = create_slot('Ebene_3')
        self.structureNode11.append_child(self.slot111)
        self.structureNode111 = create_structureNode(
            'Eeeebeneee 3',
            authors=[self.hans])
        self.slot111.append_child(self.structureNode111)
        self.slot1111 = create_slot('Ebene_4')
        self.structureNode111.append_child(self.slot1111)
        self.structureNode1111 = create_structureNode(
            'Eeeebeneee 4',
            authors=[self.hans])
        self.slot1111.append_child(self.structureNode1111)
        self.slot11111 = create_slot('Ebene_5')
        self.structureNode1111.append_child(self.slot11111)
        self.structureNode11111 = create_structureNode(
            'Eeeebeneee 5',
            authors=[self.hans])
        self.slot11111.append_child(self.structureNode11111)
        self.slot111111 = create_slot('Ebene_6')
        self.structureNode11111.append_child(self.slot111111)
        self.structureNode111111 = create_structureNode(
            'Eeeebeneee 6',
            authors=[self.hans])
        self.slot111111.append_child(self.structureNode111111)
        self.slot1111111 = create_slot('Ebene_7')
        self.structureNode111111.append_child(self.slot1111111)
        self.textnode1111111 = create_textNode(
            'Traaaansparenz',
            text="Auf Ebene 7.",
            authors=[self.hans])
        self.slot1111111.append_child(self.textnode1111111)
        self.slot12 = create_slot('Bildung')
        self.structureNode1.append_child(self.slot12)
        self.textnode12 = create_textNode(
            'Biiildung',
            authors=[self.hans])
        self.slot12.append_child(self.textnode12)
        self.slot13 = create_slot('Datenschutz')
        self.structureNode1.append_child(self.slot13)
        self.textnode13 = create_textNode(
            'Daaatenschutz', text="Blubb.", authors=[self.hans])
        self.slot13.append_child(self.textnode13)
        self.textnode13_a1 = create_argument(
            self.textnode13, arg_type='con', title='Dagegen',
            text="...denn ihr seid dafür", authors=[self.hugo])

        self.slot2 = create_slot('Grundsatzprogramm')
        self.root.append_child(self.slot2)
        self.textnode2 = create_textNode(
            'LangerGrundsatzTitel', authors=[self.hugo])
        self.slot2.append_child(self.textnode2)

        self.slot3 = create_slot('Organisatorisches')
        self.root.append_child(self.slot3)
        self.textnode31 = create_textNode('Langweilig1', authors=[self.hans])
        self.textnode32 = create_textNode('Langweilig2', authors=[self.hugo])
        self.textnode33 = create_textNode(
            'Langweilig3', authors=[self.hans, self.hugo])
        self.slot3.append_child(self.textnode31)
        self.slot3.append_child(self.textnode32)
        self.slot3.append_child(self.textnode33)
        create_vote(self.hans, [self.textnode33])

        self.top_slots = [self.slot1, self.slot2, self.slot3]
        self.child_slots = [self.slot11, self.slot12, self.slot13]
        self.short_titles = ['Wahlprogramm', 'Grundsatzprogramm',
                             'Organisatorisches']
        self.full_titles = ['LangerWahlprogrammTitel', 'LangerGrundsatzTitel',
                            'Langweilig3']
        self.authors = [[self.hans], [self.hugo], [self.hans, self.hugo]]
        self.maxDiff = None
Example #36
0
    def setUp(self):
        self.hans = create_user('hans')
        self.hugo = create_user('hugo')

        self.root = get_root_node()
        self.slot1 = create_slot('Wahlprogramm')
        self.root.append_child(self.slot1)
        self.structureNode1 = create_structureNode('LangerWahlprogrammTitel',
                                                   text="Einleitungstext",
                                                   authors=[self.hans])
        self.slot1.append_child(self.structureNode1)
        self.slot11 = create_slot('Transparenz')
        self.structureNode1.append_child(self.slot11)
        self.structureNode11 = create_structureNode(
            'Traaaansparenz',
            text="Transparenz ist wichtig.",
            authors=[self.hans])
        self.slot11.append_child(self.structureNode11)
        self.slot111 = create_slot('Ebene_3')
        self.structureNode11.append_child(self.slot111)
        self.structureNode111 = create_structureNode('Eeeebeneee 3',
                                                     authors=[self.hans])
        self.slot111.append_child(self.structureNode111)
        self.slot1111 = create_slot('Ebene_4')
        self.structureNode111.append_child(self.slot1111)
        self.structureNode1111 = create_structureNode('Eeeebeneee 4',
                                                      authors=[self.hans])
        self.slot1111.append_child(self.structureNode1111)
        self.slot11111 = create_slot('Ebene_5')
        self.structureNode1111.append_child(self.slot11111)
        self.structureNode11111 = create_structureNode('Eeeebeneee 5',
                                                       authors=[self.hans])
        self.slot11111.append_child(self.structureNode11111)
        self.slot111111 = create_slot('Ebene_6')
        self.structureNode11111.append_child(self.slot111111)
        self.structureNode111111 = create_structureNode('Eeeebeneee 6',
                                                        authors=[self.hans])
        self.slot111111.append_child(self.structureNode111111)
        self.slot1111111 = create_slot('Ebene_7')
        self.structureNode111111.append_child(self.slot1111111)
        self.textnode1111111 = create_textNode('Traaaansparenz',
                                               text="Auf Ebene 7.",
                                               authors=[self.hans])
        self.slot1111111.append_child(self.textnode1111111)
        self.slot12 = create_slot('Bildung')
        self.structureNode1.append_child(self.slot12)
        self.textnode12 = create_textNode('Biiildung', authors=[self.hans])
        self.slot12.append_child(self.textnode12)
        self.slot13 = create_slot('Datenschutz')
        self.structureNode1.append_child(self.slot13)
        self.textnode13 = create_textNode('Daaatenschutz',
                                          text="Blubb.",
                                          authors=[self.hans])
        self.slot13.append_child(self.textnode13)
        self.textnode13_a1 = create_argument(self.textnode13,
                                             arg_type='con',
                                             title='Dagegen',
                                             text="...denn ihr seid dafür",
                                             authors=[self.hugo])

        self.slot2 = create_slot('Grundsatzprogramm')
        self.root.append_child(self.slot2)
        self.textnode2 = create_textNode('LangerGrundsatzTitel',
                                         authors=[self.hugo])
        self.slot2.append_child(self.textnode2)

        self.slot3 = create_slot('Organisatorisches')
        self.root.append_child(self.slot3)
        self.textnode31 = create_textNode('Langweilig1', authors=[self.hans])
        self.textnode32 = create_textNode('Langweilig2', authors=[self.hugo])
        self.textnode33 = create_textNode('Langweilig3',
                                          authors=[self.hans, self.hugo])
        self.slot3.append_child(self.textnode31)
        self.slot3.append_child(self.textnode32)
        self.slot3.append_child(self.textnode33)
        create_vote(self.hans, [self.textnode33])

        self.top_slots = [self.slot1, self.slot2, self.slot3]
        self.child_slots = [self.slot11, self.slot12, self.slot13]
        self.short_titles = [
            'Wahlprogramm', 'Grundsatzprogramm', 'Organisatorisches'
        ]
        self.full_titles = [
            'LangerWahlprogrammTitel', 'LangerGrundsatzTitel', 'Langweilig3'
        ]
        self.authors = [[self.hans], [self.hugo], [self.hans, self.hugo]]
        self.maxDiff = None
Example #37
0
def create_alternatives_for_urheberrecht(path):
    ulf = create_user("ulf")
    timo = create_user("timo")
    slot_path = path.rsplit(".", 1)[0]
    slot = get_node_for_path(slot_path)

    w1 = "Reform des Urheberrechts sollte von der Basis kommen."

    a1 = create_structureNode("Urheberrecht", w1, authors=[ulf])
    slot.append_child(a1)

    w2a = "Abschaffung des Urheberrechts!"
    a2a = create_structureNode("Kein Urheberrecht", w2a, authors=[ulf])
    slot.append_child(a2a)

    w2b = "Völlige Abschaffung des Urheber- und Patentrechts!"
    a2b = create_structureNode("Kein Urheberrecht", w2b, authors=[ulf])
    slot.append_child(a2b)
    arga = a2a.add_derivate(
        a2b,
        "con",
        "Patentrecht ist genauso böse",
        "Das patentrecht ist mindestens genauso schlimm und muss auch weg!",
        [ulf],
    )

    w2c = "Völlige Abschaffung des Urheber- und Patentrechts! Außerdem Todesstrafe für alle Patentanwälte."
    a2c = create_structureNode("Kein Urheberrecht", w2c, authors=[timo])
    slot.append_child(a2c)
    argb = a2b.add_derivate(a2c, "con", "Patentanwälte stinken!", "Dieses Pack gehört ausgerottet!", [timo])

    # create votes
    original = get_node_for_path(path)
    hugo = create_user("hugo")
    hans = create_user("hans")
    hein = create_user("hein")
    create_vote(ulf, [a1])
    create_vote(ulf, [a2a, a2b])
    create_vote(timo, [a2c])
    create_vote(hugo, [original])
    create_vote(hein, [original])
    create_vote(hans, [a1])
    create_vote(hans, [a2b])
    create_vote(hans, [arga])
    create_vote(ulf, [arga])
    create_spam_flag(hein, [argb])
    create_spam_flag(hein, [a2c])
Example #38
0
 def test_get_newfollows_without_sources_returns_number_of_follows(self):
     n = create_structureNode('Foo')
     create_vote(self.hans, [n])
     create_vote(self.hugo, [n])
     self.assertEqual(n.get_newfollows(), 2)