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:
parent
b9fa324bb4
commit
01b78d7513
|
@ -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
|
||||
|
|
|
@ -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')
|
||||
|
|
Loading…
Reference in a new issue