Fix row-level visibility for grid edit action

This commit is contained in:
Lance Edgar 2016-09-19 16:32:18 -05:00
parent cff19f38a3
commit a77f41debf

View file

@ -695,11 +695,16 @@ class MasterView(View):
actions = [] actions = []
prefix = self.get_permission_prefix() prefix = self.get_permission_prefix()
if self.editable and self.request.has_perm('{}.edit'.format(prefix)): if self.editable and self.request.has_perm('{}.edit'.format(prefix)):
actions.append(self.make_action('edit', icon='pencil')) actions.append(self.make_action('edit', icon='pencil', url=self.default_edit_url))
if self.deletable and self.request.has_perm('{}.delete'.format(prefix)): if self.deletable and self.request.has_perm('{}.delete'.format(prefix)):
actions.append(self.make_action('delete', icon='trash', url=self.default_delete_url)) actions.append(self.make_action('delete', icon='trash', url=self.default_delete_url))
return actions return actions
def default_edit_url(self, row, i=None):
if self.editable_instance(row):
return self.request.route_url('{}.edit'.format(self.get_route_prefix()),
**self.get_action_route_kwargs(row))
def default_delete_url(self, row, i=None): def default_delete_url(self, row, i=None):
if self.deletable_instance(row): if self.deletable_instance(row):
return self.request.route_url('{}.delete'.format(self.get_route_prefix()), return self.request.route_url('{}.delete'.format(self.get_route_prefix()),