Exemple #1
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)
Exemple #2
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)
Exemple #3
0
    def post(self):
        pid = int(self.get_argument("id"))
        post = Post.get(id=pid)
        post.title = self.get_argument('title')
        post.content = self.get_argument("content")

        tags = model.get_tags(str(self.get_argument('tags')))
        try:
            model.tag_save(tags, post.id)
            post.save()
            self.success('文章更新成功')
        except DatabaseError:
            self.error('文章更新失败')
Exemple #4
0
    def post(self):
        pid = int(self.get_argument("id"))
        post = Post.get(id=pid)
        post.title = self.get_argument('title')
        post.content = self.get_argument("content")

        tags = model.get_tags(str(self.get_argument('tags')))
        try:
            model.tag_save(tags, post.id)
            post.save()
            self.success('文章更新成功')
        except DatabaseError:
            self.error('文章更新失败')
Exemple #5
0
 def post(self):
     pid = self.get_argument('id')
     try:
         try:
             post_tag = PostTag.delete().where(PostTag.post == pid)
             post_tag.execute()
         except DoesNotExist:
             pass
         post = Post.get(Post.id == pid)
         post.delete_instance()
         self.success('删除成功')
     except DoesNotExist:
         pass
     except DatabaseError:
         self.failure('删除失败')
Exemple #6
0
 def post(self):
     pid = self.get_argument('id')
     try:
         try:
             post_tag = PostTag.delete().where(PostTag.post == pid)
             post_tag.execute()
         except DoesNotExist:
             pass
         post = Post.get(Post.id == pid)
         post.delete_instance()
         self.success('删除成功')
     except DoesNotExist:
         pass
     except DatabaseError:
         self.failure('删除失败')