本文整理汇总了Python中treemap.models.Tree.user_can_create方法的典型用法代码示例。如果您正苦于以下问题:Python Tree.user_can_create方法的具体用法?Python Tree.user_can_create怎么用?Python Tree.user_can_create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类treemap.models.Tree
的用法示例。
在下文中一共展示了Tree.user_can_create方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: WritableTest
# 需要导入模块: from treemap.models import Tree [as 别名]
# 或者: from treemap.models.Tree import user_can_create [as 别名]
class WritableTest(PermissionsTestCase):
def test_plot_is_writable_if_can_create_tree(self):
self.commander_user = make_commander_user(self.instance)
self.commander_role = \
self.commander_user.get_instance_user(self.instance).role
self.tree_only_user = make_user(self.instance)
self.tree_only_role = self.instance.default_role
content_type = ContentType.objects.get_for_model(Tree)
add_tree_perm = Permission.objects.get(content_type=content_type,
codename='add_tree')
self.tree_only_role.instance_permissions.add(add_tree_perm)
self.tree_only_role.save()
self.p = Point(-8515941.0, 4953519.0)
self.plot = Plot(instance=self.instance, width=12, geom=self.p)
self.plot.save_with_user(self.commander_user)
plot2 = Plot(instance=self.instance, width=12, geom=self.p)
self.assertRaises(AuthorizeException,
plot2.save_with_user,
self.tree_only_user)
self.tree = Tree(instance=self.instance, plot=self.plot)
self.tree.save_with_user(self.tree_only_user)
self.assertTrue(self.tree.user_can_create(self.tree_only_user))
# The plot should be writable if the user can create a tree
self.assertTrue(perms.map_feature_is_writable(
self.tree_only_role,
self.plot))