Exemple #1
0
def test_discussion():
    l.add_proposal(data)
    proposal = data['id']

    users = []
    for n in range(10):
        uid = l.add_user('{}@example.com'.format(n), 'name {}'.format(n), 'blah')
        l.approve_user(uid)
        users.append(uid)

    l.add_to_discussion(users[0], proposal, 'Lorem ipsum')

    for u in users:
        assert len(l.get_unread(u)) == 0

    assert len(l.get_discussion(proposal)) == 1
    assert l.get_discussion(proposal)[0].body == 'Lorem ipsum'

    l.add_to_discussion(users[-1], proposal, 'dolor sit')
    assert [x.id for x in l.get_unread(users[0])] == [proposal]
    l.add_to_discussion(users[-1], proposal, 'amet, consectetur')
    assert [x.id for x in l.get_unread(users[0])] == [proposal]

    l.mark_read(users[0], proposal)
    for u in users:
        assert len(l.get_unread(u)) == 0

    l.add_to_discussion(users[0], proposal, 'LOREM IPSUM')
    assert l.get_discussion(proposal)[-1].body == 'LOREM IPSUM'
    assert l.get_discussion(proposal)[0].body == 'Lorem ipsum'
Exemple #2
0
def test_discussion():
    l.add_proposal(data)
    proposal = data['id']

    users = []
    for n in range(10):
        uid = l.add_user('{}@example.com'.format(n), 'name {}'.format(n),
                         'blah')
        l.approve_user(uid)
        users.append(uid)

    l.add_to_discussion(users[0], proposal, 'Lorem ipsum')

    for u in users:
        assert len(l.get_unread(u)) == 0

    assert len(l.get_discussion(proposal)) == 1
    assert l.get_discussion(proposal)[0].body == 'Lorem ipsum'

    l.add_to_discussion(users[-1], proposal, 'dolor sit')
    assert [x.id for x in l.get_unread(users[0])] == [proposal]
    l.add_to_discussion(users[-1], proposal, 'amet, consectetur')
    assert [x.id for x in l.get_unread(users[0])] == [proposal]

    l.mark_read(users[0], proposal)
    for u in users:
        assert len(l.get_unread(u)) == 0

    l.add_to_discussion(users[0], proposal, 'LOREM IPSUM')
    assert l.get_discussion(proposal)[-1].body == 'LOREM IPSUM'
    assert l.get_discussion(proposal)[0].body == 'Lorem ipsum'
Exemple #3
0
def test_discussion():
    l.add_proposal(data)
    proposal = data["id"]

    users = []
    for n in range(10):
        uid = l.add_user("{}@example.com".format(n), "name {}".format(n), "blah")
        l.approve_user(uid)
        users.append(uid)

    l.add_to_discussion(users[0], proposal, "Lorem ipsum")

    for u in users:
        assert len(l.get_unread(u)) == 0

    assert len(l.get_discussion(proposal)) == 1
    assert l.get_discussion(proposal)[0].body == "Lorem ipsum"

    l.add_to_discussion(users[-1], proposal, "dolor sit")
    assert [x.id for x in l.get_unread(users[0])] == [proposal]
    l.add_to_discussion(users[-1], proposal, "amet, consectetur")
    assert [x.id for x in l.get_unread(users[0])] == [proposal]

    l.mark_read(users[0], proposal)
    for u in users:
        assert len(l.get_unread(u)) == 0

    l.add_to_discussion(users[0], proposal, "LOREM IPSUM")
    assert l.get_discussion(proposal)[-1].body == "LOREM IPSUM"
    assert l.get_discussion(proposal)[0].body == "Lorem ipsum"
Exemple #4
0
def mark_read_read_next(id):
    l.mark_read(request.user.id, id)
    unread = l.get_unread(request.user.id)
    if not unread:
        flash('All unread messages marked as read')
        return redirect(url_for('screening_stats'))
    target = random.choice(unread)
    return redirect(url_for('screening', id=random.choice(unread).id))
Exemple #5
0
def mark_read_read_next(id):
    l.mark_read(request.user.id, id)
    unread = l.get_unread(request.user.id)
    if not unread:
        flash('All unread messages marked as read')
        return redirect(url_for('screening_stats'))
    target = random.choice(unread)
    return redirect(url_for('screening', id=random.choice(unread).id))
Exemple #6
0
def show_unread():
    return render_template('unread.html', unread=l.get_unread(request.user.id))
Exemple #7
0
def show_unread():
    return render_template('unread.html', unread=l.get_unread(request.user.id))