本文整理汇总了Python中treemap.tests.set_write_permissions函数的典型用法代码示例。如果您正苦于以下问题:Python set_write_permissions函数的具体用法?Python set_write_permissions怎么用?Python set_write_permissions使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_write_permissions函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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)
示例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)
示例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])
示例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'})
示例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
示例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)
示例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)
示例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')
示例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')
示例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])
示例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())
示例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)
示例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())
示例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())