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

Python tests.set_write_permissions函数代码示例

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

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



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

示例1: setUp

    def setUp(self):
        super(ExportTreeTaskTest, self).setUp()

        set_write_permissions(self.instance, self.user,
                              'Plot', ['udf:Test choice'])
        set_write_permissions(self.instance, self.user,
                              'Tree', ['udf:Test int'])

        UserDefinedFieldDefinition.objects.create(
            instance=self.instance,
            model_type='Plot',
            datatype=json.dumps({'type': 'choice',
                                 'choices': ['a', 'b', 'c']}),
            iscollection=False,
            name='Test choice')

        UserDefinedFieldDefinition.objects.create(
            instance=self.instance,
            model_type='Tree',
            datatype=json.dumps({'type': 'int'}),
            iscollection=False,
            name='Test int')

        p = Plot(geom=self.instance.center, instance=self.instance,
                 address_street="123 Main Street")
        p.udfs['Test choice'] = 'a'

        p.save_with_user(self.user)

        t = Tree(plot=p, instance=self.instance, diameter=2)
        t.udfs['Test int'] = 4

        t.save_with_user(self.user)
开发者ID:RickMohr,项目名称:otm-core,代码行数:33,代码来源:tests.py


示例2: setUp

    def setUp(self):
        self.p = Point(-8515941.0, 4953519.0)
        self.instances = [
            make_instance(point=self.p),
            make_instance(point=self.p)
        ]
        self.commander_users = [
            make_commander_user(i, username='commander%d' % i.pk)
            for i in self.instances]
        for i in range(len(self.instances)):
            set_write_permissions(self.instances[i], self.commander_users[i],
                                  'Plot', ['udf:Test choice'])
        self.choice_udfds = [
            UserDefinedFieldDefinition.objects.create(
                instance=i,
                model_type='Plot',
                datatype=json.dumps({'type': 'choice',
                                     'choices': ['a', 'b', 'c']}),
                iscollection=False,
                name='Test choice') for i in self.instances]

        self.plots = [
            Plot(geom=self.p, instance=i) for i in self.instances]

        for i in range(len(self.plots)):
            self.plots[i].save_with_user(self.commander_users[i])

        psycopg2.extras.register_hstore(connection.cursor(), globally=True)
开发者ID:riromu,项目名称:otm-core,代码行数:28,代码来源:test_udfs.py


示例3: setUp

    def setUp(self):
        super(ExportTreeTaskTest, self).setUp()

        set_write_permissions(self.instance, self.user, "Plot", ["udf:Test choice"])
        set_write_permissions(self.instance, self.user, "Tree", ["udf:Test int"])

        UserDefinedFieldDefinition.objects.create(
            instance=self.instance,
            model_type="Plot",
            datatype=json.dumps({"type": "choice", "choices": ["a", "b", "c"]}),
            iscollection=False,
            name="Test choice",
        )

        UserDefinedFieldDefinition.objects.create(
            instance=self.instance,
            model_type="Tree",
            datatype=json.dumps({"type": "int"}),
            iscollection=False,
            name="Test int",
        )

        p = Plot(geom=self.instance.center, instance=self.instance, address_street="123 Main Street")
        p.udfs["Test choice"] = "a"

        p.save_with_user(self.user)

        t = Tree(plot=p, instance=self.instance, diameter=2)
        t.udfs["Test int"] = 4

        t.save_with_user(self.user)
开发者ID:nvh3010,项目名称:otm-core,代码行数:31,代码来源:tests.py


示例4: _setup_collection_udfs

    def _setup_collection_udfs(self):
        self.plotstew = make_collection_udf(self.instance, model='Plot',
                                            datatype=COLLECTION_UDF_DATATYPE)
        self.treestew = make_collection_udf(self.instance, model='Tree',
                                            datatype=COLLECTION_UDF_DATATYPE)

        set_write_permissions(self.instance, self.commander, 'Plot',
                              [self.plotstew.canonical_name])
        set_write_permissions(self.instance, self.commander, 'Tree',
                              [self.treestew.canonical_name])

        p1, _ = self.create_tree_and_plot(
            plotudfs={self.plotstew.name:
                      [{'action': 'water', 'date': "2013-08-06 00:00:00"},
                       {'action': 'prune', 'date': "2013-09-15 00:00:00"}]},
            treeudfs={self.treestew.name:
                      [{'action': 'water', 'date': "2013-05-15 00:00:00"},
                       {'action': 'water', 'date': None}]})

        p2, _ = self.create_tree_and_plot(
            plotudfs={self.plotstew.name: [
                {'action': 'water', 'date': "2014-11-26 00:00:00"}]},
            treeudfs={self.treestew.name: [
                {'action': 'prune', 'date': "2014-06-23 00:00:00"}]})

        p3, _ = self.create_tree_and_plot(
            plotudfs={self.plotstew.name: [
                {'action': 'water', 'date': "2015-08-05 00:00:00"},
                {'action': 'prune', 'date': "2015-04-13 00:00:00"}]},
            treeudfs={self.treestew.name:
                      [{'action': 'prune', 'date': "2013-06-19 00:00:00"},
                       {'action': 'water', 'date': None}]})

        return (p.pk for p in [p1, p2, p3])
