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


Python PostSerializer.save方法代码示例

本文整理汇总了Python中popit.serializers.PostSerializer.save方法的典型用法代码示例。如果您正苦于以下问题:Python PostSerializer.save方法的具体用法?Python PostSerializer.save怎么用?Python PostSerializer.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在popit.serializers.PostSerializer的用法示例。


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

示例1: test_update_post_otherlabels_links

# 需要导入模块: from popit.serializers import PostSerializer [as 别名]
# 或者: from popit.serializers.PostSerializer import save [as 别名]
    def test_update_post_otherlabels_links(self):
        data = {
            "other_labels": [
                {
                    "id": "aee39ddd-6785-4a36-9781-8e745c6359b7",
                    "links": [
                        {
                            "id": "6c928027-4813-4770-80a5-ba413a43efae",
                            "note": "It is on facebook but it is hard to see"
                        }
                    ]
                }
            ]
        }

        post = Post.objects.untranslated().get(id="c1f0f86b-a491-4986-b48d-861b58a3ef6e")
        serializer = PostSerializer(post, data=data, partial=True, language="en")
        serializer.is_valid()
        self.assertEqual(serializer.errors, {})
        serializer.save()

        post = Post.objects.language("en").get(id="c1f0f86b-a491-4986-b48d-861b58a3ef6e")
        other_labels = post.other_labels.language("en").get(id="aee39ddd-6785-4a36-9781-8e745c6359b7")
        link = other_labels.links.language("en").get(id="6c928027-4813-4770-80a5-ba413a43efae")
        self.assertEqual(link.note, "It is on facebook but it is hard to see")
开发者ID:lfalvarez,项目名称:popit_ng,代码行数:27,代码来源:test_post_serializer.py

示例2: test_create_post_minimal_field_serializer

# 需要导入模块: from popit.serializers import PostSerializer [as 别名]
# 或者: from popit.serializers.PostSerializer import save [as 别名]
 def test_create_post_minimal_field_serializer(self):
     data = {
         "role": "Honorary Member",
     }
     serializer = PostSerializer(data=data, language="en")
     serializer.is_valid()
     self.assertEqual(serializer.errors, {})
     serializer.save()
     post = Post.objects.language("en").get(role="Honorary Member")
     self.assertEqual(post.role, "Honorary Member")
开发者ID:lfalvarez,项目名称:popit_ng,代码行数:12,代码来源:test_post_serializer.py

示例3: test_update_post_translated

# 需要导入模块: from popit.serializers import PostSerializer [as 别名]
# 或者: from popit.serializers.PostSerializer import save [as 别名]
 def test_update_post_translated(self):
     data = {
         "label": "ahli"
     }
     post = Post.objects.untranslated().get(id="c1f0f86b-a491-4986-b48d-861b58a3ef6e")
     serializer = PostSerializer(post, data=data, language="ms", partial=True)
     serializer.is_valid()
     self.assertEqual(serializer.errors, {})
     serializer.save()
     post = Post.objects.language("ms").get(id="c1f0f86b-a491-4986-b48d-861b58a3ef6e")
     self.assertEqual(post.label, "ahli")
开发者ID:lfalvarez,项目名称:popit_ng,代码行数:13,代码来源:test_post_serializer.py

示例4: test_create_post_translated

# 需要导入模块: from popit.serializers import PostSerializer [as 别名]
# 或者: from popit.serializers.PostSerializer import save [as 别名]
 def test_create_post_translated(self):
     data = {
         "label": "Ahli Terhormat",
         "role": "Ahli Terhormat",
     }
     serializer = PostSerializer(data=data, language="ms")
     serializer.is_valid()
     self.assertEqual(serializer.errors, {})
     serializer.save()
     post = Post.objects.language("ms").get(role="Ahli Terhormat")
     self.assertEqual(post.role, "Ahli Terhormat")
开发者ID:lfalvarez,项目名称:popit_ng,代码行数:13,代码来源:test_post_serializer.py

示例5: test_create_post_otherlabels_serializer

