• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.ModeratedObject类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_is_not_equal_instance_should_be_false

    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)
开发者ID:bx2,项目名称:django-moderation,代码行数:7,代码来源:test_models.py


示例2: test_has_object_been_changed_should_be_false

    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)
开发者ID:EBNull,项目名称:django-moderation,代码行数:7,代码来源:models.py


示例3: test_generate_diff

    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}])
开发者ID:bx2,项目名称:django-moderation,代码行数:26,代码来源:test_diff.py


示例4: test_post_save_handler_for_existing_object

    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,代码行数:27,代码来源:testregister.py


示例5: test_approval_status_pending

 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)
开发者ID:bx2,项目名称:django-moderation,代码行数:8,代码来源:test_models.py


示例6: test_filter_moderated_objects_returns_object

    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>]")
开发者ID:bx2,项目名称:django-moderation,代码行数:10,代码来源:test_menagers.py


示例7: test_has_object_been_changed_should_be_true

    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)
开发者ID:EBNull,项目名称:django-moderation,代码行数:11,代码来源:models.py


示例8: test_is_not_equal_instance_should_be_true

    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)
开发者ID:bx2,项目名称:django-moderation,代码行数:11,代码来源:test_models.py


示例9: test_has_object_been_changed_should_be_true

    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)
开发者ID:amyth,项目名称:django-moderation,代码行数:11,代码来源:models.py


示例10: test_filter_moderated_objects_returns_empty_queryset

    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"[]")
开发者ID:bx2,项目名称:django-moderation,代码行数:12,代码来源:test_menagers.py


示例11: test_deserialzed_object

    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")
开发者ID:nickburns2006,项目名称:django-moderation,代码行数:12,代码来源:models.py


示例12: test_get_changes_between_models

    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')})
开发者ID:bx2,项目名称:django-moderation,代码行数:12,代码来源:test_diff.py


示例13: test_approve_moderated_object_new_model_instance

 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,代码行数:13,代码来源:test_models.py


示例14: test_excluded_fields_should_be_excluded_from_changes

    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}")
开发者ID:ixc,项目名称:django-moderation,代码行数:13,代码来源:diff.py


示例15: test_approve_moderated_object

    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,代码行数:13,代码来源:models.py


示例16: test_get_changes_between_models

    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')
        
        changes = get_changes_between_models(moderated_object.changed_object,
                                   self.profile)

        self.assertEqual(unicode(changes),
                u"{u'userprofile__url': Change object: http://www.google.com"\
                u" - http://www.google.com, u'userprofile__description': "\
                u"Change object: New description - Old description}")
开发者ID:ixc,项目名称:django-moderation,代码行数:14,代码来源:diff.py


示例17: ModerationAdminSendMessageTestCase

class ModerationAdminSendMessageTestCase(SettingsTestCase):
    fixtures = ['test_users.json', 'test_moderation.json']
    urls = 'moderation.tests.urls.default'
    test_settings = 'moderation.tests.settings.generic'

    def setUp(self):
        rf = RequestFactory()
        rf.login(username='admin', password='aaaa')
        self.request = rf.get('/admin/moderation/')
        self.request.user = User.objects.get(username='admin')
        self.admin = ModerationAdmin(UserProfile, site)

        self.profile = UserProfile.objects.get(user__username='moderator')
        self.moderated_obj = ModeratedObject(content_object=self.profile)
        self.moderated_obj.save()

    def test_send_message_when_object_has_no_moderated_object(self):
        profile = UserProfile(description='Profile for new user',
                    url='http://www.yahoo.com',
                    user=User.objects.get(username='user1'))

        profile.save()

        self.admin.send_message(self.request, profile.pk)

        message = self.request.user.message_set.get()
        self.assertEqual(unicode(message), u"This object is not registered "\
                                          u"with the moderation system.")

    def test_send_message_status_pending(self):
        self.moderated_obj.moderation_status = MODERATION_STATUS_PENDING
        self.moderated_obj.save()

        self.admin.send_message(self.request, self.profile.pk)

        message = self.request.user.message_set.get()
        self.assertEqual(unicode(message), u"Object is not viewable on site,"\
                         u" it will be visible when moderator will accept it")

    def test_send_message_status_rejected(self):
        self.moderated_obj.moderation_status = MODERATION_STATUS_REJECTED
        self.moderated_obj.moderation_reason = u'Reason for rejection'
        self.moderated_obj.save()

        self.admin.send_message(self.request, self.profile.pk)

        message = self.request.user.message_set.get()
        self.assertEqual(unicode(message), u"Object has been rejected by "\
                                 "moderator, reason: Reason for rejection")

    def test_send_message_status_approved(self):
        self.moderated_obj.moderation_status = MODERATION_STATUS_APPROVED
        self.moderated_obj.save()

        self.admin.send_message(self.request, self.profile.pk)

        message = self.request.user.message_set.get()
        self.assertEqual(unicode(message), "Object has been approved by "\
                                           "moderator and is visible on site")
开发者ID:Inkvi,项目名称:django-moderation,代码行数:59,代码来源:admin.py


示例18: test_get_of_existing_object_should_return_old_version_of_object

    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,代码行数:15,代码来源:testregister.py


示例19: test_reject_moderated_object

 def test_reject_moderated_object(self):
     self.profile.description = 'New description'
     self.profile.save()
     
     moderated_object = ModeratedObject(content_object=self.profile)
     moderated_object.save()
     
     self.profile.description = "Old description"
     self.profile.save()
     
     moderated_object.reject(self.user)
     
     user_profile = UserProfile.objects.get(user__username='moderator')
     
     self.assertEqual(user_profile.description, "Old description")
     self.assertEqual(moderated_object.moderation_status,
                      MODERATION_STATUS_REJECTED)
开发者ID:bx2,项目名称:django-moderation,代码行数:17,代码来源:test_models.py


示例20: test_moderate

 def test_moderate(self):
     self.profile.description = 'New description'
     self.profile.save()
     
     moderated_object = ModeratedObject(content_object=self.profile)
     moderated_object.save()
     
     self.profile.description = 'Old description'
     self.profile.save()
     
     moderated_object._moderate(MODERATION_STATUS_APPROVED,
                                self.user, "Reason")
     
     self.assertEqual(moderated_object.moderation_status,
                      MODERATION_STATUS_APPROVED)
     self.assertEqual(moderated_object.moderated_by, self.user)
     self.assertEqual(moderated_object.moderation_reason, "Reason")
开发者ID:bx2,项目名称:django-moderation,代码行数:17,代码来源:test_models.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python moderator.GenericModerator类代码示例发布时间:2022-05-27
下一篇:
Python fields.SerializedObjectField类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap