Beispiel #1
0
 def from_mongo_in_blog_object(cls, id):
     blog_data = Database.find_one(collection=Blog.COLLECTION_NAME,
                                   query={'id': id})
     return cls(author=blog_data['author'],
                title=blog_data['title'],
                description=blog_data['description'],
                id=blog_data['id'])
 def _user_has_account(self):
     blog = Database.find_one(Blog.COLLECTION_NAME,
                              query={'author': self.user})
     if blog is not None:
         self.user_blog = Blog.from_mongo_in_blog_object(blog['id'])
         return True
     else:
         return False
Beispiel #3
0
 def from_mongo_in_post_object(cls, id):
     post_data = Database.find_one(collection=Post.COLLECTION_NAME,
                                   query={'id': id})
     return cls(blog_id=post_data['blog_id'],
                title=post_data['title'],
                content=post_data['content'],
                author=post_data['author'],
                date=post_data['created_date'])
 def get_by_id(cls, _id):
     data = Database.find_one(User.COLLECTION_NAME, {"_id": _id})
     if data is not None:
         return cls(**data)
 def get_by_email(cls, email):
     data = Database.find_one(User.COLLECTION_NAME, {"email": email})
     if data is not None:
         return cls(**data)
 def from_mongo_in_blog_object(cls, _id):
     blog_data = Database.find_one(collection=Blog.COLLECTION_NAME, query={'_id': _id})
     return cls(**blog_data)
Beispiel #7
0
 def from_mongo_in_post_object(cls, id):
     post_data = Database.find_one(collection=Post.COLLECTION_NAME,
                                   query={'id': id})
     return cls(**post_data)