Add workaround when inserting new fields to form field list

i.e. if inserting "before" or "after" a field which does not exist
This commit is contained in:
Lance Edgar 2022-03-09 18:39:12 -06:00
parent b9fa324bb4
commit 01b78d7513
2 changed files with 17 additions and 5 deletions

View file

@ -1044,12 +1044,22 @@ class FieldList(list):
"""
def insert_before(self, field, newfield):
if field in self:
i = self.index(field)
self.insert(i, newfield)
else:
log.warning("field '%s' not found, will append new field: %s",
field, newfield)
self.append(newfield)
def insert_after(self, field, newfield):
if field in self:
i = self.index(field)
self.insert(i + 1, newfield)
else:
log.warning("field '%s' not found, will append new field: %s",
field, newfield)
self.append(newfield)
@colander.deferred

View file

@ -69,6 +69,7 @@ class UserView(PrincipalMasterView):
'active_sticky',
'set_password',
'roles',
'permissions',
]
row_grid_columns = [
@ -256,11 +257,12 @@ class UserView(PrincipalMasterView):
if self.viewing:
permissions = self.request.registry.settings.get('tailbone_permissions', {})
f.append('permissions')
f.set_renderer('permissions', PermissionsRenderer(request=self.request,
permissions=permissions,
include_guest=True,
include_authenticated=True))
else:
f.remove('permissions')
if self.viewing or self.deleting:
f.remove('set_password')