Пример #1
0
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)
Пример #2
0
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))
Пример #3
0
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))