我正在使用 django 创建一个基于 Web 的应用程序。此应用程序将被多个客户用作服务。
它有几个表示层次关系的模型/表。根据这种层次关系授予用户访问权限 - 前县 -> 学校 -> 部门 -> 教室。
因此,有权访问部门的用户可以访问其中的所有教室等
我的问题是如何使这个权限系统可以跨客户端配置。该应用程序应该是一个新客户端来定义任意级别 - 前国家 -> 州 -> 城市 -> 学校 -> 班级。
关于什么是好方法的任何想法?
What about storing the new levels in a prefix tree? you could use each level as a node of a branch of the tree.
When a new user wants do define a new level, the prefix tree will be updated starting from the level where the user belongs. If your problem is just about giving visibility to the user of the sub-branch of the level where he belongs, this should work.
A similar approach, maybe less intuitive, is to give to each level a number (or alpha-numeric value), so that in the end a user associated to the level "state" in your example, has a level code of 23 (let's say: "ex-country": 2 and "state": 3), so that he can add sub-levels starting with the prefix 23.