diff --git a/mo/rights.py b/mo/rights.py index 4f119ef7f7d29084e92dbc8eb31e8efdc4030da1..40a72a75b539e5a81afc0fca81c804ef38c89aa7 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 8d032472d41fd7e0db2fad49c340b5296238e7ae..4192d0b8a7045b77c6e20682460fa283bed1ff05 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 e5773cf08cfdff099193abd7084549529b279c24..1386bfd1ec407988fcc38dd036e94acf1884fe7f 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 %}