开发者ID:barbaralluz,项目名称:otm-core,代码行数:34,代码来源:test_search.py


示例5: test_bulk_update_scalar_choices

    def test_bulk_update_scalar_choices(self):
        plot_udfd = UserDefinedFieldDefinition.objects.create(
            instance=self.instance,
            model_type='Plot',
            datatype=json.dumps({'type': 'choice',
                                 'choices': ['a', 'b']}),
            iscollection=False,
            name='Test plot choice')

        tree_udfd = UserDefinedFieldDefinition.objects.create(
            instance=self.instance,
            model_type='Tree',
            datatype=json.dumps({'type': 'choice',
                                 'choices': ['x', 'y']}),
            iscollection=False,
            name='Test tree choice')

        set_write_permissions(self.instance, self.user,
                              'Plot', ['udf:Test plot choice'])

        set_write_permissions(self.instance, self.user,
                              'Tree', ['udf:Test tree choice'])

        params = {'choice_changes': [
            {'id': str(plot_udfd.pk), 'changes': [
                {"action": "rename",
                 "original_value": "b",
                 "new_value": "B",
                 "subfield": ""},
                {"action": "add",
                 "original_value": "",
                 "new_value": "p",
                 "subfield": ""}]},
            {'id': str(tree_udfd.pk), 'changes': [
                {"action": "rename",
                 "original_value": "y",
                 "new_value": "Y",
                 "subfield": ""},
                {"action": "add",
                 "original_value": "",
                 "new_value": "q",
                 "subfield": ""}]}]}
        request = self._make_put_request(params)
        udf_bulk_update(request, self.instance)

        plot_udfd.refresh_from_db()
        tree_udfd.refresh_from_db()

        plot_datatype = json.loads(plot_udfd.datatype)
        tree_datatype = json.loads(tree_udfd.datatype)

        self.assertIn('choices', plot_datatype)
        self.assertEqual(set(plot_datatype['choices']), {'a', 'B', 'p'})

        self.assertIn('choices', tree_datatype)
        self.assertEqual(set(tree_datatype['choices']), {'x', 'Y', 'q'})
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:56,代码来源:test_udf.py


示例6: _setup_collection_udfs

def _setup_collection_udfs(instance, user):
    plotstew = make_collection_udf(instance, model='Plot',
                                   datatype=COLLECTION_UDF_DATATYPE)
    treestew = make_collection_udf(instance, model='Tree',
                                   datatype=COLLECTION_UDF_DATATYPE)

    set_write_permissions(instance, user, 'Plot', [plotstew.canonical_name])
    set_write_permissions(instance, user, 'Tree', [treestew.canonical_name])

    return plotstew, treestew
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:10,代码来源:test_search.py


示例7: setUp

    def setUp(self):
        self.p = Point(-8515941.0, 4953519.0)
        self.instance = make_instance(point=self.p)

        self.udf = make_collection_udf(self.instance, "Stewardship")

        self.commander_user = make_commander_user(self.instance)
        set_write_permissions(self.instance, self.commander_user, "Plot", ["udf:Stewardship"])

        self.plot = Plot(geom=self.p, instance=self.instance)
        self.plot.save_with_user(self.commander_user)
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:11,代码来源:test_udfs.py


示例8: setUp

    def setUp(self):
        self.instance = make_instance()
        self.p = Point(-8515941.0, 4953519.0)

        make_collection_udf(self.instance, 'Stewardship')

        self.commander_user = make_commander_user(self.instance)
        set_write_permissions(self.instance, self.commander_user,
                              'Plot', ['udf:Stewardship'])

        self.plot = Plot(geom=self.p, instance=self.instance)
        self.plot.save_with_user(self.commander_user)
开发者ID:heath,项目名称:OTM2,代码行数:12,代码来源:udfs.py


示例9: 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


示例10: setUp

    def setUp(self):
        User._system_user.save_base()

        self.instance = make_instance()
        self.user = make_commander_user(self.instance)

        set_write_permissions(self.instance, self.user,
                              'Plot', ['udf:Test choice'])

        self.udf = UserDefinedFieldDefinition.objects.create(
            instance=self.instance,
            model_type='Plot',
            datatype=json.dumps({'type': 'choice',
                                 'choices': ['a', 'b', 'c']}),
            iscollection=False,
            name='Test choice')
