Ejemplo n.º 1
0
def create_new_blog():
    if request.method == 'GET':
        return render_template('new_blog.html')
    else:  # post: received post data from 'new_blog.html'
        title = request.form['title']
        description = request.form['description']
        user = User.get_by_email(session['email'])

        new_blog = Blog(user.email, title, description, user._id)
        new_blog.save_to_mongo()
        # make_response is to turn to function user_blog with the value user._id
        blogs = Blog.find_by_author_id(user._id)
        return render_template("profile.html",
                               email=session['email'],
                               blogs=blogs)
Ejemplo n.º 2
0
 def get_blogs(self):
     return Blog.find_by_author_id(self._id)
Ejemplo n.º 3
0
    def get_blogs(self):

        # to call a class / static method just use Blog.
        return Blog.find_by_author_id(self._id)
Ejemplo n.º 4
0
 def get_blogs(self):
     # return blog class
     return Blog.find_by_author_id(self._id)
Ejemplo n.º 5
0
 def get_blogs(self):
     return Blog.find_by_author_id(self._id)
Ejemplo n.º 6
0
 def get_blogs(self):
     """ Get the blogs """
     return Blog.find_by_author_id(self._id)
Ejemplo n.º 7
0
 def get_blogs(self):
     return Blog.find_by_author_id(self._id)  # Now we find by author id
Ejemplo n.º 8
0
 def get_blogs(self):
     # print("@user.get_blogs _id==: {}".format(self._id))
     return Blog.find_by_author_id(self._id)
Ejemplo n.º 9
0
 def get_blogs(self):
     blog = Blog.find_by_author_id(self._id)
     print("got the blog")
     return blog
Ejemplo n.º 10
0
def home_author(author_id):
    blogs = Blog.find_by_author_id(author_id)
    author = [blog.author for blog in blogs]
    author = author[0]
    return render_template('author_blogs.html', blogs=blogs, author=author)
Ejemplo n.º 11
0
 def get_blogs(self):
     # Verify the structure of documents in DB for ease of retrieval.
     # Retrieval is best using an author ID because author name can be duplicated. unless is username. So Blog model is updated now to suit the change. prior only author name existed.
     return Blog.find_by_author_id(self._id)