Don't allow edit/delete of rows, if master view says so
also fix "back to parent" link when viewing row
This commit is contained in:
parent
abea50427e
commit
31df41283c
|
@ -8,7 +8,7 @@
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
<%def name="context_menu_items()">
|
<%def name="context_menu_items()">
|
||||||
<li>${h.link_to("Back to {}".format(parent_model_title), index_url)}</li>
|
<li>${h.link_to("Back to {}".format(parent_model_title), instance_url)}</li>
|
||||||
% if master.rows_editable and instance_editable and request.has_perm('{}.edit'.format(permission_prefix)):
|
% if master.rows_editable and instance_editable and request.has_perm('{}.edit'.format(permission_prefix)):
|
||||||
<li>${h.link_to("Edit this {}".format(model_title), action_url('edit', instance))}</li>
|
<li>${h.link_to("Edit this {}".format(model_title), action_url('edit', instance))}</li>
|
||||||
% endif
|
% endif
|
||||||
|
|
|
@ -3324,6 +3324,9 @@ class MasterView(View):
|
||||||
"""
|
"""
|
||||||
self.editing = True
|
self.editing = True
|
||||||
row = self.get_row_instance()
|
row = self.get_row_instance()
|
||||||
|
if not self.row_editable(row):
|
||||||
|
raise self.redirect(self.get_row_action_url('view', row))
|
||||||
|
|
||||||
form = self.make_row_form(row)
|
form = self.make_row_form(row)
|
||||||
|
|
||||||
if self.request.method == 'POST':
|
if self.request.method == 'POST':
|
||||||
|
@ -3407,9 +3410,10 @@ class MasterView(View):
|
||||||
"""
|
"""
|
||||||
Desktop view which can "delete" a sub-row from the parent.
|
Desktop view which can "delete" a sub-row from the parent.
|
||||||
"""
|
"""
|
||||||
row = self.Session.query(self.model_row_class).get(self.request.matchdict['row_uuid'])
|
row = self.get_row_instance()
|
||||||
if not row:
|
if not self.row_deletable(row):
|
||||||
raise self.notfound()
|
raise self.redirect(self.get_row_action_url('view', row))
|
||||||
|
|
||||||
self.delete_row_object(row)
|
self.delete_row_object(row)
|
||||||
return self.redirect(self.get_action_url('view', self.get_parent(row)))
|
return self.redirect(self.get_action_url('view', self.get_parent(row)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue