本文整理汇总了Python中moderation.models.ModeratedObject.save方法的典型用法代码示例。如果您正苦于以下问题:Python ModeratedObject.save方法的具体用法?Python ModeratedObject.save怎么用?Python ModeratedObject.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类moderation.models.ModeratedObject
的用法示例。
在下文中一共展示了ModeratedObject.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_generate_diff
# 需要导入模块: from moderation.models import ModeratedObject [as 别名]
# 或者: from moderation.models.ModeratedObject import save [as 别名]
def test_generate_diff(self):
self.profile.description = 'New description'
self.profile.url = 'http://new_url.com'
moderated_object = ModeratedObject(content_object=self.profile)
moderated_object.save()
self.profile = UserProfile.objects.get(user__username='moderator')
self.profile.description = 'Old description'
self.profile.url = 'http://old_url.com'
fields_diff = generate_diff(self.profile,
moderated_object.changed_object)
description_diff = u'<del class="diff modified">Old </del>'\
u'<ins class="diff modified">New </ins>description'
url_diff = u'http<del class="diff modified">old_url</del>'\
u'<ins class="diff modified">new_url</ins>.com'
self.assertEqual(fields_diff, [
{
'verbose_name':'description',
'diff': description_diff},
{
'verbose_name':'url',
'diff': url_diff}])
示例2: test_is_not_equal_instance_should_be_false
# 需要导入模块: from moderation.models import ModeratedObject [as 别名]
# 或者: from moderation.models.ModeratedObject import save [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)
示例3: test_has_object_been_changed_should_be_false
# 需要导入模块: from moderation.models import ModeratedObject [as 别名]
# 或者: from moderation.models.ModeratedObject import save [as 别名]
def test_has_object_been_changed_should_be_false(self):
moderated_object = ModeratedObject(content_object=self.profile)
moderated_object.save()
value = moderated_object.has_object_been_changed(self.profile)
self.assertEqual(value, False)
示例4: test_post_save_handler_for_existing_object
# 需要导入模块: from moderation.models import ModeratedObject [as 别名]
# 或者: from moderation.models.ModeratedObject import save [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)
示例5: test_approval_status_pending
# 需要导入模块: from moderation.models import ModeratedObject [as 别名]
# 或者: from moderation.models.ModeratedObject import save [as 别名]
def test_approval_status_pending(self):
"""test if before object approval status is pending"""
moderated_object = ModeratedObject(content_object=self.profile)
moderated_object.save()
self.assertEqual(moderated_object.moderation_status,
MODERATION_STATUS_PENDING)
示例6: test_filter_moderated_objects_returns_object
# 需要导入模块: from moderation.models import ModeratedObject [as 别名]
# 或者: from moderation.models.ModeratedObject import save [as 别名]
def test_filter_moderated_objects_returns_object(self):
"""Test if filter_moderated_objects return object when object
doesnt have moderated object or deserialised object is <> object"""
moderated_object = ModeratedObject(content_object=self.profile)
moderated_object.save()
self.profile.description = "New"
self.profile.save()
self.assertEqual(unicode(UserProfile.objects.all()), u"[<UserProfile: moderator - http://www.google.com>]")
示例7: test_has_object_been_changed_should_be_true
# 需要导入模块: from moderation.models import ModeratedObject [as 别名]
# 或者: from moderation.models.ModeratedObject import save [as 别名]
def test_has_object_been_changed_should_be_true(self):
self.profile.description = 'New description'
moderated_object = ModeratedObject(content_object=self.profile)
moderated_object.save()
user_profile = self.profile.__class__.objects.get(id=self.profile.id)
value = moderated_object.has_object_been_changed(user_profile)
self.assertEqual(value, True)
示例8: test_has_object_been_changed_should_be_true
# 需要导入模块: from moderation.models import ModeratedObject [as 别名]
# 或者: from moderation.models.ModeratedObject import save [as 别名]
def test_has_object_been_changed_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.has_object_been_changed(user_profile)
self.assertEqual(value, True)
示例9: test_is_not_equal_instance_should_be_true
# 需要导入模块: from moderation.models import ModeratedObject [as 别名]
# 或者: from moderation.models.ModeratedObject import save [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)
示例10: test_get_changes_between_models
# 需要导入模块: from moderation.models import ModeratedObject [as 别名]
# 或者: from moderation.models.ModeratedObject import save [as 别名]
def test_get_changes_between_models(self):
self.profile.description = 'New description'
moderated_object = ModeratedObject(content_object=self.profile)
moderated_object.save()
self.profile = UserProfile.objects.get(user__username='moderator')
diff = get_changes_between_models(moderated_object.changed_object,
self.profile)
self.assertEqual(diff, {'description': ('New description',
u'Profile description')})
示例11: test_filter_moderated_objects_returns_empty_queryset
# 需要导入模块: from moderation.models import ModeratedObject [as 别名]
# 或者: from moderation.models.ModeratedObject import save [as 别名]
def test_filter_moderated_objects_returns_empty_queryset(self):
"""Test filter_moderated_objects returns empty queryset
for object that has moderated object"""
ManagerClass = ModerationObjectsManager()(Manager)
manager = ManagerClass()
query_set = UserProfile._default_manager.all()
moderated_object = ModeratedObject(content_object=self.profile)
moderated_object.save()
self.assertEqual(unicode(manager.filter_moderated_objects(query_set)), u"[]")
示例12: test_deserialzed_object
# 需要导入模块: from moderation.models import ModeratedObject [as 别名]
# 或者: from moderation.models.ModeratedObject import save [as 别名]
def test_deserialzed_object(self):
moderated_object = ModeratedObject(content_object=self.profile)
self.profile.description = "New description"
moderated_object.changed_object = self.profile
moderated_object.save()
pk = moderated_object.pk
moderated_object = ModeratedObject.objects.get(pk=pk)
self.assertEqual(moderated_object.changed_object.description, "New description")
self.assertEqual(moderated_object.content_object.description, u"Old description")
示例13: test_approve_moderated_object
# 需要导入模块: from moderation.models import ModeratedObject [as 别名]
# 或者: from moderation.models.ModeratedObject import save [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')
示例14: test_excluded_fields_should_be_excluded_from_changes
# 需要导入模块: from moderation.models import ModeratedObject [as 别名]
# 或者: from moderation.models.ModeratedObject import save [as 别名]
def test_excluded_fields_should_be_excluded_from_changes(self):
self.profile.description = 'New description'
moderated_object = ModeratedObject(content_object=self.profile)
moderated_object.save()
self.profile = UserProfile.objects.get(user__username='moderator')
changes = get_changes_between_models(moderated_object.changed_object,
self.profile, excludes=['description'])
self.assertEqual(unicode(changes),
u"{u'userprofile__url': Change object: "\
u"http://www.google.com - http://www.google.com}")
示例15: test_approve_moderated_object_new_model_instance
# 需要导入模块: from moderation.models import ModeratedObject [as 别名]
# 或者: from moderation.models.ModeratedObject import save [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')