Use self.has_perm()
within MasterView
This commit is contained in:
parent
1e0f707a6d
commit
6c228a59f2
|
@ -372,14 +372,12 @@ class MasterView(View):
|
||||||
Return a dictionary of kwargs to be passed to the factory when creating
|
Return a dictionary of kwargs to be passed to the factory when creating
|
||||||
new grid instances.
|
new grid instances.
|
||||||
"""
|
"""
|
||||||
permission_prefix = self.get_permission_prefix()
|
|
||||||
|
|
||||||
checkboxes = self.checkboxes
|
checkboxes = self.checkboxes
|
||||||
if not checkboxes and self.mergeable and self.request.has_perm('{}.merge'.format(permission_prefix)):
|
if not checkboxes and self.mergeable and self.has_perm('merge'):
|
||||||
checkboxes = True
|
checkboxes = True
|
||||||
if not checkboxes and self.supports_set_enabled_toggle and self.request.has_perm('{}.enable_disable_set'.format(permission_prefix)):
|
if not checkboxes and self.supports_set_enabled_toggle and self.has_perm('enable_disable_set'):
|
||||||
checkboxes = True
|
checkboxes = True
|
||||||
if not checkboxes and self.set_deletable and self.request.has_perm('{}.delete_set'.format(permission_prefix)):
|
if not checkboxes and self.set_deletable and self.has_perm('delete_set'):
|
||||||
checkboxes = True
|
checkboxes = True
|
||||||
|
|
||||||
defaults = {
|
defaults = {
|
||||||
|
@ -468,8 +466,6 @@ class MasterView(View):
|
||||||
"""
|
"""
|
||||||
Return a dict of kwargs to be used when constructing a new rows grid.
|
Return a dict of kwargs to be used when constructing a new rows grid.
|
||||||
"""
|
"""
|
||||||
permission_prefix = self.get_permission_prefix()
|
|
||||||
|
|
||||||
defaults = {
|
defaults = {
|
||||||
'model_class': self.model_row_class,
|
'model_class': self.model_row_class,
|
||||||
'width': 'full',
|
'width': 'full',
|
||||||
|
@ -497,7 +493,7 @@ class MasterView(View):
|
||||||
actions.append(self.make_action('edit', icon=icon, url=self.row_edit_action_url))
|
actions.append(self.make_action('edit', icon=icon, url=self.row_edit_action_url))
|
||||||
|
|
||||||
# delete action
|
# delete action
|
||||||
if self.rows_deletable and self.request.has_perm('{}.delete_row'.format(permission_prefix)):
|
if self.rows_deletable and self.has_perm('delete_row'):
|
||||||
actions.append(self.make_action('delete', icon='trash', url=self.row_delete_action_url))
|
actions.append(self.make_action('delete', icon='trash', url=self.row_delete_action_url))
|
||||||
defaults['delete_speedbump'] = self.rows_deletable_speedbump
|
defaults['delete_speedbump'] = self.rows_deletable_speedbump
|
||||||
|
|
||||||
|
@ -2480,9 +2476,8 @@ class MasterView(View):
|
||||||
Return a list of 'main' actions for the grid.
|
Return a list of 'main' actions for the grid.
|
||||||
"""
|
"""
|
||||||
actions = []
|
actions = []
|
||||||
prefix = self.get_permission_prefix()
|
|
||||||
use_buefy = self.get_use_buefy()
|
use_buefy = self.get_use_buefy()
|
||||||
if self.viewable and self.request.has_perm('{}.view'.format(prefix)):
|
if self.viewable and self.has_perm('view'):
|
||||||
url = self.get_view_index_url if self.use_index_links else None
|
url = self.get_view_index_url if self.use_index_links else None
|
||||||
icon = 'eye' if use_buefy else 'zoomin'
|
icon = 'eye' if use_buefy else 'zoomin'
|
||||||
actions.append(self.make_action('view', icon=icon, url=url))
|
actions.append(self.make_action('view', icon=icon, url=url))
|
||||||
|
@ -2497,16 +2492,15 @@ class MasterView(View):
|
||||||
Return a list of 'more' actions for the grid.
|
Return a list of 'more' actions for the grid.
|
||||||
"""
|
"""
|
||||||
actions = []
|
actions = []
|
||||||
prefix = self.get_permission_prefix()
|
|
||||||
use_buefy = self.get_use_buefy()
|
use_buefy = self.get_use_buefy()
|
||||||
|
|
||||||
# Edit
|
# Edit
|
||||||
if self.editable and self.request.has_perm('{}.edit'.format(prefix)):
|
if self.editable and self.has_perm('edit'):
|
||||||
icon = 'edit' if use_buefy else 'pencil'
|
icon = 'edit' if use_buefy else 'pencil'
|
||||||
actions.append(self.make_action('edit', icon=icon, url=self.default_edit_url))
|
actions.append(self.make_action('edit', icon=icon, url=self.default_edit_url))
|
||||||
|
|
||||||
# Delete
|
# Delete
|
||||||
if self.deletable and self.request.has_perm('{}.delete'.format(prefix)):
|
if self.deletable and self.has_perm('delete'):
|
||||||
kwargs = {}
|
kwargs = {}
|
||||||
if use_buefy and self.delete_confirm == 'simple':
|
if use_buefy and self.delete_confirm == 'simple':
|
||||||
kwargs['click_handler'] = 'deleteObject'
|
kwargs['click_handler'] = 'deleteObject'
|
||||||
|
|
Loading…
Reference in a new issue