diff --git a/bt5/erp5_crm/PropertySheetTemplateItem/portal_property_sheets/EventConstraint/content_type_consistency_constraint.xml b/bt5/erp5_crm/PropertySheetTemplateItem/portal_property_sheets/EventConstraint/content_type_consistency_constraint.xml new file mode 100644 index 0000000000000000000000000000000000000000..672e7b136b4da8a53d4d2198be77d92b52ddde6a --- /dev/null +++ b/bt5/erp5_crm/PropertySheetTemplateItem/portal_property_sheets/EventConstraint/content_type_consistency_constraint.xml @@ -0,0 +1,80 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="Script Constraint" module="erp5.portal_type"/> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>_identity_criterion</string> </key> + <value> + <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> + </value> + </item> + <item> + <key> <string>_range_criterion</string> </key> + <value> + <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> + </value> + </item> + <item> + <key> <string>categories</string> </key> + <value> + <tuple> + <string>constraint_type/audit</string> + </tuple> + </value> + </item> + <item> + <key> <string>description</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>content_type_consistency_constraint</string> </value> + </item> + <item> + <key> <string>portal_type</string> </key> + <value> <string>Script Constraint</string> </value> + </item> + <item> + <key> <string>script_id</string> </key> + <value> <string>Event_checkContentTypeConsistency</string> </value> + </item> + </dictionary> + </pickle> + </record> + <record id="2" aka="AAAAAAAAAAI="> + <pickle> + <global name="PersistentMapping" module="Persistence.mapping"/> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>data</string> </key> + <value> + <dictionary/> + </value> + </item> + </dictionary> + </pickle> + </record> + <record id="3" aka="AAAAAAAAAAM="> + <pickle> + <global name="PersistentMapping" module="Persistence.mapping"/> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>data</string> </key> + <value> + <dictionary/> + </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_checkContentTypeConsistency.py b/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_checkContentTypeConsistency.py new file mode 100644 index 0000000000000000000000000000000000000000..56f71bb33baf960c5728f0c84491a74705fc8173 --- /dev/null +++ b/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_checkContentTypeConsistency.py @@ -0,0 +1,15 @@ +message_list = [] +portal = context.getPortalObject() + +# I noticed that, in some Event objects, getContentType returns something like +# <bound method Mail Message.content_type of <Mail Message at 1813>> +content_type = context.getContentType() +if content_type is not None and not isinstance(content_type, str): + if fixit: + context.setContentType(None) + portal.portal_workflow.doActionFor(context, action="edit_action", comment="fix consistency") + message_list.append("%s : content type reset to None" % context.getRelativeUrl()) + else: + message_list.append("%s : content type is not a string" % context.getRelativeUrl()) + +return message_list diff --git a/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_checkContentTypeConsistency.xml b/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_checkContentTypeConsistency.xml new file mode 100644 index 0000000000000000000000000000000000000000..27172581bb613f8e9ebfbf22f38bdfd5c9a04320 --- /dev/null +++ b/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_checkContentTypeConsistency.xml @@ -0,0 +1,62 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="PythonScript" module="Products.PythonScripts.PythonScript"/> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>Script_magic</string> </key> + <value> <int>3</int> </value> + </item> + <item> + <key> <string>_bind_names</string> </key> + <value> + <object> + <klass> + <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/> + </klass> + <tuple/> + <state> + <dictionary> + <item> + <key> <string>_asgns</string> </key> + <value> + <dictionary> + <item> + <key> <string>name_container</string> </key> + <value> <string>container</string> </value> + </item> + <item> + <key> <string>name_context</string> </key> + <value> <string>context</string> </value> + </item> + <item> + <key> <string>name_m_self</string> </key> + <value> <string>script</string> </value> + </item> + <item> + <key> <string>name_subpath</string> </key> + <value> <string>traverse_subpath</string> </value> + </item> + </dictionary> + </value> + </item> + </dictionary> + </state> + </object> + </value> + </item> + <item> + <key> <string>_params</string> </key> + <value> <string>fixit=False, **kw</string> </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>Event_checkContentTypeConsistency</string> </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData>