summaryrefslogtreecommitdiffstats
path: root/ogcp/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'ogcp/models.py')
-rw-r--r--ogcp/models.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/ogcp/models.py b/ogcp/models.py
index d27b869..ef050ed 100644
--- a/ogcp/models.py
+++ b/ogcp/models.py
@@ -8,7 +8,18 @@
from flask_login import UserMixin
class User(UserMixin):
- def __init__(self, username, scopes, admin):
+ def __init__(self, username, scopes, admin, permissions):
self.id = username
self.scopes = scopes
self.admin = admin
+ self.permissions = permissions
+
+ def get_permission(self, target, action):
+ if self.admin or not target in self.permissions:
+ return True
+ return self.permissions[target].get(action, True)
+
+ def target_is_disabled(self, target):
+ if self.admin or not target in self.permissions or not self.permissions[target]:
+ return False
+ return all(value == False for value in self.permissions[target].values())