[gen] Optimized Ref: do not ajax-call the Ref view macro when displaying a complete page; added Ref.changeOrder to enable/disable (independently from write permission) the possibility to sort or change order of referred objects.

This commit is contained in:
Gaetan Delannay 2012-10-07 11:26:55 +02:00
parent 82a8ac99b4
commit 872b77208b
2 changed files with 19 additions and 22 deletions

View file

@ -1766,7 +1766,7 @@ class Ref(Type):
maxChars=None, colspan=1, master=None, masterValue=None,
focus=False, historized=False, mapping=None, label=None,
queryable=False, queryFields=None, queryNbCols=1,
navigable=False, searchSelect=None):
navigable=False, searchSelect=None, changeOrder=True):
self.klass = klass
self.attribute = attribute
# May the user add new objects through this ref ?
@ -1839,6 +1839,9 @@ class Ref(Type):
# in the search screen. Those values are returned by self.searchSelect,
# which must be a static method accepting the tool as single arg.
self.searchSelect = searchSelect
# If changeOrder is False, it even if the user has the right to modify
# the field, it will not be possible to move objects or sort them.
self.changeOrder = changeOrder
Type.__init__(self, validator, multiplicity, index, default, optional,
editDefault, show, page, group, layouts, move, indexed,
False, specificReadPermission, specificWritePermission,
@ -2084,6 +2087,13 @@ class Ref(Type):
raise Unauthorized("User can't write Ref field '%s' (%s)." % \
(self.name, may.msg))
def changeOrderEnabled(self, obj):
'''Is changeOrder enabled?'''
if isinstance(self.changeOrder, bool):
return self.changeOrder
else:
return self.callMethod(obj, self.changeOrder)
def autoref(klass, field):
'''klass.field is a Ref to p_klass. This kind of auto-reference can't be
declared in the "normal" way, like this: