Use buefy table for "find principal by perm" results
this should work for oruga as well
This commit is contained in:
parent
098ed5b1cf
commit
5aa8d1f9a3
6 changed files with 88 additions and 54 deletions
|
@ -65,14 +65,21 @@ class PrincipalMasterView(MasterView):
|
|||
principals = None
|
||||
permission_group = self.request.GET.get('permission_group')
|
||||
permission = self.request.GET.get('permission')
|
||||
grid = None
|
||||
if permission_group and permission:
|
||||
principals = self.find_principals_with_permission(self.Session(),
|
||||
permission)
|
||||
grid = self.find_by_perm_make_results_grid(principals)
|
||||
else: # otherwise clear both values
|
||||
permission_group = None
|
||||
permission = None
|
||||
|
||||
context = {'permissions': sorted_perms, 'principals': principals}
|
||||
context = {
|
||||
'permissions': sorted_perms,
|
||||
'principals': principals,
|
||||
'principals_data': self.find_by_perm_results_data(principals),
|
||||
'grid': grid,
|
||||
}
|
||||
|
||||
perms = self.get_perms_data(sorted_perms)
|
||||
context['perms_data'] = perms
|
||||
|
@ -114,6 +121,35 @@ class PrincipalMasterView(MasterView):
|
|||
|
||||
return data
|
||||
|
||||
def find_by_perm_make_results_grid(self, principals):
|
||||
route_prefix = self.get_route_prefix()
|
||||
factory = self.get_grid_factory()
|
||||
g = factory(key=f'{route_prefix}.results',
|
||||
request=self.request,
|
||||
data=[],
|
||||
columns=[],
|
||||
main_actions=[
|
||||
self.make_action('view', icon='eye',
|
||||
click_handler='navigateTo(props.row._url)'),
|
||||
])
|
||||
self.find_by_perm_configure_results_grid(g)
|
||||
return g
|
||||
|
||||
def find_by_perm_configure_results_grid(self, g):
|
||||
pass
|
||||
|
||||
def find_by_perm_results_data(self, principals):
|
||||
data = []
|
||||
for principal in principals or []:
|
||||
data.append(self.find_by_perm_normalize(principal))
|
||||
return data
|
||||
|
||||
def find_by_perm_normalize(self, principal):
|
||||
return {
|
||||
'uuid': principal.uuid,
|
||||
'_url': self.get_action_url('view', principal),
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def defaults(cls, config):
|
||||
cls._principal_defaults(config)
|
||||
|
|
|
@ -406,6 +406,17 @@ class RoleView(PrincipalMasterView):
|
|||
roles.append(role)
|
||||
return roles
|
||||
|
||||
def find_by_perm_configure_results_grid(self, g):
|
||||
g.append('name')
|
||||
g.set_link('name')
|
||||
|
||||
def find_by_perm_normalize(self, role):
|
||||
data = super().find_by_perm_normalize(role)
|
||||
|
||||
data['name'] = role.name
|
||||
|
||||
return data
|
||||
|
||||
def download_permissions_matrix(self):
|
||||
"""
|
||||
View which renders the complete role / permissions matrix data into an
|
||||
|
|
|
@ -521,6 +521,21 @@ class UserView(PrincipalMasterView):
|
|||
users.append(user)
|
||||
return users
|
||||
|
||||
def find_by_perm_configure_results_grid(self, g):
|
||||
g.append('username')
|
||||
g.set_link('username')
|
||||
|
||||
g.append('person')
|
||||
g.set_link('person')
|
||||
|
||||
def find_by_perm_normalize(self, user):
|
||||
data = super().find_by_perm_normalize(user)
|
||||
|
||||
data['username'] = user.username
|
||||
data['person'] = str(user.person or '')
|
||||
|
||||
return data
|
||||
|
||||
def preferences(self, user=None):
|
||||
"""
|
||||
View to modify preferences for a particular user.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue