예제 #1
0
def user_post(topic_id):
    topic = Topic.from_mongo(topic_id)
    posts = topic.get_posts()
    return render_template('posts.html',
                           posts=posts,
                           topic_title=topic.title,
                           topic_id=topic._id,
                           username=session['username'],
                           picture=session['picture'])
예제 #2
0
def new_post(topic_id):
    if request.method == 'GET':
        return render_template('new_post.html', topic_id=topic_id)
    else:
        message = request.form['content']
        user = User.get_by_username(session['username'])
        topic = Topic.from_mongo(topic_id)

        new_post = Post(message, topic_id, user.username, user.picture,
                        topic.description, topic.title)
        new_post.save_to_mongo()

        return make_response(user_post(topic_id))