當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。