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


Python ModeratedObject.approve方法代码示例

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


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

示例1: test_post_save_handler_for_existing_object

# 需要导入模块: from moderation.models import ModeratedObject [as 别名]
# 或者: from moderation.models.ModeratedObject import approve [as 别名]
    def test_post_save_handler_for_existing_object(self):
        from django.db.models import signals

        signals.pre_save.connect(self.moderation.pre_save_handler,
                                 sender=UserProfile)
        signals.post_save.connect(self.moderation.post_save_handler,
                                  sender=UserProfile)
        profile = UserProfile.objects.get(user__username='moderator')
        moderated_object = ModeratedObject(content_object=profile)
        moderated_object.save()
        moderated_object.approve(by=self.user)

        profile.description = 'New description of user profile'
        profile.save()

        moderated_object = ModeratedObject.objects.get_for_instance(profile)

        original_object = moderated_object.changed_object
        self.assertEqual(original_object.description,
                         'New description of user profile')
        self.assertEqual(UserProfile.objects.get(pk=profile.pk).description,
                         'Old description')

        signals.pre_save.disconnect(self.moderation.pre_save_handler,
                                    UserProfile)
        signals.post_save.disconnect(self.moderation.post_save_handler,
                                     UserProfile)
开发者ID:blag,项目名称:django-moderation,代码行数:29,代码来源:testregister.py

示例2: test_filter_moderated_objects_returns_object

# 需要导入模块: from moderation.models import ModeratedObject [as 别名]
# 或者: from moderation.models.ModeratedObject import approve [as 别名]
    def test_filter_moderated_objects_returns_object(self):
        """Test if filter_moderated_objects return object when object 
        doesn't have moderated object or deserialized object is <> object"""
        moderated_object = ModeratedObject(content_object=self.profile)
        moderated_object.save()
        moderated_object.approve()

        self.profile.description = "New"
        self.profile.save()

        self.assertEqual(unicode(UserProfile.objects.all()),
                         u'[<UserProfile: moderator - http://www.google.com>]')
开发者ID:adityar7,项目名称:django-moderation,代码行数:14,代码来源:managers.py

示例3: test_approve_moderated_object

# 需要导入模块: from moderation.models import ModeratedObject [as 别名]
# 或者: from moderation.models.ModeratedObject import approve [as 别名]
    def test_approve_moderated_object(self):
        """test if after object approval new data is saved."""
        self.profile.description = 'New description'

        moderated_object = ModeratedObject(content_object=self.profile)

        moderated_object.save()

        moderated_object.approve(moderated_by=self.user)

        user_profile = UserProfile.objects.get(user__username='moderator')

        self.assertEqual(user_profile.description, 'New description')
开发者ID:EBNull,项目名称:django-moderation,代码行数:15,代码来源:models.py

示例4: test_approve_moderated_object_new_model_instance

# 需要导入模块: from moderation.models import ModeratedObject [as 别名]
# 或者: from moderation.models.ModeratedObject import approve [as 别名]
 def test_approve_moderated_object_new_model_instance(self):
     profile = UserProfile(description='Profile for new user',
                 url='http://www.test.com',
                 user=User.objects.get(username='user1'))
     
     moderated_object = ModeratedObject(content_object=profile)
     moderated_object.save()
     
     moderated_object.approve(self.user)
     
     user_profile = UserProfile.objects.get(url='http://www.test.com')
     
     self.assertEqual(user_profile.description, 'Profile for new user')
开发者ID:bx2,项目名称:django-moderation,代码行数:15,代码来源:test_models.py

示例5: test_has_object_been_changed_should_be_true

# 需要导入模块: from moderation.models import ModeratedObject [as 别名]
# 或者: from moderation.models.ModeratedObject import approve [as 别名]
    def test_has_object_been_changed_should_be_true(self):
        self.profile.description = 'Old description'
        moderated_object = ModeratedObject(content_object=self.profile)
        moderated_object.save()
        moderated_object.approve(moderated_by=self.user)

        user_profile = self.profile.__class__.objects.get(id=self.profile.id)

        self.profile.description = 'New description'
        moderated_object = ModeratedObject(content_object=self.profile)
        moderated_object.save()

        value = moderated_object.has_object_been_changed(user_profile)

        self.assertEqual(value, True)
开发者ID:SamTShaw,项目名称:django-moderation,代码行数:17,代码来源:models.py

示例6: test_get_of_existing_object_should_return_old_version_of_object

# 需要导入模块: from moderation.models import ModeratedObject [as 别名]
# 或者: from moderation.models.ModeratedObject import approve [as 别名]
    def test_get_of_existing_object_should_return_old_version_of_object(self):
        """Tests if after register of model class with moderation, 
            when existing object is saved, when getting of object returns 
            old version of object"""
        profile = UserProfile.objects.get(user__username='moderator')
        moderated_object = ModeratedObject(content_object=profile)
        moderated_object.save()
        moderated_object.approve(by=self.user)

        profile.description = "New description"
        profile.save()

        old_profile = UserProfile.objects.get(pk=profile.pk)

        self.assertEqual(old_profile.description, 'Old description')
开发者ID:blag,项目名称:django-moderation,代码行数:17,代码来源:testregister.py


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