[gen] klass.creators can now be a method that either returns a list of global roles allowed to create instances of this class, or a boolean indicating if the currently logged user can create instances of this class or not. [gen] Bugfixes.
This commit is contained in:
parent
e1b83574c5
commit
1f901e5545
6 changed files with 64 additions and 55 deletions
|
@ -74,7 +74,7 @@ class Field:
|
|||
|
||||
# Displays a field label.
|
||||
pxLabel = Px('''<label if="field.hasLabel and (field.type != 'Action')"
|
||||
lfor="field.name">::zobj.translate('label', field=field)</label>''')
|
||||
lfor=":field.name">::zobj.translate('label', field=field)</label>''')
|
||||
|
||||
# Displays a field description.
|
||||
pxDescription = Px('''<span if="field.hasDescr"
|
||||
|
|
|
@ -185,14 +185,16 @@ class Transition:
|
|||
# triggered if user has at least one of those roles and if all
|
||||
# functions return True.
|
||||
hasRole = None
|
||||
for roleOrFunction in self.condition:
|
||||
if isinstance(roleOrFunction, basestring):
|
||||
for condition in self.condition:
|
||||
# "Unwrap" role names from Role instances.
|
||||
if isinstance(condition, Role): condition = condition.name
|
||||
if isinstance(condition, basestring): # It is a role
|
||||
if hasRole == None:
|
||||
hasRole = False
|
||||
if user.has_role(roleOrFunction, obj):
|
||||
if user.has_role(condition, obj):
|
||||
hasRole = True
|
||||
elif type(roleOrFunction) == types.FunctionType:
|
||||
if not roleOrFunction(wf, obj.appy()):
|
||||
else: # It is a method
|
||||
if not condition(wf, obj.appy()):
|
||||
return False
|
||||
if hasRole != False:
|
||||
return True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue