Пример #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'
Пример #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'
Пример #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"
Пример #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))
Пример #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))
Пример #6
0
def mark_read(id):
    l.mark_read(request.user.id, id)
    return render_template('discussion_snippet.html',
                           unread=l.is_unread(request.user.id, id),
                           discussion=l.get_discussion(id))
Пример #7
0
def mark_read(id):
    l.mark_read(request.user.id, id)
    return render_template('discussion_snippet.html', 
            unread = l.is_unread(request.user.id, id),
            discussion = l.get_discussion(id))
Пример #8
0
def mark_read(id):
    l.mark_read(request.user.id, id)
    return redirect(url_for("screening", id=id))