def hot_posts(cls, count=8, order="view_count desc"): return [cls(post) for post in DBPost.hot_posts(count, order)]
def create_post(cls, author, category, **settings): dbpost = DBPost.create(author_id=author.db_object.id, category_id=category.db_object.id) dbpost.save() _ = dbpost.stats # init stats author.stats.increase("post_count") category.stats.increase("post_count") post = cls(dbpost) post.update(**settings) return post
def latest_posts(cls, count=8, order="updated_date desc"): return [cls(post) for post in DBPost.latest_posts(count, order)]
def get_by_id(cls, id): dbpost = id and DBPost.get_by_id(id) return dbpost and cls(dbpost)
def get_by_id(cls, id): dbpost = DBPost.get_by_id(id) return dbpost and cls(dbpost)
def latest_posts(cls, count=8, order="updated_date desc"): return DBPost.latest_posts(count, order)
def hot_posts(cls, count=8, order="view_count desc"): return DBPost.hot_posts(count, order)