diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Component_view/my_error_message_list.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Component_view/my_error_message_list.xml index 78791a5c07803e67c2fa70e4ff795b2d927a8672..9db83bc78f9ed6f456a18eb516cbf6b0f4858365 100644 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Component_view/my_error_message_list.xml +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Component_view/my_error_message_list.xml @@ -56,6 +56,14 @@ <key> <string>tales</string> </key> <value> <dictionary> + <item> + <key> <string>css_class</string> </key> + <value> <string></string> </value> + </item> + <item> + <key> <string>editable</string> </key> + <value> <string></string> </value> + </item> <item> <key> <string>enabled</string> </key> <value> @@ -70,10 +78,18 @@ <key> <string>form_id</string> </key> <value> <string></string> </value> </item> + <item> + <key> <string>height</string> </key> + <value> <string></string> </value> + </item> <item> <key> <string>target</string> </key> <value> <string></string> </value> </item> + <item> + <key> <string>title</string> </key> + <value> <string></string> </value> + </item> </dictionary> </value> </item> @@ -127,7 +143,7 @@ <dictionary> <item> <key> <string>_text</string> </key> - <value> <string>python: here.getValidationState() == \'modified\'</string> </value> + <value> <string>here/hasErrorMessageList</string> </value> </item> </dictionary> </pickle> diff --git a/product/ERP5/bootstrap/erp5_core/bt/change_log b/product/ERP5/bootstrap/erp5_core/bt/change_log index 71a88c1e36d0153de92dcc4fa7bc13c9690554e8..97a444f20453f1695b9e82695864300b76d07c57 100644 --- a/product/ERP5/bootstrap/erp5_core/bt/change_log +++ b/product/ERP5/bootstrap/erp5_core/bt/change_log @@ -1,3 +1,6 @@ +2012-02-29 arnaud.fontaine +* Display error messages in Component_view which may have been raised when validating a Component in draft state. + 2012-02-29 arnaud.fontaine * Add portal_components to keep path list. diff --git a/product/ERP5/bootstrap/erp5_core/bt/revision b/product/ERP5/bootstrap/erp5_core/bt/revision index c0426e0056b9a4ac976a5690789fc7a54ec77e28..c623c09cb1bb06ab804dd8976937506cf556dccb 100644 --- a/product/ERP5/bootstrap/erp5_core/bt/revision +++ b/product/ERP5/bootstrap/erp5_core/bt/revision @@ -1 +1 @@ -41018 \ No newline at end of file +41019 \ No newline at end of file diff --git a/product/ERP5Type/mixin/component.py b/product/ERP5Type/mixin/component.py index 8e39471a3d338b2441cc71569b52deb2bfcee10f..c7894a53d0d037b732b7eec14c5e784d13cd2f09 100644 --- a/product/ERP5Type/mixin/component.py +++ b/product/ERP5Type/mixin/component.py @@ -239,13 +239,29 @@ class ComponentMixin(PropertyRecordableMixin, Base): error_list = self.checkConsistency() if error_list: workflow = self.workflow_history['component_validation_workflow'][-1] - workflow['error_list'] = error_list + + # When checking consistency with validate_action, messages are stored + # into error_message workflow attribute as Message instances + workflow['error_message'] = [error.getMessage() for error in error_list] else: for property_name in self._recorded_property_name_tuple: self.clearRecordedProperty(property_name) self.validate() + security.declareProtected(Permissions.AccessContentsInformation, + 'getErrorMessageList') + def hasErrorMessageList(self): + """ + Check whether there are error messages, useful to display errors in the UI + without calling getErrorMessageList() which translates error messages + """ + try: + self.workflow_history['component_validation_workflow'][-1]['error_message'] + return True + except KeyError: + return False + security.declareProtected(Permissions.AccessContentsInformation, 'getErrorMessageList') def getErrorMessageList(self): @@ -254,8 +270,8 @@ class ComponentMixin(PropertyRecordableMixin, Base): the Component has been modified after being validated once """ current_workflow = self.workflow_history['component_validation_workflow'][-1] - return [str(error.getTranslatedMessage()) - for error in current_workflow.get('error_list', [])] + return [error.translate() + for error in current_workflow.get('error_message', [])] security.declareProtected(Permissions.ModifyPortalContent, 'load') def load(self, namespace_dict={}, validated_only=False, text_content=None):