Commit 8e945c95 authored by Rafael Monnerat's avatar Rafael Monnerat

ERP5Form: Really ignore the form if it is in the ignore list.

parent e6fc1116
......@@ -1362,38 +1362,38 @@ class ERP5Form(Base, ZMIForm, ZopePageTemplate):
is_field_library = self.getId().endswith('FieldLibrary')
if self.pt == 'form_view' and not is_field_library:
translated_workflow_state_title_field_re = re.compile('my_translated_.*state_title$')
def isTranslatedWorkflowStateTitleField(f):
return translated_workflow_state_title_field_re.match(f.getId()) is not None
not_translated_workflow_state_field_re = re.compile('my_(?!translated_).*state(_title|)$')
def isNonTranslatedWorkflowStateField(f):
return not_translated_workflow_state_field_re.match(f.getId()) and f.getId() not in (
# exception for some properties containing "state" in their names
'my_initial_implementation_state',
'my_hot_reindexing_state',
'my_message_different_state',
)
for group_name in self.get_groups():
field_list = self.get_fields_in_group(group_name)
for index, field in enumerate(field_list):
if isTranslatedWorkflowStateTitleField(field):
is_in_right_group = 'right' in group_name
# workflow states fields must be the last ones, so we check
# that this field or all the one below match the
# my_translated_${state_variable}_title regex
all_bottom_fields_are_workflow_state_fields = {True} == {
isTranslatedWorkflowStateTitleField(f) is not None for f in field_list[index:]}
if not (all_bottom_fields_are_workflow_state_fields and is_in_right_group):
if self.getId() not in CodingStyle.ignored_skin_id_set:
translated_workflow_state_title_field_re = re.compile('my_translated_.*state_title$')
def isTranslatedWorkflowStateTitleField(f):
return translated_workflow_state_title_field_re.match(f.getId()) is not None
not_translated_workflow_state_field_re = re.compile('my_(?!translated_).*state(_title|)$')
def isNonTranslatedWorkflowStateField(f):
return not_translated_workflow_state_field_re.match(f.getId()) and f.getId() not in (
# exception for some properties containing "state" in their names
'my_initial_implementation_state',
'my_hot_reindexing_state',
'my_message_different_state',
)
for group_name in self.get_groups():
field_list = self.get_fields_in_group(group_name)
for index, field in enumerate(field_list):
if isTranslatedWorkflowStateTitleField(field):
is_in_right_group = 'right' in group_name
# workflow states fields must be the last ones, so we check
# that this field or all the one below match the
# my_translated_${state_variable}_title regex
all_bottom_fields_are_workflow_state_fields = {True} == {
isTranslatedWorkflowStateTitleField(f) is not None for f in field_list[index:]}
if not (all_bottom_fields_are_workflow_state_fields and is_in_right_group):
addMessage(
'erp5-Guideline.Place.Simulation.And.Validation.Fields.In.Bottom.Of.Right.Group',
'Workflow state fields must be at the bottom right')
if isNonTranslatedWorkflowStateField(field):
addMessage(
'erp5-Guideline.Place.Simulation.And.Validation.Fields.In.Bottom.Of.Right.Group',
'Workflow state fields must be at the bottom right')
if isNonTranslatedWorkflowStateField(field):
addMessage(
'erp5-Guideline.Use.Correct.Names.For.Simulation.And.Validation.Titles',
'Workflow state fields should be named my_translated_${state_variable}_title')
'erp5-Guideline.Use.Correct.Names.For.Simulation.And.Validation.Titles',
'Workflow state fields should be named my_translated_${state_variable}_title')
# check fields, if they implement _checkConsistency
for field in self.objectValues():
......
  • I think this was intentional to check these even for ignored skins. As we can see in this comment ( https://lab.nexedi.com/nexedi/erp5/blob/8e945c95a263cf4b50fa36ef507491b8ec8aa96e/product/ERP5Form/Form.py#L1348 )

    # For ignored_skin_id_set, we only ignore naming of the form itself.

    Are there some problems that are impossible to fix ?

  • Yes, in case of Ticket_viewAsHateoas:

    https://lab.nexedi.com/nexedi/slapos.core/tree/master/master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/Ticket_viewAsHateoas

    We want the non-translated value (and the translated one too), since this is part of expected API not for displaying to the user.

    [<ObjectMessage object at 0x7fbd870fc5f0
      'object_relative_url': '/portal_skins/slapos_hal_json_style/Ticket_viewAsHateoas'
      'message': 'erp5-Guideline.Use.Correct.Names.For.Simulation.And.Validation.Titles: Workflow state fields should be named my_translated_${state_variable}_title'
      'mapping': {}>] 

    In such case, there is also an hardcoded value for a certain fields:

                  def isNonTranslatedWorkflowStateField(f):
                    return not_translated_workflow_state_field_re.match(f.getId()) and f.getId() not in (
                        # exception for some properties containing "state" in their names
                        'my_initial_implementation_state',
                        'my_hot_reindexing_state',
                        'my_message_different_state',
                    )

    So why what is on ignore list, can't be ignored after all? I'm not sure if there are other ways to handle it.

  • mentioned in commit 78fc14eb

    Toggle commit list
  • mentioned in merge request !1479 (merged)

    Toggle commit list
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