Commit 716080f3 authored by Gabriel Monnerat's avatar Gabriel Monnerat

erp5_upgrader: Fix code to run checkConsistency to a specific constraint_type

constraint_type should be a string instead of a list.
parent 2bd817ff
...@@ -67,7 +67,7 @@ if alarm.sense() in (None, True):\n ...@@ -67,7 +67,7 @@ if alarm.sense() in (None, True):\n
\n \n
context.ERP5Site_checkUpgraderConsistency(fixit=True,\n context.ERP5Site_checkUpgraderConsistency(fixit=True,\n
active_process=active_process,\n active_process=active_process,\n
filter_dict={"constraint_type": ["post_upgrade",]})\n filter_dict={"constraint_type": "post_upgrade"})\n
\n \n
context.setEnabled(False)\n context.setEnabled(False)\n
return\n return\n
......
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
"""\n """\n
context.ERP5Site_checkUpgraderConsistency(fixit=True,\n context.ERP5Site_checkUpgraderConsistency(fixit=True,\n
active_process=context.newActiveProcess(),\n active_process=context.newActiveProcess(),\n
filter_dict={"constraint_type": ["pre_upgrade"]})\n filter_dict={"constraint_type": "pre_upgrade"})\n
\n \n
context.setEnabled(False)\n context.setEnabled(False)\n
return\n return\n
......
...@@ -50,22 +50,19 @@ ...@@ -50,22 +50,19 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>traverse = context.getPortalObject().restrictedTraverse\n <value> <string>active_process = context.getPortalObject().restrictedTraverse(active_process)\n
active_process = traverse(active_process)\n
\n \n
# We don\'t need check more if something is already inconsistent\n # We don\'t need check more if something is already inconsistent\n
if (active_process.ActiveProcess_sense() and not fixit):\n if active_process.ActiveProcess_sense() and not fixit:\n
return\n return\n
\n \n
constraint_message_list = context.checkConsistency(fixit=fixit,\n constraint_message_list = context.checkConsistency(\n
filter=filter)\n fixit=fixit, filter=filter,)\n
\n \n
if constraint_message_list and not active_process.getResultList():\n if constraint_message_list and not active_process.getResultList():\n
summary = "%s Consistency - At least one inconsistent object found" % \\\n
(fixit and \'Fix\' or \'Check\')\n
active_process.postActiveResult(\n active_process.postActiveResult(\n
severity=(not fixit and 1) or 0,\n severity=0 if fixit else 1,\n
summary=summary,\n summary="%s Consistency - At least one inconsistent object found" % (\'Fix\' if fixit else \'Check\', ),\n
detail=[m.message for m in constraint_message_list])\n detail=[m.message for m in constraint_message_list])\n
</string> </value> </string> </value>
</item> </item>
......
...@@ -50,19 +50,27 @@ ...@@ -50,19 +50,27 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n <value> <string>constraint_type_per_type, _ = context.Base_getConstraintTypeListPerPortalType()\n
constraint_type_per_type, _ = context.Base_getConstraintTypeListPerPortalType()\n
constraint_type = filter_dict.get("constraint_type")\n constraint_type = filter_dict.get("constraint_type")\n
if not constraint_type:\n
return\n
\n \n
portal_type_list = []\n
append = portal_type_list.append\n
for portal_type, constraint_type_list in constraint_type_per_type.iteritems():\n for portal_type, constraint_type_list in constraint_type_per_type.iteritems():\n
if not constraint_type and constraint_type not in constraint_type_list:\n if constraint_type in constraint_type_list:\n
continue\n append(portal_type)\n
method_kw = {\'fixit\': fixit,\n \n
\'filter\': filter_dict,\n if portal_type_list:\n
\'active_process\': active_process.getRelativeUrl()}\n context.getPortalObject().portal_catalog.searchAndActivate(\n
portal.portal_catalog.searchAndActivate(\'Base_postCheckConsistencyResult\',\n \'Base_postCheckConsistencyResult\',\n
portal_type=portal_type,\n portal_type=portal_type_list,\n
method_kw=method_kw)\n method_kw={\n
\'fixit\': fixit,\n
\'filter\': filter_dict,\n
\'active_process\': active_process.getRelativeUrl(),\n
},\n
)\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
......
612 613
\ No newline at end of file \ No newline at end of file
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