Commit ce7277cb authored by Jérome Perrin's avatar Jérome Perrin

Added support for portal_type color


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@5950 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7312a7e6
...@@ -37,6 +37,7 @@ class CategoryExistence(Constraint): ...@@ -37,6 +37,7 @@ class CategoryExistence(Constraint):
{ 'id' : 'category_existence', { 'id' : 'category_existence',
'description' : 'Category causality must be defined', 'description' : 'Category causality must be defined',
'type' : 'CategoryExistence', 'type' : 'CategoryExistence',
'portal_type' : ('Person', 'Organisation')
'causality' : None, 'causality' : None,
}, },
""" """
...@@ -49,16 +50,23 @@ class CategoryExistence(Constraint): ...@@ -49,16 +50,23 @@ class CategoryExistence(Constraint):
errors = [] errors = []
# For each attribute name, we check if defined # For each attribute name, we check if defined
for base_category in self.constraint_definition.keys(): for base_category in self.constraint_definition.keys():
if base_category in ('portal_type', ):
continue
# Check existence of base category # Check existence of base category
error_message = "Category existence error for base category '%s': " % \ error_message = "Category existence error for base category '%s': " % \
base_category base_category
if base_category not in object.getBaseCategoryList(): if base_category not in object.getBaseCategoryList():
error_message += " this document has no such category" error_message += " this document has no such category"
elif len(object.getCategoryMembershipList(base_category)) == 0: elif len(object.getCategoryMembershipList(base_category,
portal_type = self.constraint_definition\
.get('portal_type', ()))) == 0:
error_message += " this category was not defined" error_message += " this category was not defined"
else: else:
error_message = None error_message = None
# Raise error # Raise error
if error_message: if error_message:
errors.append(self._generateError(object, error_message)) errors.append(self._generateError(object, error_message))
return errors return errors
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