Esempio n. 1
0
def batch_vote(id):
    group = l.get_group(id)
    if request.user.email in group.author_emails or group.locked:
        abort(404)

    accept = request.values.getlist('accept', int)

    l.vote_group(id, request.user.id, accept)
    return redirect(url_for('batch_view', id=id))
Esempio n. 2
0
def batch_vote(id):
    group = l.get_group(id)
    if request.user.email in group.author_emails or group.locked:
        abort(404)

    accept = request.values.getlist('accept', int)

    l.vote_group(id, request.user.id, accept)
    return redirect(url_for('batch_view', id=id))
Esempio n. 3
0
def batch_vote(id):
    accept = request.values.getlist("accept", int)

    l.vote_group(id, request.user.id, accept)
    if not accept:
        txt = "You chose no talks from group {}".format(id)
    else:
        txt = "You chose talk{} {} from group {}"
        txt = txt.format("" if len(accept) == 1 else "s", " and ".join("#" + str(x) for x in accept), id)
    flash(txt)
    return redirect(url_for("batch_splash_page"))
Esempio n. 4
0
def batch_vote(id):
    group = l.get_group(id)
    if request.user.email in group.author_emails:
        abort(404)

    accept = request.values.getlist('accept', int)

    l.vote_group(id, request.user.id, accept)
    if not accept:
        txt = 'You chose no talks from group {}'.format(id)
    else:
        txt = 'You chose talk{} {} from group {}'
        txt = txt.format('' if len(accept) == 1 else 's',
                    ' and '.join('#'+str(x) for x in accept),
                    id)
    flash(txt)
    return redirect(url_for('batch_splash_page'))
Esempio n. 5
0
def test_batch():

    user = l.add_user('*****@*****.**', 'Voter', '123')
    l.approve_user(user)

    submitter = l.add_user('*****@*****.**', 'Submitted', '123')
    l.approve_user(submitter)

    proposals = []
    for n in range(1, 50):
        prop = data.copy()
        prop['id'] = n
        if n == 6:
            prop['authors'] = [{'name': 'Blah', 'email': '*****@*****.**'}]
        proposals.append(l.add_proposal(prop))

    group_one = l.create_group('Group One', proposals[4:10])
    group_two = l.create_group('Group Two', proposals[16:27])

    assert l.get_group(group_one).name == 'Group One'

    group_one_proposals = l.get_group_proposals(group_one)
    assert set(x.id for x in group_one_proposals) == set(proposals[4:10])

    all_groups = l.list_groups(user)
    assert set([group_one, group_two]) == set(x.id for x in all_groups)
    assert not any(x.voted for x in all_groups)

    votes1 = list(reversed(proposals[5:6]))
    votes2 = proposals[4:5]

    l.vote_group(group_one, user, votes1)

    all_groups = {x.id: x.voted for x in l.list_groups(user)}
    assert all_groups[group_one]
    assert not all_groups[group_two]

    assert l.get_batch_vote(group_one, user).accept == votes1

    l.vote_group(group_one, user, votes2)

    assert l.get_batch_vote(group_one, user).accept == votes2

    assert len(l.list_groups(submitter)) == 1
Esempio n. 6
0
def test_batch():

    user = l.add_user('*****@*****.**', 'Voter', '123')
    l.approve_user(user)

    submitter = l.add_user('*****@*****.**', 'Submitted', '123')
    l.approve_user(submitter)

    proposals = []
    for n in range(1,50):
        prop = data.copy()
        prop['id'] = n
        if n == 6:
            prop['authors'] = [{'name':'Blah', 'email':'*****@*****.**'}]
        proposals.append(l.add_proposal(prop))

    group_one = l.create_group('Group One', proposals[4:10])
    group_two = l.create_group('Group Two', proposals[16:27])

    assert l.get_group(group_one).name == 'Group One'

    group_one_proposals = l.get_group_proposals(group_one)
    assert set(x.id for x in group_one_proposals) == set(proposals[4:10])
   
    all_groups = l.list_groups(user)
    assert set([group_one, group_two]) == set(x.id for x in all_groups)
    assert not any(x.voted for x in all_groups)

    votes1 = list(reversed(proposals[5:6]))
    votes2 = proposals[4:5]

    l.vote_group(group_one, user, votes1)

    all_groups = {x.id:x.voted for x in l.list_groups(user)}
    assert all_groups[group_one]
    assert not all_groups[group_two]

    assert l.get_batch_vote(group_one, user).accept == votes1

    l.vote_group(group_one, user, votes2)

    assert l.get_batch_vote(group_one, user).accept == votes2

    assert len(l.list_groups(submitter)) == 1
Esempio n. 7
0
def test_batch():

    user = l.add_user("*****@*****.**", "Voter", "123")
    l.approve_user(user)

    proposals = []
    for n in range(1, 50):
        prop = data.copy()
        prop["id"] = n
        proposals.append(l.add_proposal(prop))

    group_one = l.create_group("Group One", proposals[4:10])
    group_two = l.create_group("Group Two", proposals[16:27])

    assert l.get_group(group_one).name == "Group One"

    group_one_proposals = l.get_group_proposals(group_one)
    assert set(x.id for x in group_one_proposals) == set(proposals[4:10])

    all_groups = l.list_groups(user)
    assert set([group_one, group_two]) == set(x.id for x in all_groups)
    assert not any(x.voted for x in all_groups)

    votes1 = list(reversed(proposals[5:6]))
    votes2 = proposals[4:5]

    l.vote_group(group_one, user, votes1)

    all_groups = {x.id: x.voted for x in l.list_groups(user)}
    assert all_groups[group_one]
    assert not all_groups[group_two]

    assert l.get_batch_vote(group_one, user).accept == votes1

    l.vote_group(group_one, user, votes2)

    assert l.get_batch_vote(group_one, user).accept == votes2