def getBlogs(userId = None): if userId is not None: user = User.getById(userId) else: user = User.getByEmail(session['email']) blogs = user.getBlogs() return render_template('userBlogs.html',blogs=blogs,email=user.email)
def createNewBlog(): if request.method == 'GET': return render_template('newBlog.html') else: title = request.form['title'] description = request.form['description'] author = User.getByEmail(session['email']) blog = Blog(author.email,title,description,author._id) blog.saveToMongo() return make_response(getBlogs(author._id))
def createNewPost(blogId): if request.method == 'GET': return render_template('newPost.html',blogId=blogId) else: title = request.form['title'] content = request.form['content'] author = User.getByEmail(session['email']) blog = Blog.getFromMongo(blogId) blog.newPost(title,content) return make_response(getPostsForBlog(blogId))