From 9870e69301e853a14d9908a6a8f006968398c96c Mon Sep 17 00:00:00 2001
From: Martin Mares <mj@ucw.cz>
Date: Sat, 16 Jan 2021 16:24:57 +0100
Subject: [PATCH] =?UTF-8?q?M=C3=ADt=20pr=C3=A1vo=20editovat=20m=C3=ADsto?=
=?UTF-8?q?=20a=20p=C5=99idat=20mu=20pod=C5=99=C3=ADzen=C3=A9=20nen=C3=AD?=
=?UTF-8?q?=20tot=C3=A9=C5=BE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
mo/rights.py | 8 ++++++++
mo/web/org_place.py | 1 +
mo/web/templates/org_place.html | 2 +-
3 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/mo/rights.py b/mo/rights.py
index 4f119ef7..40a72a75 100644
--- a/mo/rights.py
+++ b/mo/rights.py
@@ -153,6 +153,14 @@ class Rights:
return True
return False
+ def can_add_place_child(self, place: db.Place):
+ if self.have_right(Right.edit_region):
+ return True
+ elif place.level >= 2 and self.have_right(Right.edit_place):
+ # Can add cities and lower
+ return True
+ return False
+
def can_edit_user(self, user: db.User):
if user.is_admin:
return self.user.is_admin # only admins can edit admins
diff --git a/mo/web/org_place.py b/mo/web/org_place.py
index 8d032472..4192d0b8 100644
--- a/mo/web/org_place.py
+++ b/mo/web/org_place.py
@@ -34,6 +34,7 @@ def org_place(id: int):
return render_template(
'org_place.html', place=place, school=school,
can_edit=rr.can_edit_place(place),
+ can_add_child=rr.can_add_place_child(place),
children=children
)
diff --git a/mo/web/templates/org_place.html b/mo/web/templates/org_place.html
index e5773cf0..1386bfd1 100644
--- a/mo/web/templates/org_place.html
+++ b/mo/web/templates/org_place.html
@@ -49,7 +49,7 @@
{% endfor %}
</table>
{% endif %}
-{% if can_edit %}
+{% if can_add_child %}
<a class="btn btn-primary" href="{{ url_for('org_place_new_child', id=place.place_id) }}">Přidat nové podřízené místo</a>
{% endif %}
{% endif %}
--
GitLab