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

Gatekeeper: přidána funkce is_ancestor_of

S právy moc společného nemá, ale gatekeeper se stará o obecné
kešování předků.
parent 7acb33d7
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !95. Comments created here will be created in the context of that merge request.
...@@ -307,6 +307,11 @@ class Gatekeeper: ...@@ -307,6 +307,11 @@ class Gatekeeper:
self.parent_cache[pid] = db.get_place_parents(place) self.parent_cache[pid] = db.get_place_parents(place)
return self.parent_cache[pid] return self.parent_cache[pid]
def is_ancestor_of(self, ancestor: db.Place, of: db.Place) -> bool:
parents = self.get_parents(of)
parent_ids = set(p.place_id for p in parents)
return ancestor.place_id in parent_ids
def rights_for( def rights_for(
self, place: Optional[db.Place] = None, year: Optional[int] = None, self, place: Optional[db.Place] = None, year: Optional[int] = None,
cat: Optional[str] = None, seq: Optional[int] = None, cat: Optional[str] = None, seq: Optional[int] = None,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment