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
......@@ -28,47 +28,61 @@
##############################################################################
class TaskConstraint:
"""
Constraintsts For Task
"""
_constraints = (
{ 'id' : 'title_existence',
'description' : 'Title must be defined',
'type' : 'StringAttributeMatch',
'title' : '^[^ ]',
},
{ 'id' : 'source',
'description' : 'Source must be defined',
'type' : 'CategoryMembershipArity',
'min_arity' : '1',
'max_arity' : '1',
'portal_type' : ('Person', 'Organisation', 'Category'),
'base_category' : ('source',)
},
{ 'id' : 'destination',
'description' : 'Destination must be defined',
'type' : 'CategoryMembershipArity',
'min_arity' : '1',
'max_arity' : '1',
'portal_type' : ('Person', 'Organisation', 'Category'),
'base_category' : ('destination',)
},
{ 'id' : 'start_date_existence',
'description' : 'Property start_date must be defined',
'type' : 'PropertyExistence',
'start_date' : None,
},
{ 'id' : 'stop_date_existence',
'description' : 'Property stop date must be defined',
'type' : 'PropertyExistence',
'stop_date' : None,
},
{ 'id' : 'lines',
'description' : 'Lines must be defined',
'type' : 'ContentExistence',
'portal_type' : ('Task Line', 'Task Report Line' ),
},
)
"""
Constraintsts For Task
"""
_constraints = (
{ 'id' : 'title_existence',
'description' : 'Title must be defined',
'type' : 'PropertyExistence',
'title' : None,
'message_property_not_set': 'Title must be defined',
'message_no_such_property' : 'Title must be defined',
},
{ 'id' : 'source_category_membership_arity',
'description' : 'Source must be defined',
'type' : 'CategoryMembershipArity',
'min_arity' : '1',
'max_arity' : '1',
'portal_type' : ('Person', 'Organisation', 'Category'),
'base_category' : ('source',),
'message_arity_with_portal_type_not_in_range': 'Assignee must be defined',
},
{ 'id' : 'destination_category_membership_arity',
'description' : 'Destination must be defined',
'type' : 'CategoryMembershipArity',
'min_arity' : '1',
'max_arity' : '1',
'portal_type' : ('Person', 'Organisation', 'Category'),
'base_category' : ('destination',),
'message_arity_with_portal_type_not_in_range': 'Location must be defined',
},
{ 'id' : 'start_date_existence',
'description' : 'Property start_date must be defined',
'type' : 'PropertyExistence',
'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',
'description' : 'Property stop date must be defined',
'type' : 'PropertyExistence',
'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',
'description' : 'Lines must be defined',
'type' : 'ContentExistence',
'portal_type' : ('Task Line', 'Task Report Line' ),
'message_no_subobject_portal_type' : \
'It is required create at least one Line.',
},
)
......@@ -27,21 +27,24 @@
##############################################################################
class TaskLineConstraint:
"""
Task Line Constraints
"""
_constraints = (
{ 'id' : 'quantity_existence',
'description' : 'Property quantity must be defined',
'type' : 'PropertyExistence',
'quantity' : None,
},
{ 'id' : 'resource',
'description' : 'Resource must be defined',
'type' : 'CategoryMembershipArity',
'min_arity' : '1',
'max_arity' : '1',
'portal_type' : ( ),
'base_category' : ('resource',)
},
)
"""
Task Line Constraints
"""
_constraints = (
{ 'id' : 'quantity_existence',
'description' : 'Property quantity must be defined',
'type' : 'PropertyExistence',
'quantity' : None,
"message_property_not_set" : 'Quantity must be defined at Lines',
"message_no_such_property" : 'Quantity must be defined at Lines'
},
{ 'id' : 'resource',
'description' : 'Resource must be defined',
'type' : 'CategoryMembershipArity',
'min_arity' : '1',
'max_arity' : '1',
'portal_type' : ( ),
'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