本文整理汇总了Python中moderation.models.ModeratedObject._is_not_equal_instance方法的典型用法代码示例。如果您正苦于以下问题:Python ModeratedObject._is_not_equal_instance方法的具体用法?Python ModeratedObject._is_not_equal_instance怎么用?Python ModeratedObject._is_not_equal_instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类moderation.models.ModeratedObject
的用法示例。
在下文中一共展示了ModeratedObject._is_not_equal_instance方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_is_not_equal_instance_should_be_false
# 需要导入模块: from moderation.models import ModeratedObject [as 别名]
# 或者: from moderation.models.ModeratedObject import _is_not_equal_instance [as 别名]
def test_is_not_equal_instance_should_be_false(self):
moderated_object = ModeratedObject(content_object=self.profile)
moderated_object.save()
value = moderated_object._is_not_equal_instance(self.profile)
self.assertEqual(value, False)
示例2: test_is_not_equal_instance_should_be_true
# 需要导入模块: from moderation.models import ModeratedObject [as 别名]
# 或者: from moderation.models.ModeratedObject import _is_not_equal_instance [as 别名]
def test_is_not_equal_instance_should_be_true(self):
self.profile.description = 'New description'
moderated_object = ModeratedObject(content_object=self.profile)
moderated_object.save()
user_profile = UserProfile.objects.get(user__username='moderator')
value = moderated_object._is_not_equal_instance(user_profile)
self.assertEqual(value, True)
示例3: post_save_handler
# 需要导入模块: from moderation.models import ModeratedObject [as 别名]
# 或者: from moderation.models.ModeratedObject import _is_not_equal_instance [as 别名]
def post_save_handler(self, sender, instance, **kwargs):
"""
Creates new moderation object if instance is created,
If instance exists and is only updated then save instance as
content_object of moderated_object
"""
#check if object was loaded from fixture, bypass moderation if so
if kwargs['raw']:
return
pk = instance.pk
moderator = self.get_moderator(sender)
if kwargs['created']:
old_object = sender._default_manager.get(pk=pk)
moderated_obj = ModeratedObject(content_object=old_object)
moderated_obj.save()
moderator.inform_moderator(instance)
else:
moderated_obj \
= ModeratedObject.objects.get_for_instance(instance)
if moderated_obj.moderation_status == MODERATION_STATUS_APPROVED\
and moderator.bypass_moderation_after_approval:
return
if moderated_obj._is_not_equal_instance(instance):
copied_instance = self._copy_model_instance(instance)
# save instance with data from changed_object
moderated_obj.changed_object.save_base(raw=True)
# save new data in moderated object
moderated_obj.changed_object = copied_instance
moderated_obj.moderation_status = MODERATION_STATUS_PENDING
moderated_obj.save()
moderator.inform_moderator(instance)