diff --git a/tailbone/templates/principal/find_by_perm.mako b/tailbone/templates/principal/find_by_perm.mako
index f257901b..5a053751 100644
--- a/tailbone/templates/principal/find_by_perm.mako
+++ b/tailbone/templates/principal/find_by_perm.mako
@@ -1,10 +1,11 @@
-## -*- coding: utf-8 -*-
+## -*- coding: utf-8; -*-
<%inherit file="/base.mako" />
<%def name="title()">Find ${model_title_plural} by Permission%def>
<%def name="extra_javascript()">
${parent.extra_javascript()}
+ % if not use_buefy:
+ % endif
%def>
+% if not use_buefy:
${h.form(request.current_route_url(), id='find-by-perm-form')}
${h.csrf_token(request)}
@@ -65,3 +68,114 @@ ${h.end_form()}
${self.principal_table()}
% endif
+
+
+% else:
+## use_buefy!
+
+
+
+
+
+
+
+
+
+% endif
diff --git a/tailbone/views/principal.py b/tailbone/views/principal.py
index d879c696..d780cfca 100644
--- a/tailbone/views/principal.py
+++ b/tailbone/views/principal.py
@@ -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)