def _prompt_user_for_account(self): title = input("Enter blog title: ") description = input("Enter blog description: ") blog = Blog(author=self.user, title=title, description=description) blog.save_to_mongo() self.user_blog = blog
def create_new_blog(): if request.method == 'GET': return render_template('new_blog.html') else: 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() return make_response(user_blog(user._id))
def _user_has_account(self): blog = Database.find_one('blogs', {'author': self.user}) if blog is not None: self.user_blog = Blog.from_mongo(blog['id']) return True else: return False
def user_post(blog_id): blog = Blog.from_mongo(blog_id) posts = blog.get_post() return render_template("posts.html", posts=posts, blog_title=blog.title, blog_id=blog._id)
def New_Post(blog_id, title, content, date=datetime.datetime.utcnow()): blog = Blog.from_mongo(blog_id) blog.new_post(title=title, content=content, date=date)
def New_Blog(self, title, description): blog = Blog(author=self.email, title=title, description=description, author_id=self._id) blog.save_to_mongo()
def Get_Blogs(self): return Blog.Find_By_Author(self._id)
def _view_blog(self): blog_to_see = input("Enter the ID of the blog you'd like to read: ") blog = Blog.from_mongo(blog_to_see) posts = blog.get_post() for post in posts: print("Date: {}, title: {}\n\n{}".format(post['date'], post['title'], post['content']))
from src.modules.post import Post from src.modules.blog import Blog from src.modules.user import User from src.commons.Database import Database Database.initialize() blog = Blog(author="Eliudnjai", title="Another-nother test", description="hope this shit works", author_id=User.Get_By_Id(id)) blog.save_to_mongo()