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):
|
def insert_before(self, field, newfield):
|
||||||
i = self.index(field)
|
if field in self:
|
||||||
self.insert(i, newfield)
|
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):
|
def insert_after(self, field, newfield):
|
||||||
i = self.index(field)
|
if field in self:
|
||||||
self.insert(i + 1, newfield)
|
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
|
@colander.deferred
|
||||||
|
|
|
@ -69,6 +69,7 @@ class UserView(PrincipalMasterView):
|
||||||
'active_sticky',
|
'active_sticky',
|
||||||
'set_password',
|
'set_password',
|
||||||
'roles',
|
'roles',
|
||||||
|
'permissions',
|
||||||
]
|
]
|
||||||
|
|
||||||
row_grid_columns = [
|
row_grid_columns = [
|
||||||
|
@ -256,11 +257,12 @@ class UserView(PrincipalMasterView):
|
||||||
|
|
||||||
if self.viewing:
|
if self.viewing:
|
||||||
permissions = self.request.registry.settings.get('tailbone_permissions', {})
|
permissions = self.request.registry.settings.get('tailbone_permissions', {})
|
||||||
f.append('permissions')
|
|
||||||
f.set_renderer('permissions', PermissionsRenderer(request=self.request,
|
f.set_renderer('permissions', PermissionsRenderer(request=self.request,
|
||||||
permissions=permissions,
|
permissions=permissions,
|
||||||
include_guest=True,
|
include_guest=True,
|
||||||
include_authenticated=True))
|
include_authenticated=True))
|
||||||
|
else:
|
||||||
|
f.remove('permissions')
|
||||||
|
|
||||||
if self.viewing or self.deleting:
|
if self.viewing or self.deleting:
|
||||||
f.remove('set_password')
|
f.remove('set_password')
|
||||||
|
|
Loading…
Reference in a new issue