开发者ID:nvh3010,项目名称:otm-core,代码行数:16,代码来源:test_udfs.py


示例11: _setup_udfs

    def _setup_udfs(self):
        set_write_permissions(self.instance, self.commander,
                              'Plot',
                              ['udf:Test string', 'udf:Test date'])
        set_write_permissions(self.instance, self.commander,
                              'Tree',
                              ['udf:Test float'])

        UserDefinedFieldDefinition.objects.create(
            instance=self.instance,
            model_type='Plot',
            datatype=json.dumps({'type': 'string'}),
            iscollection=False,
            name='Test string')

        UserDefinedFieldDefinition.objects.create(
            instance=self.instance,
            model_type='Plot',
            datatype=json.dumps({'type': 'date'}),
            iscollection=False,
            name='Test date')

        UserDefinedFieldDefinition.objects.create(
            instance=self.instance,
            model_type='Tree',
            datatype=json.dumps({'type': 'float'}),
            iscollection=False,
            name='Test float')

        psycopg2.extras.register_hstore(connection.cursor(), globally=True)

        p1, _ = self.create_tree_and_plot(
            plotudfs={'Test string': 'testing foo',
                      'Test date': datetime(2010, 1, 9)},
            treeudfs={'Test float': 9.2})

        p2, _ = self.create_tree_and_plot(
            plotudfs={'Test string': 'testing baz or fish',
                      'Test date': datetime(2012, 1, 9)},
            treeudfs={'Test float': 12.0})

        p3, _ = self.create_tree_and_plot(
            plotudfs={'Test string': 'baz',
                      'Test date': datetime(2014, 1, 9)},
            treeudfs={'Test float': 2.2})

        return (p.pk for p in [p1, p2, p3])
开发者ID:barbaralluz,项目名称:otm-core,代码行数:47,代码来源:test_search.py


示例12: test_delete_udf_deletes_perms_value

    def test_delete_udf_deletes_perms_value(self):
        set_write_permissions(self.instance, self.commander_user, "Plot", ["udf:Test string"])

        udf_def = UserDefinedFieldDefinition(
            instance=self.instance,
            model_type="Plot",
            datatype=json.dumps({"type": "string"}),
            iscollection=False,
            name="Test string",
        )

        udf_def.save()

        qs = FieldPermission.objects.filter(field_name="udf:Test string", model_name="Plot")

        self.assertTrue(qs.exists())
        udf_def.delete()
        self.assertFalse(qs.exists())
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:18,代码来源:test_udfs.py


示例13: test_parse_collection_udf_nested_pass_numeric_comparison

    def test_parse_collection_udf_nested_pass_numeric_comparison(self):
        self._setup_tree_and_collection_udf()
        agility = make_collection_udf(self.instance, model='Tree',
                                      name='Agility',
                                      datatype=[{'type': 'float',
                                                 'name': 'current'}])
        set_write_permissions(self.instance, self.commander,
                              'Tree', ['udf:Agility'])
        new_tree = Tree(instance=self.instance, plot=self.plot)
        new_tree.udfs[agility.name] = [{'current': '1.5'}]
        new_tree.save_with_user(self.commander)

        pred = search._parse_query_dict(
            {'udf:tree:%s.current' % agility.pk: {'MIN': 1}},
            mapping=search.DEFAULT_MAPPING)

        target = ('AND', {('tree__id__in', (new_tree.pk,))})

        self.assertEqual(destructure_query_set(pred), target)
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:19,代码来源:test_search.py


示例14: test_delete_udf_deletes_perms_collection

    def test_delete_udf_deletes_perms_collection(self):
        set_write_permissions(self.instance, self.commander_user, "Plot", ["udf:Test choice"])

        udf_def = UserDefinedFieldDefinition(
            instance=self.instance,
            model_type="Plot",
            datatype=json.dumps(
                [{"name": "pick", "type": "choice", "choices": ["a", "b", "c"]}, {"type": "int", "name": "height"}]
            ),
            iscollection=True,
            name="Test choice",
        )

        udf_def.save()

        qs = FieldPermission.objects.filter(field_name="udf:Test choice", model_name="Plot")

        self.assertTrue(qs.exists())
        udf_def.delete()
        self.assertFalse(qs.exists())
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:20,代码来源:test_udfs.py


示例15: test_delete_udf_deletes_perms_value

    def test_delete_udf_deletes_perms_value(self):
        set_write_permissions(self.instance, self.commander_user,
                              'Plot', ['udf:Test string'])

        udf_def = UserDefinedFieldDefinition(
            instance=self.instance,
            model_type='Plot',
            datatype=json.dumps({'type': 'string'}),
            iscollection=False,
            name='Test string')

        udf_def.save()

        qs = FieldPermission.objects.filter(
            field_name='udf:Test string',
            model_name='Plot')

        self.assertTrue(qs.exists())
        udf_def.delete()
        self.assertFalse(qs.exists())
