Add basic Buefy support for "find user/role with permission X"
still not totally polished, but works as expected
This commit is contained in:
parent
ea54ca6c11
commit
efb1a73e88
2 changed files with 144 additions and 2 deletions
|
@ -2,7 +2,7 @@
|
|||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2018 Lance Edgar
|
||||
# Copyright © 2010-2019 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
|
@ -30,6 +30,7 @@ import copy
|
|||
|
||||
from rattail.db.auth import has_permission
|
||||
from rattail.core import Object
|
||||
from rattail.util import OrderedDict
|
||||
|
||||
import wtforms
|
||||
from webhelpers2.html import HTML
|
||||
|
@ -84,8 +85,35 @@ class PrincipalMasterView(MasterView):
|
|||
principals = self.find_principals_with_permission(self.Session(), permission)
|
||||
|
||||
context = {'form': form, 'permissions': sorted_perms, 'principals': principals}
|
||||
|
||||
if self.get_use_buefy():
|
||||
perms = self.get_buefy_perms_data(sorted_perms)
|
||||
context['buefy_perms'] = perms
|
||||
context['buefy_sorted_groups'] = list(perms)
|
||||
context['selected_group'] = self.request.POST.get('permission_group', 'common')
|
||||
context['selected_permission'] = self.request.POST.get('permission', None)
|
||||
|
||||
return self.render_to_response('find_by_perm', context)
|
||||
|
||||
def get_buefy_perms_data(self, sorted_perms):
|
||||
data = OrderedDict()
|
||||
for gkey, group in sorted_perms:
|
||||
|
||||
gperms = []
|
||||
for pkey, perm in group['perms']:
|
||||
gperms.append({
|
||||
'permkey': pkey,
|
||||
'label': perm['label'],
|
||||
})
|
||||
|
||||
data[gkey] = {
|
||||
'groupkey': gkey,
|
||||
'label': group['label'],
|
||||
'permissions': gperms,
|
||||
}
|
||||
|
||||
return data
|
||||
|
||||
@classmethod
|
||||
def defaults(cls, config):
|
||||
cls._principal_defaults(config)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue