From 3a1db0b113a6ab32926cf6070e7cc89459f83041 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Fri, 15 Oct 2021 08:50:26 +0300 Subject: Add immutable data structures for admin and data access roles --- wqflask/wqflask/resource_manager.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/wqflask/wqflask/resource_manager.py b/wqflask/wqflask/resource_manager.py index 330600ed..7f4718f0 100644 --- a/wqflask/wqflask/resource_manager.py +++ b/wqflask/wqflask/resource_manager.py @@ -2,7 +2,7 @@ import redis import json import functools -from enum import Enum +from enum import Enum, unique @@ -23,8 +23,18 @@ class OrderedEnum(Enum): return NotImplemented +@unique +class DataRole(OrderedEnum): + NO_ACCESS = "no-access" + VIEW = "view" + EDIT = "edit" +@unique +class AdminRole(OrderedEnum): + NOT_ADMIN = "not-admin" + EDIT_ACCESS = "edit-access" + EDIT_ADMINS = "edit-admins" def get_user_membership(conn: redis.Redis, user_id: str, group_id: str) -> Dict: -- cgit v1.2.3