From 5b0da6248e791de855366ced302cb91811810d4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Calonne?= <aurel@nexedi.com> Date: Thu, 11 Jun 2015 09:17:17 +0200 Subject: [PATCH] free subscription : some minor fixes + add interaction to generate reference --- .../Base_unsubscribeFromEvent.xml | 2 +- .../Entity_createFreeSubscription.xml | 2 +- .../FreeSubscription_generateReference.xml | 25 ++-- ...ge_getSubstitutionMappingDictFromEvent.xml | 113 ------------------ .../free_subscription_reference.xml | 104 ++++++++++++++++ .../scripts/setReference.xml | 67 +++++++++++ bt5/erp5_free_subscription/bt/version | 2 +- 7 files changed, 191 insertions(+), 124 deletions(-) delete mode 100644 bt5/erp5_free_subscription/SkinTemplateItem/portal_skins/erp5_free_subscription/NotificationMessage_getSubstitutionMappingDictFromEvent.xml create mode 100644 bt5/erp5_free_subscription/WorkflowTemplateItem/portal_workflow/free_subscription_interaction_workflow/interactions/free_subscription_reference.xml create mode 100644 bt5/erp5_free_subscription/WorkflowTemplateItem/portal_workflow/free_subscription_interaction_workflow/scripts/setReference.xml diff --git a/bt5/erp5_free_subscription/SkinTemplateItem/portal_skins/erp5_free_subscription/Base_unsubscribeFromEvent.xml b/bt5/erp5_free_subscription/SkinTemplateItem/portal_skins/erp5_free_subscription/Base_unsubscribeFromEvent.xml index 5054df8dd5..470e9a1e10 100644 --- a/bt5/erp5_free_subscription/SkinTemplateItem/portal_skins/erp5_free_subscription/Base_unsubscribeFromEvent.xml +++ b/bt5/erp5_free_subscription/SkinTemplateItem/portal_skins/erp5_free_subscription/Base_unsubscribeFromEvent.xml @@ -73,7 +73,7 @@ if user is None:\n event_id=request[\'id\'], \n hmac=request["hash"])\n \n -# serve the image\n +# serve the web-page that will display a "Sucessfully unsubscribe" message\n return context.index_html(request, request.RESPONSE, format=None)\n </string> </value> </item> diff --git a/bt5/erp5_free_subscription/SkinTemplateItem/portal_skins/erp5_free_subscription/Entity_createFreeSubscription.xml b/bt5/erp5_free_subscription/SkinTemplateItem/portal_skins/erp5_free_subscription/Entity_createFreeSubscription.xml index f60da5d8e3..25408300d3 100644 --- a/bt5/erp5_free_subscription/SkinTemplateItem/portal_skins/erp5_free_subscription/Entity_createFreeSubscription.xml +++ b/bt5/erp5_free_subscription/SkinTemplateItem/portal_skins/erp5_free_subscription/Entity_createFreeSubscription.xml @@ -56,7 +56,7 @@ free_subscription = context.getPortalObject().free_subscription_module.newConten destination_value=context,\n source=source,\n resource=resource,\n - start_date=start_date,\n + effective_date=start_date,\n title=title)\n \n free_subscription.validate()\n diff --git a/bt5/erp5_free_subscription/SkinTemplateItem/portal_skins/erp5_free_subscription/FreeSubscription_generateReference.xml b/bt5/erp5_free_subscription/SkinTemplateItem/portal_skins/erp5_free_subscription/FreeSubscription_generateReference.xml index 600bb398aa..dfe949d983 100644 --- a/bt5/erp5_free_subscription/SkinTemplateItem/portal_skins/erp5_free_subscription/FreeSubscription_generateReference.xml +++ b/bt5/erp5_free_subscription/SkinTemplateItem/portal_skins/erp5_free_subscription/FreeSubscription_generateReference.xml @@ -51,14 +51,23 @@ <item> <key> <string>_body</string> </key> <value> <string>portal = context.getPortalObject()\n -group_reference = context.getSourceValue().getGroupReference()\n -counter = portal.portal_ids.generateNewId(\n - id_generator="uid",\n - id_group=\'.\'.join((\'free_subscription\', \'reference\', group_reference)),\n - default=1)\n -\n -source_reference = \'FS-%s-%05d\' % (group_reference, counter)\n -context.setReference(source_reference)\n +if context.getSource():\n + if context.getPortalType() == "Free Subscription":\n + generator_base = "free_subscription"\n + reference_base = "FS"\n + elif context.getPortalType() == "Free Subscription Request":\n + generator_base = "free_subscription_request"\n + reference_base = "FSR"\n + else:\n + raise ValueError("Should not be called for %s" %(context.getPortalType(),))\n + group_reference = context.getSourceValue().getGroupReference()\n + counter = portal.portal_ids.generateNewId(\n + id_generator="uid",\n + id_group=\'.\'.join((generator_base, \'reference\', group_reference)),\n + default=1)\n + \n + source_reference = \'%s-%s-%05d\' % (reference_base, group_reference, counter)\n + context.setReference(source_reference)\n </string> </value> </item> <item> diff --git a/bt5/erp5_free_subscription/SkinTemplateItem/portal_skins/erp5_free_subscription/NotificationMessage_getSubstitutionMappingDictFromEvent.xml b/bt5/erp5_free_subscription/SkinTemplateItem/portal_skins/erp5_free_subscription/NotificationMessage_getSubstitutionMappingDictFromEvent.xml deleted file mode 100644 index cf7639648b..0000000000 --- a/bt5/erp5_free_subscription/SkinTemplateItem/portal_skins/erp5_free_subscription/NotificationMessage_getSubstitutionMappingDictFromEvent.xml +++ /dev/null @@ -1,113 +0,0 @@ -<?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>_body</string> </key> - <value> <string encoding="cdata"><![CDATA[ - -from Products.ERP5Type.Message import translateString\n -portal = context.getPortalObject()\n -format_address = portal.ERP5Site_formatFrenchAddressText\n -\n -def getSubstitutionMappingDict():\n - destination = event_value.getDestinationValue()\n - kw[\'event_value_source_title\'] = event_value.getSourceTitle()\n -\n - if destination is not None:\n - kw[\'third_party_reference\'] = destination.getDestinationReference()\n - kw[\'address\'] = (destination.getDefaultAddressText() or \'\').upper()\n - kw[\'email\'] = destination.getDefaultEmailText() or \'\'\n - kw[\'telephone\'] = destination.getDefaultTelephoneText() or \'\'\n - kw[\'mobile\'] = destination.getMobileTelephoneText() or \'\'\n - kw[\'creation_date\'] = destination.getCreationDate()\n - kw[\'origin_campaign\'] = destination.getOriginReference()\n -\n - if destination.getPortalType() == \'Person\':\n - kw[\'first_name\'] = destination.getFirstName()\n - kw[\'last_name\'] = destination.getLastName()\n - kw[\'social_title\'] = destination.getSocialTitleTranslatedTitle("")\n - kw[\'third_party_name\'] = destination.getTitle()\n - if destination.getSocialTitle():\n - kw[\'third_party_name\'] = "%s %s" % (destination.getSocialTitleTranslatedTitle() or \'\',\n - destination.getTitle())\n - elif destination.getPortalType() == \'Organisation\':\n - kw[\'social_title\'] = str(translateString("Participant"))\n - kw[\'third_party_name\'] = destination.getCorporateName() or destination.getTitle()\n -\n - kw[\'event_value_start_date\'] = event_value.getStartDate()\n - kw[\'event_value_nature\'] = event_value.getResourceReference()\n - kw[\'event_value_reference\'] = event_value.getReference()\n - kw[\'ticket_reference\'] = event_value.getDefaultFollowUpReference()\n - hmac = portal.Base_getHMACHexdigest(key=portal.Base_getEventHMACKey(), message=event_value.getId())\n - kw["image_parameters"] = "/Base_openEvent?id=%s&hash=%s" %(event_value.getId(), hmac)\n - kw["newsletter_parameters"] = "/Base_readEvent?id=%s&hash=%s" %(event_value.getId(), hmac)\n - kw["unsubscribe_parameters"] = "/Base_unsubscribe?id=%s&hash=%s" %(event_value.getId(), hmac)\n -\n - return kw\n -\n -\n -with context.getPortalObject().Localizer.translationContext("fr"):\n - return getSubstitutionMappingDict()\n - - -]]></string> </value> - </item> - <item> - <key> <string>_params</string> </key> - <value> <string>event_value, **kw</string> </value> - </item> - <item> - <key> <string>id</string> </key> - <value> <string>NotificationMessage_getSubstitutionMappingDictFromEvent</string> </value> - </item> - </dictionary> - </pickle> - </record> -</ZopeData> diff --git a/bt5/erp5_free_subscription/WorkflowTemplateItem/portal_workflow/free_subscription_interaction_workflow/interactions/free_subscription_reference.xml b/bt5/erp5_free_subscription/WorkflowTemplateItem/portal_workflow/free_subscription_interaction_workflow/interactions/free_subscription_reference.xml new file mode 100644 index 0000000000..a67f645a5f --- /dev/null +++ b/bt5/erp5_free_subscription/WorkflowTemplateItem/portal_workflow/free_subscription_interaction_workflow/interactions/free_subscription_reference.xml @@ -0,0 +1,104 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="InteractionDefinition" module="Products.ERP5.Interaction"/> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>actbox_category</string> </key> + <value> <string>workflow</string> </value> + </item> + <item> + <key> <string>actbox_name</string> </key> + <value> <string></string> </value> + </item> + <item> + <key> <string>actbox_url</string> </key> + <value> <string></string> </value> + </item> + <item> + <key> <string>activate_script_name</string> </key> + <value> + <tuple/> + </value> + </item> + <item> + <key> <string>after_script_name</string> </key> + <value> + <list> + <string>setReference</string> + </list> + </value> + </item> + <item> + <key> <string>before_commit_script_name</string> </key> + <value> + <tuple/> + </value> + </item> + <item> + <key> <string>description</string> </key> + <value> <string></string> </value> + </item> + <item> + <key> <string>guard</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>free_subscription_reference</string> </value> + </item> + <item> + <key> <string>method_id</string> </key> + <value> + <list> + <string>submit</string> + <string>validate</string> + </list> + </value> + </item> + <item> + <key> <string>once_per_transaction</string> </key> + <value> <int>0</int> </value> + </item> + <item> + <key> <string>portal_type_filter</string> </key> + <value> + <list> + <string>Free Subscription</string> + <string>Free Subscription Request</string> + </list> + </value> + </item> + <item> + <key> <string>portal_type_group_filter</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>script_name</string> </key> + <value> + <tuple/> + </value> + </item> + <item> + <key> <string>temporary_document_disallowed</string> </key> + <value> <int>0</int> </value> + </item> + <item> + <key> <string>title</string> </key> + <value> <string></string> </value> + </item> + <item> + <key> <string>trigger_type</string> </key> + <value> <int>2</int> </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_free_subscription/WorkflowTemplateItem/portal_workflow/free_subscription_interaction_workflow/scripts/setReference.xml b/bt5/erp5_free_subscription/WorkflowTemplateItem/portal_workflow/free_subscription_interaction_workflow/scripts/setReference.xml new file mode 100644 index 0000000000..cf67c43302 --- /dev/null +++ b/bt5/erp5_free_subscription/WorkflowTemplateItem/portal_workflow/free_subscription_interaction_workflow/scripts/setReference.xml @@ -0,0 +1,67 @@ +<?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>_body</string> </key> + <value> <string>state_change[\'object\'].FreeSubscription_generateReference()\n +</string> </value> + </item> + <item> + <key> <string>_params</string> </key> + <value> <string>state_change, **kw</string> </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>setReference</string> </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_free_subscription/bt/version b/bt5/erp5_free_subscription/bt/version index 6da28dde76..2f4536184b 100644 --- a/bt5/erp5_free_subscription/bt/version +++ b/bt5/erp5_free_subscription/bt/version @@ -1 +1 @@ -0.1.1 \ No newline at end of file +0.2 \ No newline at end of file -- 2.30.9