[Answer]-Creating a configurable permissions system in django

1đź‘Ť

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.

👤drekyn

Leave a comment