Skip to content
Snippets Groups Projects

Reforma vyhodnocování práv

Closed Martin Mareš requested to merge mj/rights into master
1 unresolved thread
1 file
+ 8
16
Compare changes
  • Side-by-side
  • Inline
+ 8
16
@@ -29,13 +29,10 @@ def org_place(id: int):
school = None
children = sorted(place.children, key=lambda p: locale.strxfrm(p.name))
rr = mo.rights.Rights(g.user)
rr.get_for(place)
rr = g.gatekeeper.rights_for(place)
return render_template(
'org_place.html', place=place, school=school,
rights=sorted(rr.current_rights, key=lambda r: r. name),
can_edit=rr.can_edit_place(place),
children=children
)
@@ -79,9 +76,7 @@ def org_place_edit(id: int):
if not place:
raise werkzeug.exceptions.NotFound()
rr = mo.rights.Rights(g.user)
rr.get_for(place)
rr = g.gatekeeper.rights_for(place)
if not rr.can_edit_place(place):
raise werkzeug.exceptions.Forbidden()
@@ -177,8 +172,7 @@ def org_place_move(id: int):
place = sess.query(db.Place).get(id)
if not place:
raise werkzeug.exceptions.NotFound()
rr = mo.rights.Rights(g.user)
rr.get_for(place)
rr = g.gatekeeper.rights_for(place)
if not rr.can_edit_place(place):
raise werkzeug.exceptions.Forbidden()
@@ -240,8 +234,7 @@ def org_place_delete(id: int):
place = sess.query(db.Place).get(id)
if not place:
raise werkzeug.exceptions.NotFound()
rr = mo.rights.Rights(g.user)
rr.get_for(place)
rr = g.gatekeeper.rights_for(place)
if not rr.can_edit_place(place):
raise werkzeug.exceptions.Forbidden()
@@ -288,8 +281,7 @@ def org_place_new_child(id: int):
parent_place = sess.query(db.Place).get(id)
if not parent_place:
raise werkzeug.exceptions.NotFound()
rr = mo.rights.Rights(g.user)
rr.get_for(parent_place)
rr = g.gatekeeper.rights_for(parent_place)
if not rr.can_edit_place(parent_place):
raise werkzeug.exceptions.Forbidden()
if not parent_place.can_have_child():
@@ -360,10 +352,10 @@ def org_place_rights(id: int):
.all())
roles.sort(key=lambda r: (mo.rights.role_order_by_type[r.role], r.user.sort_key()))
rr = mo.rights.Rights(g.user)
rr.get_for(place)
rr = g.gatekeeper.rights_for(place)
rights = sorted(rr.rights, key=lambda r: r.name)
return render_template(
'org_place_rights.html', place=place, rights=rr.current_rights,
'org_place_rights.html', place=place, rights=rights,
roles=roles, roles_by_type=mo.rights.roles_by_type
)
Loading