Commit 691f834a authored by Rafael Monnerat's avatar Rafael Monnerat

Constraints was improved. Added nice messages, improved identation and added...

Constraints was improved. Added nice messages, improved identation and added date_coerency constraint.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@22041 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 0aee055c
...@@ -35,40 +35,54 @@ class TaskConstraint: ...@@ -35,40 +35,54 @@ class TaskConstraint:
_constraints = ( _constraints = (
{ 'id' : 'title_existence', { 'id' : 'title_existence',
'description' : 'Title must be defined', 'description' : 'Title must be defined',
'type' : 'StringAttributeMatch', 'type' : 'PropertyExistence',
'title' : '^[^ ]', 'title' : None,
'message_property_not_set': 'Title must be defined',
'message_no_such_property' : 'Title must be defined',
}, },
{ 'id' : 'source', { 'id' : 'source_category_membership_arity',
'description' : 'Source must be defined', 'description' : 'Source must be defined',
'type' : 'CategoryMembershipArity', 'type' : 'CategoryMembershipArity',
'min_arity' : '1', 'min_arity' : '1',
'max_arity' : '1', 'max_arity' : '1',
'portal_type' : ('Person', 'Organisation', 'Category'), 'portal_type' : ('Person', 'Organisation', 'Category'),
'base_category' : ('source',) 'base_category' : ('source',),
'message_arity_with_portal_type_not_in_range': 'Assignee must be defined',
}, },
{ 'id' : 'destination', { 'id' : 'destination_category_membership_arity',
'description' : 'Destination must be defined', 'description' : 'Destination must be defined',
'type' : 'CategoryMembershipArity', 'type' : 'CategoryMembershipArity',
'min_arity' : '1', 'min_arity' : '1',
'max_arity' : '1', 'max_arity' : '1',
'portal_type' : ('Person', 'Organisation', 'Category'), 'portal_type' : ('Person', 'Organisation', 'Category'),
'base_category' : ('destination',) 'base_category' : ('destination',),
'message_arity_with_portal_type_not_in_range': 'Location must be defined',
}, },
{ 'id' : 'start_date_existence', { 'id' : 'start_date_existence',
'description' : 'Property start_date must be defined', 'description' : 'Property start_date must be defined',
'type' : 'PropertyExistence', 'type' : 'PropertyExistence',
'start_date' : None, 'start_date' : None,
'message_property_not_set': 'Begin Date must be defined',
'message_no_such_property' : 'Begin Date must be defined'
}, },
{ 'id' : 'stop_date_existence', { 'id' : 'stop_date_existence',
'description' : 'Property stop date must be defined', 'description' : 'Property stop date must be defined',
'type' : 'PropertyExistence', 'type' : 'PropertyExistence',
'stop_date' : None, 'stop_date' : None,
'message_property_not_set': 'End Date must be defined',
'message_no_such_property' : 'End Date must be defined'
},
{ 'id' : 'date_coherency',
'description' : 'Stop Date must be after Start Date',
'type' : 'TALESConstraint',
'expression' : 'python: object.getStopDate() >= object.getStartDate()',
'message_expression_false': 'End Date must be after Begin Date',
}, },
{ 'id' : 'lines', { 'id' : 'lines',
'description' : 'Lines must be defined', 'description' : 'Lines must be defined',
'type' : 'ContentExistence', 'type' : 'ContentExistence',
'portal_type' : ('Task Line', 'Task Report Line' ), 'portal_type' : ('Task Line', 'Task Report Line' ),
'message_no_subobject_portal_type' : \
'It is required create at least one Line.',
}, },
) )
...@@ -35,6 +35,8 @@ class TaskLineConstraint: ...@@ -35,6 +35,8 @@ class TaskLineConstraint:
'description' : 'Property quantity must be defined', 'description' : 'Property quantity must be defined',
'type' : 'PropertyExistence', 'type' : 'PropertyExistence',
'quantity' : None, 'quantity' : None,
"message_property_not_set" : 'Quantity must be defined at Lines',
"message_no_such_property" : 'Quantity must be defined at Lines'
}, },
{ 'id' : 'resource', { 'id' : 'resource',
'description' : 'Resource must be defined', 'description' : 'Resource must be defined',
...@@ -42,6 +44,7 @@ class TaskLineConstraint: ...@@ -42,6 +44,7 @@ class TaskLineConstraint:
'min_arity' : '1', 'min_arity' : '1',
'max_arity' : '1', 'max_arity' : '1',
'portal_type' : ( ), 'portal_type' : ( ),
'base_category' : ('resource',) 'base_category' : ('resource',),
'message_arity_not_in_range' : 'Resource must be defined at Lines.' ,
}, },
) )
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment