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

Python audit.approve_or_reject_existing_edit函数代码示例

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

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



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

示例1: test_requires_write_permissions_on_field

    def test_requires_write_permissions_on_field(self):
        self.plot.width = 333
        self.plot.save_with_user(self.commander_user)

        width_audit = self.plot.audits().order_by('-created')[0]

        # Read only can't edit
        FieldPermission.objects.filter(field_name='width').update(
            permission_level=FieldPermission.READ_ONLY)

        self.assertRaises(AuthorizeException,
                          approve_or_reject_existing_edit,
                          width_audit, self.commander_user, approved=True)

        # Neither can 'write with audit'
        FieldPermission.objects.filter(field_name='width').update(
            permission_level=FieldPermission.WRITE_WITH_AUDIT)

        self.assertRaises(AuthorizeException,
                          approve_or_reject_existing_edit,
                          width_audit, self.commander_user, approved=True)

        # But write directly can
        FieldPermission.objects.filter(field_name='width').update(
            permission_level=FieldPermission.WRITE_DIRECTLY)

        approve_or_reject_existing_edit(
            width_audit, self.commander_user, approved=True)
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:28,代码来源:test_audit.py


示例2: test_reject_regular_edit

    def test_reject_regular_edit(self):
        self.plot.width = 444
        self.plot.save_with_user(self.commander_user)

        self.plot.width = 555
        self.plot.save_with_user(self.commander_user)

        width_audit = self.plot.audits().order_by('-created')[0]

        # Sanity check
        self.assertEqual(width_audit.field, 'width')

        # Should not have a reference associated with it
        self.assertIsNone(width_audit.ref)

        approve_or_reject_existing_edit(
            width_audit, self.commander_user, approved=False)

        width_audit_reloaded = Audit.objects.get(pk=width_audit.pk)
        self.assertIsNotNone(width_audit_reloaded.ref)

        refd = width_audit_reloaded.ref
        self.assertEqual(refd.action, Audit.Type.ReviewReject)

        plot_reloaded = Plot.objects.get(pk=self.plot.pk)
        self.assertEqual(plot_reloaded.width, 444)
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:26,代码来源:test_audit.py


示例3: test_approving_edits_on_deleted_obj_doesnt_fail

    def test_approving_edits_on_deleted_obj_doesnt_fail(self):
        self.plot.width = 444
        self.plot.save_with_user(self.commander_user)

        width_audit = self.plot.audits().order_by('-created')[0]

        self.plot.delete_with_user(self.commander_user, cascade=True)

        approve_or_reject_existing_edit(
            width_audit, self.commander_user, approved=False)
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:10,代码来源:test_audit.py


示例4: approve_or_reject_photo

def approve_or_reject_photo(
        request, instance, feature_id, photo_id, action):

    approved = action == 'approve'

    if approved:
        msg = trans('Approved')
    else:
        msg = trans('Rejected')

    resp = HttpResponse(msg)

    try:
        photo = (MapFeaturePhoto.objects
                 .select_related('treephoto')
                 .get(pk=photo_id))
        try:
            photo = photo.treephoto
        except MapFeaturePhoto.DoesNotExist:
            pass  # There is no tree photo, so use the superclass
    except MapFeaturePhoto.DoesNotExist:
        # This may be a pending tree. Let's see if there
        # are pending audits
        pending_audits = Audit.objects\
            .filter(instance=instance)\
            .filter(model__in=['TreePhoto', 'MapFeaturePhoto'])\
            .filter(model_id=photo_id)\
            .filter(requires_auth=True)

        if len(pending_audits) > 0:
            # Process as pending and quit
            approve_or_reject_audits_and_apply(
                pending_audits, request.user, approved)

            return resp
        else:
            # Error - no pending or regular
            raise Http404('Photo Not Found')

    # Handle the id audit first
    all_audits = []
    for audit in photo.audits():
        if audit.field == 'id':
            all_audits = [audit] + all_audits
        else:
            all_audits.append(audit)

    for audit in all_audits:
        approve_or_reject_existing_edit(
            audit, request.user, approved)

    return resp
开发者ID:PyBulls,项目名称:OTM2,代码行数:52,代码来源:photo.py


示例5: approve_or_reject_photo

def approve_or_reject_photo(
        request, instance, feature_id, tree_id, photo_id, action):

    approved = action == 'approve'

    if approved:
        msg = trans('Approved')
    else:
        msg = trans('Rejected')

    resp = HttpResponse(msg)

    tree = get_object_or_404(
        Tree, plot_id=feature_id, instance=instance, pk=tree_id)

    try:
        photo = TreePhoto.objects.get(pk=photo_id, tree=tree)
    except TreePhoto.DoesNotExist:
        # This may be a pending tree. Let's see if there
        # are pending audits
        pending_audits = Audit.objects\
                              .filter(instance=instance)\
                              .filter(model='TreePhoto')\
                              .filter(model_id=photo_id)\
                              .filter(requires_auth=True)

        if len(pending_audits) > 0:
            # Process as pending and quit
            approve_or_reject_audits_and_apply(
                pending_audits, request.user, approved)

            return resp
        else:
            # Error - no pending or regular
            raise Http404('Tree Photo Not Found')

    # Handle the id audit first
    all_audits = []
    for audit in photo.audits():
        if audit.field == 'id':
            all_audits = [audit] + all_audits
        else:
            all_audits.append(audit)

    for audit in all_audits:
        approve_or_reject_existing_edit(
            audit, request.user, approved)

    return resp
开发者ID:heath,项目名称:OTM2,代码行数:49,代码来源:views.py


示例6: test_rejecting_old_edits_doesnt_update_object

    def test_rejecting_old_edits_doesnt_update_object(self):
        self.plot.width = 333
        self.plot.save_with_user(self.commander_user)

        self.plot.width = 444
        self.plot.save_with_user(self.commander_user)

        width_audit = self.plot.audits().order_by('-created')[0]

        self.plot.width = 555
        self.plot.save_with_user(self.commander_user)

        approve_or_reject_existing_edit(
            width_audit, self.commander_user, approved=False)

        reloaded_plot = Plot.objects.get(pk=self.plot.pk)
        self.assertEqual(reloaded_plot.width, 555)
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:17,代码来源:test_audit.py


示例7: test_reject_id_edit

    def test_reject_id_edit(self):
        id_audit = self.plot.audits().get(field='id')

        approve_or_reject_existing_edit(
            id_audit, self.commander_user, approved=False)

        all_audits = list(self.plot.audits())

        self.assertNotEqual(len(all_audits), 0)

        updated_audit = Audit.objects.get(pk=id_audit.pk)
        ref_audit = updated_audit.ref

        self.assertIsNotNone(ref_audit)
        self.assertEqual(ref_audit.action, Audit.Type.ReviewReject)

        self.assertRaises(Plot.DoesNotExist,
                          Plot.objects.get, pk=self.plot.pk)
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:18,代码来源:test_audit.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python audit.ReputationMetric类代码示例发布时间:2022-05-27
下一篇:
Python audit.approve_or_reject_audit_and_apply函数代码示例发布时间: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