开发者ID:atogle,项目名称:OTM2,代码行数:20,代码来源:udfs.py


示例16: _setup_tree_and_collection_udf

    def _setup_tree_and_collection_udf(self):
        instance = make_instance()

        self.plotstew = make_collection_udf(instance, model='Plot',
                                            datatype=COLLECTION_UDF_DATATYPE)
        self.treestew = make_collection_udf(instance, model='Tree',
                                            datatype=COLLECTION_UDF_DATATYPE)

        commander = make_commander_user(instance)
        set_write_permissions(instance, commander, 'Plot', ['udf:Stewardship'])
        set_write_permissions(instance, commander, 'Tree', ['udf:Stewardship'])

        d1 = {'action': 'prune', 'date': "2014-05-3 00:00:00"}
        d2 = {'action': 'water', 'date': "2014-04-29 00:00:00"}

        self.plot = Plot(instance=instance, geom=instance.center)
        self.plot.udfs[self.plotstew.name] = [d1]
        self.plot.save_with_user(commander)

        self.tree = Tree(instance=instance, plot=self.plot)
        self.tree.udfs[self.treestew.name] = [d2]
        self.tree.save_with_user(commander)
开发者ID:barbaralluz,项目名称:otm-core,代码行数:22,代码来源:test_search.py


示例17: setUp

    def setUp(self):
        # Just in case - cleanup other bad test cases
        Instance.objects.all().delete()

        self.instance = make_instance()
        plot_stew, tree_stew = tuple(
            create_stewardship_udfs(self.instance))
        self.cudf = plot_stew
        self.user = make_commander_user(self.instance)

        self.udf = UserDefinedFieldDefinition.objects.create(
            instance=self.instance,
            model_type='Plot',
            datatype=json.dumps({'type': 'choice',
                                 'choices': ['a', 'b', 'c']}),
            iscollection=False,
            name='Test choice')

        self.plot = Plot(instance=self.instance, geom=self.instance.center)

        set_write_permissions(self.instance, self.user,
                              'Plot', ['udf:Test choice', 'udf:Stewardship'])
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:22,代码来源:test_udf.py


示例18: setUp

    def setUp(self):
        self.instance = make_instance()
        self.commander_user = make_commander_user(self.instance)
        set_write_permissions(self.instance, self.commander_user,
                              'Plot', ['udf:Test choice'])

        self.p = Point(-8515941.0, 4953519.0)

        UserDefinedFieldDefinition.objects.create(
            instance=self.instance,
            model_type='Plot',
            datatype=json.dumps({'type': 'choice',
                                 'choices': ['a', 'b', 'c']}),
            iscollection=False,
            name='Test choice')

        UserDefinedFieldDefinition.objects.create(
            instance=self.instance,
            model_type='Plot',
            datatype=json.dumps({'type': 'string'}),
            iscollection=False,
            name='Test unauth')

        UserDefinedFieldDefinition.objects.create(
            instance=self.instance,
            model_type='Plot',
            datatype=json.dumps([{'type': 'choice',
                                  'name': 'a choice',
                                  'choices': ['a', 'b', 'c']},
                                 {'type': 'string',
                                  'name': 'a string'}]),
            iscollection=True,
            name='Test collection')

        self.plot = Plot(geom=self.p, instance=self.instance)
        self.plot.save_with_user(self.commander_user)

        psycopg2.extras.register_hstore(connection.cursor(), globally=True)
开发者ID:danmcginnis,项目名称:OTM2,代码行数:38,代码来源:udfs.py


示例19: test_delete_udf_deletes_perms_collection

    def test_delete_udf_deletes_perms_collection(self):
        set_write_permissions(self.instance, self.commander_user,
                              'Plot', ['udf:Test choice'])

        udf_def = UserDefinedFieldDefinition(
            instance=self.instance,
            model_type='Plot',
            datatype=json.dumps([{'name': 'pick',
                                  'type': 'choice',
                                  'choices': ['a', 'b', 'c']},
                                 {'type': 'int',
                                  'name': 'height'}]),
            iscollection=True,
            name='Test choice')

        udf_def.save()

        qs = FieldPermission.objects.filter(
            field_name='udf:Test choice',
            model_name='Plot')

        self.assertTrue(qs.exists())
        udf_def.delete()
        self.assertFalse(qs.exists())
开发者ID:atogle,项目名称:OTM2,代码行数:24,代码来源:udfs.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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