当前位置: 首页>>代码示例>>Python>>正文


Python post.Post类代码示例

本文整理汇总了Python中business.post.Post的典型用法代码示例。如果您正苦于以下问题:Python Post类的具体用法?Python Post怎么用?Python Post使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Post类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_find_post_with_not_exist_author

    def test_find_post_with_not_exist_author(self):

        try:
            Post.find_post_by_author_pagination(10, 4, 7)
            self.fail("Expect UserNotFoundError")
        except UserNotFoundError:
            pass
开发者ID:bluzky,项目名称:ice-wolf,代码行数:7,代码来源:test_post_find_by_author_with_pagination.py

示例2: test_find_post_with_invalid_categories

    def test_find_post_with_invalid_categories(self):

        try:
            Post.find_post_by_keyword("")
            self.fail("Expect InvalidFieldError")
        except InvalidFieldError:
            pass
开发者ID:bluzky,项目名称:ice-wolf,代码行数:7,代码来源:test_post_find_by_keyword.py

示例3: test_find_post_with_invalid_author_id

    def test_find_post_with_invalid_author_id(self):

        try:
            Post.find_post_by_author_pagination("abc")
            self.fail("Expect InvalidFieldError")
        except InvalidFieldError:
            pass
开发者ID:bluzky,项目名称:ice-wolf,代码行数:7,代码来源:test_post_find_by_author_with_pagination.py

示例4: test_delete_post_by_manager

    def test_delete_post_by_manager(self):
        args = {
            "user_id": 1,
            "post_id": 2
        }

        Post.delete_post(**args)
        post = DBPost.get_by_id(2)
        self.assertIsNone(post)
开发者ID:bluzky,项目名称:ice-wolf,代码行数:9,代码来源:test_post_delete.py

示例5: test_delete_post_all_field_valid

    def test_delete_post_all_field_valid(self):
        args = {
            "user_id": 1,
            "post_id": 1
        }

        Post.delete_post(**args)
        post = DBPost.get_by_id(1)
        self.assertIsNone(post)
开发者ID:bluzky,项目名称:ice-wolf,代码行数:9,代码来源:test_post_delete.py

示例6: test_delete_not_exist_post

    def test_delete_not_exist_post(self):
        args = {
            "user_id": 2,
            "post_id": 100
        }

        try:
            Post.delete_post(**args)
            self.fail("Expect PostNotFoundError")
        except PostNotFoundError:
            pass
开发者ID:bluzky,项目名称:ice-wolf,代码行数:11,代码来源:test_post_delete.py

示例7: test_add_post_without_content

    def test_add_post_without_content(self):
        args = {
            "user_id": 2,
            "title": "Hello",
            "content": "",
        }

        try:
            Post.add_post(**args)
            self.fail("Expect InvalidFieldError")
        except InvalidFieldError:
            pass
开发者ID:roseviet,项目名称:ice-wolf,代码行数:12,代码来源:test_post_add.py

示例8: test_delete_post_without_permission

    def test_delete_post_without_permission(self):
        """
        user who want to delete pos is not the author or manager
        :return:
        """
        args = {
            "user_id": 2,
            "post_id": 3
        }

        try:
            Post.delete_post(**args)
            self.fail("Expect AccessDeniedError")
        except AccessDeniedError:
            pass
开发者ID:bluzky,项目名称:ice-wolf,代码行数:15,代码来源:test_post_delete.py

示例9: show_single_post

def show_single_post(post_id):
    try:
        post = Post.get_post(post_id)
        if post:
            return render_template("single_post.html", post=post)
        else:
            abort(404)
    except Exception as e:
        abort(404)
开发者ID:roseviet,项目名称:ice-wolf,代码行数:9,代码来源:post_controller.py

示例10: edit_post

def edit_post(post_id):
    try:
        post = Post.get_post(post_id)
        #only author can edit post
        if post.author.id != current_user.id and current_user.role != "manager":
            abort(403)
        return render_template("add_post.html", post=post, categories=default.categories)
    except Exception as e:
        abort(404)
开发者ID:roseviet,项目名称:ice-wolf,代码行数:9,代码来源:post_controller.py

示例11: search_post_by_keyword

def search_post_by_keyword():
    keyword = request.args["keyword"] or None
    page = request.args.get("page", 1)
    per_page = request.args.get("per_page", PER_PAGE)

    try:
        pagination = Post.find_post_by_keyword_pagination(keyword, page, per_page)
        return render_template("search_result.html", pagination=pagination, keyword=keyword, menu_items=default.categories)
    except Exception as e:
        abort(400)
开发者ID:roseviet,项目名称:ice-wolf,代码行数:10,代码来源:post_controller.py

示例12: add_post

def add_post():
    try:
        args={
            "user_id": current_user.id,
            "title":request.form["title"] or None,
            "content": request.form["content"] or None,
            "categories": request.form.getlist("categories") or None,
            "tags": request.form["tags"] or None,
            "feature_image":request.form["feature_image"] or None,
        }
        post = Post.add_post(**args)

        return redirect(url_for('post', post_id=post.id))
    except:
        abort(400)
开发者ID:roseviet,项目名称:ice-wolf,代码行数:15,代码来源:post_controller.py

示例13: update_post

def update_post():
    args={
            "user_id": current_user.id,
            "post_id": request.form["post_id"] or None,
            "title":request.form["title"] or None,
            "content": request.form["content"] or None,
            "categories": request.form.getlist("categories") or None,
            "tags": request.form["tags"] or None,
            "feature_image":request.form["feature_image"] or None,
        }
    try:
        post = Post.update_post(**args)
        return render_template("add_post.html", post=post, categories=default.categories)
    except AccessDeniedError:
        abort(403)
    except Exception as e:
        abort(400)
开发者ID:roseviet,项目名称:ice-wolf,代码行数:17,代码来源:post_controller.py

示例14: test_add_post_without_title

    def test_add_post_without_title(self):
        args ={
            "user_id": 2,
            "title": "",
            "content": "<p>Sed itaque dignissimos eligendi reprehenderit, nesciunt ducimus voluptates dolores suscipit fugit ipsam aperiam praesentium laborum odit qui libero ipsum tempora, eos quis hic, sapiente perspiciatis amet labore voluptatibus alias. Vitae.</p>",
            "feature_image":"http://www.keenthemes.com/preview/metronic/theme/assets/global/plugins/jcrop/demos/demo_files/image1.jpg",
            "tags": "wallpaper, nature",
            "categories":"Uncategorized",
            "draft": True,
        }

        p = Post.add_post(**args)
        self.assertIsNotNone(p)

        post = DBPost.get_by_id(p.id)
        self.assertEqual(post.user_id, args["user_id"])
        self.assertGreater(len(post.title), 0)
        self.assertEqual(post.content, args["content"])
        self.assertEqual(post.feature_image, args["feature_image"])
        self.assertEqual(post.tags, args["tags"])
        self.assertEqual(post.categories, args["categories"])
开发者ID:roseviet,项目名称:ice-wolf,代码行数:21,代码来源:test_post_add.py

示例15: test_get_post_with_negative_id

 def test_get_post_with_negative_id(self):
     try:
         post = Post.get_post(-1)
         self.fail("Expect InvalidFieldError")
     except InvalidFieldError:
         pass
开发者ID:bluzky,项目名称:ice-wolf,代码行数:6,代码来源:test_post_get_id.py


注:本文中的business.post.Post类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。