def thread_list_view(page): if request.method == 'GET': prospective_applicants = applicants.get_prospective_applicants( db.session) thread_list = threads.thread_list(db.session, page=page) unread_posts = { thread_id: post_number for thread_id, post_number in threads.unread_posts( db.session, current_user, thread_list) } return render_template('thread_list.html', threads=thread_list, num_applicants=len(prospective_applicants), Markup=Markup, unread_posts=unread_posts) elif request.method == 'POST': new_thread = threads.create_thread(db.session, request.form['post-thread-title']) new_post = posts.make_post(db.session, current_user, new_thread, request.form['post-thread-content']) db.session.commit() return redirect( url_for('thread_view', thread_id=new_thread.id, _anchor=new_post.number))
def thread_list_view(page): if request.method == 'GET': prospective_applicants = applicants.get_prospective_applicants(db.session) thread_list = threads.thread_list(db.session, page=page) unread_posts = {thread_id: post_number for thread_id, post_number in threads.unread_posts(db.session, current_user, thread_list)} return render_template('thread_list.html', threads=thread_list, num_applicants=len(prospective_applicants), Markup=Markup, unread_posts=unread_posts) elif request.method == 'POST': new_thread = threads.create_thread(db.session, request.form['post-thread-title']) new_post = posts.make_post(db.session, current_user, new_thread, request.form['post-thread-content']) db.session.commit() return redirect(url_for('thread_view', thread_id=new_thread.id, _anchor=new_post.number))
def thread_view(thread_id): if request.method == 'GET': posts_list = posts.post_list(db.session, thread_id) if not posts_list: abort(404) thread = threads.thread_from_id(db.session, thread_id) #threads.mark_read(db.session, current_user, thread, posts_list[-1]) return render_template('thread_view.html', posts=posts_list, thread=thread, Markup=Markup, user_tz=pytz.timezone(current_user.timezone)) elif request.method == 'POST': thread = threads.thread_from_id(db.session, thread_id) if not thread: abort(404) new_post = posts.make_post(db.session, current_user, thread, request.form['post-body']) db.session.commit() return redirect(url_for('thread_view', thread_id=thread.id, _anchor=new_post.number))
def thread_view(thread_id): if request.method == 'GET': posts_list = posts.post_list(db.session, thread_id) if not posts_list: abort(404) thread = threads.thread_from_id(db.session, thread_id) #threads.mark_read(db.session, current_user, thread, posts_list[-1]) return render_template('thread_view.html', posts=posts_list, thread=thread, Markup=Markup, user_tz=pytz.timezone(current_user.timezone)) elif request.method == 'POST': thread = threads.thread_from_id(db.session, thread_id) if not thread: abort(404) new_post = posts.make_post(db.session, current_user, thread, request.form['post-body']) db.session.commit() return redirect( url_for('thread_view', thread_id=thread.id, _anchor=new_post.number))