-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPermissions.py
More file actions
48 lines (39 loc) · 1.09 KB
/
Permissions.py
File metadata and controls
48 lines (39 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
defaults = {
"can_view_admin": False,
"can_view_user": True,
"can_use_pass": True,
"can_view_dev": False,
"can_submit_issues": False,
"can_view_passes" : False
}
class Permission:
def __init__(self, **kwargs):
for i in defaults: #Make sure we have defaults
setattr(self, i, defaults[i])
for i in kwargs: #Allow changing the defaults
setattr(self, i, kwargs[i])
def dict(self):
dict = {}
for i in dir(self):
if not i.startswith("__") and not callable(self.__getattribute__(i)):
dict[i] = self.__getattribute__(i)
return dict
def load_dict(self, dict):
for i in dict:
self.__setattr__(i, dict[i])
perms = {
"user":
Permission(),
"dev":
Permission(can_view_admin=True, can_view_dev=True, can_submit_issues=True, can_view_passes=True),
"admin":
Permission(can_view_admin=True, can_submit_issues=True, can_view_passes=True),
"tester":
Permission(can_submit_issues=True)
}
def get_permissions(perm):
perm = perm.lower()
if perm not in perms:
return perms["user"] #Default to user perms
else:
return perms[perm]