From 26b78c5160aab2fcc807db6f3ccb7a75d9554971 Mon Sep 17 00:00:00 2001
From: Martin Mares <mj@ucw.cz>
Date: Sat, 25 Sep 2021 13:08:01 +0200
Subject: [PATCH] =?UTF-8?q?Gatekeeper:=20p=C5=99id=C3=A1na=20funkce=20is?=
 =?UTF-8?q?=5Fancestor=5Fof?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

S právy moc společného nemá, ale gatekeeper se stará o obecné
kešování předků.
---
 mo/rights.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/mo/rights.py b/mo/rights.py
index b052390d..f0854a97 100644
--- a/mo/rights.py
+++ b/mo/rights.py
@@ -307,6 +307,11 @@ class Gatekeeper:
             self.parent_cache[pid] = db.get_place_parents(place)
         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(
             self, place: Optional[db.Place] = None, year: Optional[int] = None,
             cat: Optional[str] = None, seq: Optional[int] = None,
-- 
GitLab