def detail(request, blogId): blog = Blog.getBlogById(blogId) if not blog: return returnNotFound("博客不存在") # 自增pv blog.increaseViews() blog.content = markdown.markdown(blog.content, extensions=[ "markdown.extensions.extra", "markdown.extensions.codehilite", "markdown.extensions.toc" ]) return render(request, "blog/detail.html", context={"blog": blog})
def updateBlog(request): if not Auth.checkOperator(request): return returnBadRequest("权限校验失败") result, blogId, title, content = checkPara(request.POST, ["blogId", "title", "content"]) if result != True: return returnBadRequest(result) blog = Blog.getBlogById(blogId) if not blog: return returnBadRequest("博客不存在") blog.title = title blog.content = content blog.save() return returnOk()
def test_get_blog(self): blog = Blog.getBlogById(1) print(blog.id) print(blog.title) self.assertEqual(True, True)