本文整理汇总了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)
示例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>]')
示例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')
示例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')
示例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)
示例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')