Skip to content
Snippets Groups Projects
Commit 478b89ae authored by Martin Mareš's avatar Martin Mareš
Browse files

rights: fixup!

parent 1d20c08e
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !19. Comments created here will be created in the context of that merge request.
......@@ -133,8 +133,9 @@ class Rights:
rights: Set[Right]
def __repr__(self):
rs = " ".join([r.role.name for r in self.roles])
return f"Rights(uid={self.user.user_id} is_admin={self.user.is_admin} roles=<{rs}>)"
ros = " ".join([r.role.name for r in self.roles])
ris = " ".join([r.name for r in self.rights])
return f"Rights(uid={self.user.user_id} is_admin={self.user.is_admin} roles=<{ros}> rights=<{ris}>)"
def have_right(self, right: Right):
if self.user.is_admin:
......@@ -166,11 +167,13 @@ class Gatekeeper:
nebo právě zpracovávaný job."""
user: db.User
roles: List[db.UserRole]
parent_cache: Dict[int, List[db.Place]]
rights_cache: Dict[Tuple[Optional[int], Optional[int], Optional[str], Optional[int], Optional[db.RoleType]], Rights]
def __init__(self, user: db.User):
self.user = user
self.roles = user.roles
assert user.is_org or user.is_admin
self.parent_cache = {}
self.rights_cache = {}
......@@ -212,11 +215,11 @@ class Gatekeeper:
# XXX: This might be faster...
if place is None:
for role in rights.roles:
for role in self.roles:
try_role(role, None)
else:
for at in self.get_parents(place):
for role in rights.roles:
for role in self.roles:
try_role(role, at)
return rights
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment