Only show granted permissions when viewing role details

Hopefully a little easier on the eyes..still could use more improvements
though I'm sure.
This commit is contained in:
Lance Edgar 2016-08-11 22:29:55 -05:00
parent 2b1a493706
commit 41ca3859f6
2 changed files with 18 additions and 8 deletions

View file

@ -3,6 +3,10 @@
* Permission Lists * Permission Lists
******************************/ ******************************/
div.field-wrapper.permissions {
overflow: visible;
}
div.field-wrapper.permissions div.field div.group { div.field-wrapper.permissions div.field div.group {
margin-bottom: 10px; margin-bottom: 10px;
} }

View file

@ -74,18 +74,24 @@ def PermissionsFieldRenderer(permissions, *args, **kwargs):
for groupkey in sorted(permissions, key=lambda k: permissions[k]['label'].lower()): for groupkey in sorted(permissions, key=lambda k: permissions[k]['label'].lower()):
inner = HTML.tag('p', c=permissions[groupkey]['label']) inner = HTML.tag('p', c=permissions[groupkey]['label'])
perms = permissions[groupkey]['perms'] perms = permissions[groupkey]['perms']
rendered = False
for key in sorted(perms, key=lambda p: perms[p]['label'].lower()): for key in sorted(perms, key=lambda p: perms[p]['label'].lower()):
checked = has_permission(Session(), role, key, checked = has_permission(Session(), role, key,
include_guest=False, include_guest=False,
include_authenticated=False) include_authenticated=False)
label = perms[key]['label'] if checked or not readonly:
if readonly: label = perms[key]['label']
span = HTML.tag('span', c="[X]" if checked else "[ ]") if readonly:
inner += HTML.tag('p', class_='perm', c=span + ' ' + label) span = HTML.tag('span', c="[X]" if checked else "[ ]")
else: inner += HTML.tag('p', class_='perm', c=span + ' ' + label)
inner += tags.checkbox(self.name + '-' + key, else:
checked=checked, label=label) inner += tags.checkbox(self.name + '-' + key,
html += HTML.tag('div', class_='group', c=inner) checked=checked, label=label)
rendered = True
if rendered:
html += HTML.tag('div', class_='group', c=inner)
if not html:
return "(none granted)"
return html return html
def render(self, **kwargs): def render(self, **kwargs):