# 需要导入模块: from popit.serializers import PostSerializer [as 别名]
# 或者: from popit.serializers.PostSerializer import save [as 别名]
 def test_create_post_otherlabels_serializer(self):
     data = {
         "other_labels": [{
             "name": "sampan party"
         }]
     }
     post = Post.objects.untranslated().get(id="c1f0f86b-a491-4986-b48d-861b58a3ef6e")
     serializer = PostSerializer(post, data=data, language="en", partial=True)
     serializer.is_valid()
     self.assertEqual(serializer.errors, {})
     serializer.save()
     post = Post.objects.language("en").get(id="c1f0f86b-a491-4986-b48d-861b58a3ef6e")
     other_labels = post.other_labels.language("en").get(name="sampan party")
     self.assertEqual(other_labels.name, "sampan party")
开发者ID:lfalvarez,项目名称:popit_ng,代码行数:16,代码来源:test_post_serializer.py

示例6: test_update_post_translated

# 需要导入模块: from popit.serializers import PostSerializer [as 别名]
# 或者: from popit.serializers.PostSerializer import save [as 别名]
 def test_update_post_translated(self):
     data = {
         "label": "ahli"
     }
     # When translation do not exist, the following is used in production
     # post = Post.objects.untranslated().get(id="c1f0f86b-a491-4986-b48d-861b58a3ef6e")
     # But when translation exist, fetch existing translation
     post = Post.objects.language("ms").get(id="c1f0f86b-a491-4986-b48d-861b58a3ef6e")
     serializer = PostSerializer(post, data=data, language="ms", partial=True)
     serializer.is_valid()
     self.assertEqual(serializer.errors, {})
     serializer.save()
     post = Post.objects.language("ms").get(id="c1f0f86b-a491-4986-b48d-861b58a3ef6e")
     self.assertEqual(post.label, "ahli")
开发者ID:buholoco,项目名称:popit_ng,代码行数:16,代码来源:test_post_serializer.py

示例7: test_create_post_serializer

# 需要导入模块: from popit.serializers import PostSerializer [as 别名]
# 或者: from popit.serializers.PostSerializer import save [as 别名]
    def test_create_post_serializer(self):
        data = {
            "label": "Honorary Member",
            "organization_id": "3d62d9ea-0600-4f29-8ce6-f7720fd49aa3",
            "role": "Honorary Member",
            "area_id": "640c0f1d-2305-4d17-97fe-6aa59f079cc4",
            "start_date": "2000-02-02",
            "end_date": "2030-02-02",
        }

        serializer = PostSerializer(data=data, language="en")
        serializer.is_valid()
        self.assertEqual(serializer.errors, {})
        serializer.save()
        post = Post.objects.language("en").get(role="Honorary Member")
        self.assertEqual(post.organization_id, "3d62d9ea-0600-4f29-8ce6-f7720fd49aa3")
开发者ID:lfalvarez,项目名称:popit_ng,代码行数:18,代码来源:test_post_serializer.py

示例8: test_create_post_links_serializer

# 需要导入模块: from popit.serializers import PostSerializer [as 别名]
# 或者: from popit.serializers.PostSerializer import save [as 别名]
 def test_create_post_links_serializer(self):
     data = {
         "links": [
             {
                 "url": "http://www.yahoo.com"
             }
         ]
     }
     post = Post.objects.untranslated().get(id="c1f0f86b-a491-4986-b48d-861b58a3ef6e")
     serializer = PostSerializer(post, data=data, partial=True, language="en")
     serializer.is_valid()
     self.assertEqual(serializer.errors, {})
     serializer.save()
     post = Post.objects.language("en").get(id="c1f0f86b-a491-4986-b48d-861b58a3ef6e")
     link = post.links.language("en").get(url="http://www.yahoo.com")
     self.assertEqual(link.url, "http://www.yahoo.com")
开发者ID:lfalvarez,项目名称:popit_ng,代码行数:18,代码来源:test_post_serializer.py

示例9: test_update_post_links_serializer

