コード例 #1
0
ファイル: ingroup.py プロジェクト: apostrophest/ingroup
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))
コード例 #2
0
ファイル: ingroup.py プロジェクト: apostrophest/ingroup
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))
コード例 #3
0
ファイル: ingroup.py プロジェクト: apostrophest/ingroup
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))
コード例 #4
0
ファイル: ingroup.py プロジェクト: apostrophest/ingroup
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))