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

Python audit.approve_or_reject_audit_and_apply函数代码示例

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

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



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

示例1: test_reject_insert_rejects_updates

    def test_reject_insert_rejects_updates(self):
        new_plot = Plot(geom=self.p1, instance=self.instance)
        new_plot.save_with_user(self.pending_user)

        insert_audit = Audit.objects.filter(model='Plot')\
                                    .get(field='id')
        field_audits = Audit.objects.filter(model='Plot')\
                                    .exclude(field='id')

        for audit in field_audits:
            approve_or_reject_audit_and_apply(
                audit, self.commander_user, approved=True)

        approve_or_reject_audit_and_apply(insert_audit,
                                          self.commander_user, False)

        # need to refresh the field_audits collection from the db
        # because references are broken
        # why doesn't this work? why are there 5 values in field_audits_ids?
        # field_audit_ids = field_audits.values_list('id', flat=True)
        field_audit_ids = [field_audit.id for field_audit in field_audits]
        field_audits = Audit.objects.filter(pk__in=field_audit_ids)

        for field_audit in field_audits:
            attached_review_audit = Audit.objects.get(pk=field_audit.ref.pk)

            self.assertEqual(attached_review_audit.action,
                             Audit.Type.PendingReject)

            self.assertNotEqual(None,
                                Audit.objects.get(
                                    model=field_audit.model,
                                    field=field_audit.field,
                                    model_id=field_audit.model_id,
                                    action=Audit.Type.PendingApprove))
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:35,代码来源:test_audit.py


示例2: test_record_is_created_when_nullables_are_still_pending

    def test_record_is_created_when_nullables_are_still_pending(self):
        new_plot = Plot(geom=self.p1, instance=self.instance)
        new_plot.save_with_user(self.pending_user)

        new_tree = Tree(plot=new_plot, instance=self.instance,
                        diameter=10, height=10, readonly=False)

        new_tree.save_with_user(self.pending_user)

        approve_or_reject_audits_and_apply(
            new_plot.audits(),
            self.commander_user, True)

        insert_audit = Audit.objects.filter(model='Tree')\
                                    .get(field='id')
        field_audits = Audit.objects.filter(model='Tree')\
                                    .filter(field__in=['readonly', 'diameter',
                                                       'plot'])
        for audit in field_audits:
            approve_or_reject_audit_and_apply(
                audit, self.commander_user, approved=True)

        approve_or_reject_audit_and_apply(insert_audit,
                                          self.commander_user, True)

        real_tree = Tree.objects.get(pk=new_tree.pk)

        self.assertEqual(real_tree.plot_id, new_plot.pk)
        self.assertEqual(real_tree.diameter, 10)
        self.assertEqual(real_tree.height, None)
        self.assertNotEqual(real_tree.readonly, True)
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:31,代码来源:test_audit.py


示例3: test_create_and_apply_pending

    def test_create_and_apply_pending(self):
        pending = self.plot.audits().filter(requires_auth=True)

        self.assertEqual(len(pending), 0)

        role = self.commander_user.get_role(self.instance)
        fp, __ = FieldPermission.objects.get_or_create(
            model_name="Plot",
            field_name="udf:Test unauth",
            permission_level=FieldPermission.WRITE_WITH_AUDIT,
            role=role,
            instance=self.instance,
        )

        self.plot.udfs["Test unauth"] = "c"
        self.plot.save_with_user(self.commander_user)

        reloaded_plot = Plot.objects.get(pk=self.plot.pk)

        self.assertEqual(reloaded_plot.udfs["Test unauth"], None)

        pending = self.plot.audits().filter(requires_auth=True)

        self.assertEqual(len(pending), 1)

        fp.permission_level = FieldPermission.WRITE_DIRECTLY
        fp.save()

        approve_or_reject_audit_and_apply(pending[0], self.commander_user, True)

        reloaded_plot = Plot.objects.get(pk=self.plot.pk)

        self.assertEqual(reloaded_plot.udfs["Test unauth"], "c")
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:33,代码来源:test_udfs.py


示例4: test_reject

    def test_reject(self):
        # Setup
        plot_length_orig = self.plot.length
        plot_length_new = plot_length_orig + 1.0

        self.plot.length = plot_length_new
        self.plot.save_with_user(self.pending_user)

        # Generated a single audit
        audit = Audit.objects.filter(requires_auth=True)[0]

        # Should match the model
        self.assertTrue(audit.requires_auth)
        self.assertEqual(audit.model_id, self.plot.pk)

        # Users who don't have direct field access can't reject
        # the edit
        self.assertRaises(AuthorizeException,
                          approve_or_reject_audit_and_apply,
                          audit, self.observer_user, approved=False)

        # User with write access can reject the change
        approve_or_reject_audit_and_apply(
            audit, self.direct_user, approved=False)

        # Reload from DB
        audit = Audit.objects.get(pk=audit.pk)

        # Audit should be marked as processed
        self.assertIsNotNone(audit.ref)

        # Ref'd audit should note rejection
        refaudit = Audit.objects.get(pk=audit.ref.pk)
        self.assertEqual(refaudit.user, self.direct_user)
        self.assertEqual(refaudit.action, Audit.Type.PendingReject)

        # The object shouldn't have changed
        self.assertEqual(Plot.objects.get(pk=self.plot.pk).length,
                         plot_length_orig)

        ohash = Plot.objects.get(pk=self.plot.pk).hash

        # Can't reject a pending edit twice
        self.assertRaises(Exception,
                          approve_or_reject_audit_and_apply,
                          audit, self.direct_user, approved=False)

        # Can't approve a pending edit once rejected
        self.assertRaises(Exception,
                          approve_or_reject_audit_and_apply,
                          audit, self.direct_user, approved=False)

        # Nothing was changed, no audits were added
        self.assertEqual(ohash,
                         Plot.objects.get(pk=self.plot.pk).hash)
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:55,代码来源:test_audit.py


示例5: _approve_or_reject_pending_edit

def _approve_or_reject_pending_edit(
        request, instance, user, pending_edit_id, approve):
    audit = Audit.objects.get(pk=pending_edit_id, instance=instance)
    approve_or_reject_audit_and_apply(audit, user, approve)

    updated_plot = extract_plot_from_audit(audit)

    # Reject remaining audits on specified field if
    # we approved this audit
    # TODO: Should this logic be moved to app_or_rej_audit_and_ap?
    if approve:
        for pending_audit in updated_plot.get_active_pending_audits()\
                                         .filter(field=audit.field):
            approve_or_reject_audit_and_apply(pending_audit, user, False)

    return plot_to_dict(updated_plot, longform=True)
开发者ID:mmcfarland,项目名称:OTM2,代码行数:16,代码来源:views.py


示例6: test_pending_udf_audits

    def test_pending_udf_audits(self):
        UserDefinedFieldDefinition.objects.create(
            instance=self.instance,
            model_type='Plot',
            datatype=json.dumps({'type': 'choice',
                                 'choices': ['1', '2', '3']}),
            iscollection=False,
            name='times climbed')

        set_write_permissions(self.instance, self.commander_user,
                              'Plot', ['udf:times climbed'])

        FieldPermission.objects.create(
            model_name='Plot',
            field_name='udf:times climbed',
            permission_level=FieldPermission.WRITE_WITH_AUDIT,
            role=self.pending_user.get_instance_user(self.instance).role,
            instance=self.instance)

        initial_plot = Plot(geom=self.p1, instance=self.instance)
        initial_plot.udfs['times climbed'] = '2'
        initial_plot.save_with_user(self.pending_user)

        udf_audit = Audit.objects.get(model='Plot', field='udf:times climbed',
                                      model_id=initial_plot.pk)
        approve_or_reject_audit_and_apply(udf_audit, self.commander_user,
                                          approved=True)

        geom_audit = Audit.objects.get(model='Plot', field='geom',
                                       model_id=initial_plot.pk)
        approve_or_reject_audit_and_apply(geom_audit, self.commander_user,
                                          approved=True)

        readonly_audit = Audit.objects.get(model='Plot', field='readonly',
                                           model_id=initial_plot.pk)
        approve_or_reject_audit_and_apply(readonly_audit,
                                          self.commander_user, approved=True)

        insert_audit = Audit.objects.get(model='Plot', field='id',
                                         model_id=initial_plot.pk)

        approve_or_reject_audit_and_apply(insert_audit,
                                          self.commander_user, approved=True)

        new_plot = Plot.objects.get(pk=initial_plot.pk)

        self.assertEqual(new_plot.pk, initial_plot.pk)
        self.assertEqual(new_plot.readonly, False)
        self.assertEqual(new_plot.geom, self.p1)
        self.assertEqual(new_plot.udfs['times climbed'], '2')
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:50,代码来源:test_audit.py


示例7: test_approve_insert_without_required_raises_integrity_error

    def test_approve_insert_without_required_raises_integrity_error(self):
        new_plot = Plot(geom=self.p1, instance=self.instance)
        new_plot.save_with_user(self.pending_user)

        new_tree = Tree(plot=new_plot, instance=self.instance,
                        diameter=10, height=10, readonly=False)
        new_tree.save_with_user(self.pending_user)

        approve_or_reject_audits_and_apply(
            new_plot.audits(),
            self.commander_user, True)

        diameter_audit = Audit.objects.get(model='Tree',
                                           field='diameter',
                                           model_id=new_tree.pk)
        insert_audit = Audit.objects.get(model='Tree',
                                         model_id=new_tree.pk,
                                         field='id')

        approve_or_reject_audit_and_apply(
            diameter_audit, self.commander_user, approved=True)

        self.assertRaises(IntegrityError, approve_or_reject_audit_and_apply,
                          insert_audit, self.commander_user, True)
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:24,代码来源:test_audit.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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