# 需要导入模块: from popit.serializers import PostSerializer [as 别名]
# 或者: from popit.serializers.PostSerializer import save [as 别名]
 def test_update_post_links_serializer(self):
     data = {
         "links": [
             {
                 "id": "ce15a9ee-6742-4467-bbfb-c86459ee685b",
                 "note": "just a link"
             }
         ]
     }
     post = Post.objects.untranslated().get(id="c1f0f86b-a491-4986-b48d-861b58a3ef6e")
     serializer = PostSerializer(post, data=data, partial=True, language="en")
     serializer.is_valid()
     self.assertEqual(serializer.errors, {})
     serializer.save()
     post = Post.objects.language("en").get(id="c1f0f86b-a491-4986-b48d-861b58a3ef6e")
     link = post.links.language("en").get(id="ce15a9ee-6742-4467-bbfb-c86459ee685b")
     self.assertEqual(link.note, "just a link")
开发者ID:lfalvarez,项目名称:popit_ng,代码行数:19,代码来源:test_post_serializer.py

示例10: test_create_post_contacts_serializer

# 需要导入模块: from popit.serializers import PostSerializer [as 别名]
# 或者: from popit.serializers.PostSerializer import save [as 别名]
 def test_create_post_contacts_serializer(self):
     data = {
         "contact_details": [
             {
                 "type": "sms",
                 "value": "231313123131",
             }
         ]
     }
     post = Post.objects.untranslated().get(id="c1f0f86b-a491-4986-b48d-861b58a3ef6e")
     serializer = PostSerializer(post, data=data, partial=True, language="en")
     serializer.is_valid()
     self.assertEqual(serializer.errors, {})
     serializer.save()
     post = Post.objects.language("en").get(id="c1f0f86b-a491-4986-b48d-861b58a3ef6e")
     contact = post.contact_details.language("en").get(value="231313123131")
     self.assertEqual(contact.type, "sms")
开发者ID:lfalvarez,项目名称:popit_ng,代码行数:19,代码来源:test_post_serializer.py

示例11: test_update_post_otherlabels_serializer

# 需要导入模块: from popit.serializers import PostSerializer [as 别名]
# 或者: from popit.serializers.PostSerializer import save [as 别名]
 def test_update_post_otherlabels_serializer(self):
     data = {
         "other_labels": [
             {
                 "id":"aee39ddd-6785-4a36-9781-8e745c6359b7",
                 "name": "Bilge Rat"
             }
         ]
     }
     post = Post.objects.untranslated().get(id="c1f0f86b-a491-4986-b48d-861b58a3ef6e")
     serializer = PostSerializer(post, data=data, partial=True, language="en")
     serializer.is_valid()
     self.assertEqual(serializer.errors, {})
     serializer.save()
     post = Post.objects.language("en").get(id="c1f0f86b-a491-4986-b48d-861b58a3ef6e")
     other_labels = post.other_labels.language("en").get(id="aee39ddd-6785-4a36-9781-8e745c6359b7")
     self.assertEqual(other_labels.name, "Bilge Rat")
开发者ID:lfalvarez,项目名称:popit_ng,代码行数:19,代码来源:test_post_serializer.py

示例12: test_update_post_contacts_serializer

# 需要导入模块: from popit.serializers import PostSerializer [as 别名]
# 或者: from popit.serializers.PostSerializer import save [as 别名]
    def test_update_post_contacts_serializer(self):
        data = {
            "contact_details": [
                {
                    "id": "7f3f67c4-6afd-4de9-880e-943560cf56c0",
                    "type": "phone"
                }
            ]
        }

        post = Post.objects.untranslated().get(id="c1f0f86b-a491-4986-b48d-861b58a3ef6e")
        serializer = PostSerializer(post, data=data, partial=True, language="en")
        serializer.is_valid()
        self.assertEqual(serializer.errors, {})
        serializer.save()
        post = Post.objects.language("en").get(id="c1f0f86b-a491-4986-b48d-861b58a3ef6e")
        contact = post.contact_details.language("en").get(id="7f3f67c4-6afd-4de9-880e-943560cf56c0")
        self.assertEqual(contact.type, "phone")
开发者ID:lfalvarez,项目名称:popit_ng,代码行数:20,代码来源:test_post_serializer.py

示例13: test_create_post_contact_links

# 需要导入模块: from popit.serializers import PostSerializer [as 别名]
# 或者: from popit.serializers.PostSerializer import save [as 别名]
    def test_create_post_contact_links(self):
        data = {
            "contact_details": [
                {
                    "id": "7f3f67c4-6afd-4de9-880e-943560cf56c0",
                    "links": [
                        {
                            "url": "http://www.bing.com"
                        }
                    ]
                }
            ]
        }
        post = Post.objects.untranslated().get(id="c1f0f86b-a491-4986-b48d-861b58a3ef6e")
        serializer = PostSerializer(post, data=data, partial=True, language="en")
        serializer.is_valid()
        self.assertEqual(serializer.errors, {})
        serializer.save()

        post = Post.objects.language("en").get(id="c1f0f86b-a491-4986-b48d-861b58a3ef6e")
        contact = post.contact_details.language("en").get(id="7f3f67c4-6afd-4de9-880e-943560cf56c0")
        link = contact.links.language("en").get(url="http://www.bing.com")
        self.assertEqual(link.url, "http://www.bing.com")
开发者ID:lfalvarez,项目名称:popit_ng,代码行数:25,代码来源:test_post_serializer.py

示例14: test_update_post_contact_links

# 需要导入模块: from popit.serializers import PostSerializer [as 别名]
# 或者: from popit.serializers.PostSerializer import save [as 别名]
    def test_update_post_contact_links(self):
        data = {
            "contact_details": [
                {
                    "id": "7f3f67c4-6afd-4de9-880e-943560cf56c0",
                    "links": [
                        {
                            "id": "a37256e6-eab7-417a-8ac8-32edc5031924",
                            "note": "a wikipedia site"
                        }
                    ]
                }
            ]
        }
        post = Post.objects.untranslated().get(id="c1f0f86b-a491-4986-b48d-861b58a3ef6e")
        serializer = PostSerializer(post, data=data, partial=True, language="en")
        serializer.is_valid()
        self.assertEqual(serializer.errors, {})
        serializer.save()

        post = Post.objects.language("en").get(id="c1f0f86b-a491-4986-b48d-861b58a3ef6e")
        contact = post.contact_details.language("en").get(id="7f3f67c4-6afd-4de9-880e-943560cf56c0")
        link = contact.links.language("en").get(id="a37256e6-eab7-417a-8ac8-32edc5031924")
        self.assertEqual(link.note, "a wikipedia site")
开发者ID:lfalvarez,项目名称:popit_ng,代码行数:26,代码来源:test_post_serializer.py

示例15: test_create_post_otherlabels_links

# 需要导入模块: from popit.serializers import PostSerializer [as 别名]
# 或者: from popit.serializers.PostSerializer import save [as 别名]
    def test_create_post_otherlabels_links(self):
        data = {
            "other_labels": [
                {
                    "id": "aee39ddd-6785-4a36-9781-8e745c6359b7",
                    "links": [
                        {
                            "url": "http://en.wikipedia.com"
                        }
                    ]
                }
            ]
        }

        post = Post.objects.untranslated().get(id="c1f0f86b-a491-4986-b48d-861b58a3ef6e")
        serializer = PostSerializer(post, data=data, partial=True, language="en")
        serializer.is_valid()
        self.assertEqual(serializer.errors, {})
        serializer.save()

        post = Post.objects.language("en").get(id="c1f0f86b-a491-4986-b48d-861b58a3ef6e")
        other_labels = post.other_labels.language("en").get(id="aee39ddd-6785-4a36-9781-8e745c6359b7")
        link = other_labels.links.language("en").get(url="http://en.wikipedia.com")
        self.assertEqual(link.url, "http://en.wikipedia.com")
开发者ID:lfalvarez,项目名称:popit_ng,代码行数:26,代码来源:test_post_serializer.py


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