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'
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"
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))
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))
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))
def mark_read(id): l.mark_read(request.user.id, id) return redirect(url_for("screening", id=id))