示例#1
0
文件: post.py 项目: noway56/notepy
 def get(self, pid):
     try:
         post = Post.get(id=pid)
         post.tags = Tag.select().join(PostTag).join(Post).where(Post.id == pid)
         self.render('post/edit.html', post=post, side=self.get_side(), title='编辑-' + post.title)
     except DoesNotExist:
         self.send_error(404)
示例#2
0
文件: base.py 项目: noway56/notepy
    def get_side():
        """获取侧边栏内容

        通用侧边栏数据
        """
        side = {
            "recent_post": Post.select().limit(conf["RECENT_POST_NUM"]),
            "random_post": Post.select().order_by(fn.Rand()).limit(conf["RANDOM_POST_NUM"]),
            "tags": Tag.select(Tag, fn.Count(Post.id).alias("count")).join(PostTag).join(Post).group_by(Tag),
        }
        return side
示例#3
0
 def get(self, pid):
     try:
         post = Post.get(id=pid)
         post.tags = Tag.select().join(PostTag).join(Post).where(
             Post.id == pid)
         self.render('post/edit.html',
                     post=post,
                     side=self.get_side(),
                     title='编辑-' + post.title)
     except DoesNotExist:
         self.send_error(404)
示例#4
0
文件: app.py 项目: chagge/menureader
def view_tag(tag_id):
    # View all dishes for a certain tag.
    tag = Tag.get_tag_by_id(tag_id)
    data = {}
    data['similar'] = tag.get_dishes()
    return json.dumps(data)
示例#5
0
def view_tag(tag_id):
    # View all dishes for a certain tag.
    tag = Tag.get_tag_by_id(tag_id)
    data = {}
    data['similar'] = tag.get_dishes()
    return json.dumps(data)