Commit dd8f8c89 authored by Aurel's avatar Aurel

free subscription : test reference initialization & make it customizable easily

parent 10d66803
......@@ -6,5 +6,6 @@
<portal_type id="Free Subscription Request">
<item>Arrow</item>
<item>DublinCore</item>
<item>Reference</item>
</portal_type>
</property_sheet_list>
\ No newline at end of file
<?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>portal = context.getPortalObject()\n
if context.getSource():\n
generator_base = "free_subscription_request"\n
reference_base = "FSR"\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>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Assignor</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>FreeSubscriptionRequest_generateReference</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -52,15 +52,9 @@
<key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\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
generator_base = "free_subscription"\n
reference_base = "FS"\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
......
<?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>
......@@ -50,13 +50,21 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>state_change[\'object\'].FreeSubscription_generateReference()\n
<value> <string>state_change[\'object\'].getTypeBasedMethod(\'generateReference\')()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change, **kw</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Assignor</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>setReference</string> </value>
......
Free Subscription Request | Arrow
Free Subscription Request | DublinCore
Free Subscription Request | Reference
Free Subscription | DublinCore
Free Subscription | Version
\ No newline at end of file
......@@ -46,7 +46,7 @@ if use_verbose_security:
class TestFreeSubscription(ERP5TypeTestCase):
def getTitle(self):
return "ERP5 Credential"
return "Free Subscription"
def getBusinessTemplateList(self):
return (
......@@ -101,6 +101,7 @@ class TestFreeSubscription(ERP5TypeTestCase):
self.portal.getDefaultModule('Free Subscription'),
self.portal.getDefaultModule('Organisation'),
self.portal.getDefaultModule('Service'),
self.portal.getDefaultModule('Letter'),
self.portal.getDefaultModule('Person'))
for module in module_list:
module.manage_delObjects(list(module.objectIds()))
......@@ -166,6 +167,7 @@ class TestFreeSubscription(ERP5TypeTestCase):
self.assertNotEquals(request.getFollowUp(), None)
subscription = request.getFollowUpValue()
self.assertEquals(subscription.getValidationState(), "validated")
self.assertNotEquals(subscription.getReference(), None)
def stepSubmitFreeSubscriptionRequest(self, sequence=None, sequence_list=None):
request = sequence['free_subscription_request']
......@@ -174,6 +176,7 @@ class TestFreeSubscription(ERP5TypeTestCase):
def stepCheckSubmittedFreeSubscriptionRequest(self, sequence=None, sequence_list=None):
request = sequence['free_subscription_request']
self.assertEquals(request.getValidationState(), 'submitted')
self.assertNotEquals(request.getReference(), None)
def stepAcceptFreeSubscriptionRequest(self, sequence=None, sequence_list=None):
request = sequence['free_subscription_request']
......@@ -182,6 +185,7 @@ class TestFreeSubscription(ERP5TypeTestCase):
def stepCheckAcceptedFreeSubscriptionRequest(self, sequence=None, sequence_list=None):
request = sequence['free_subscription_request']
self.assertEquals(request.getValidationState(), 'accepted')
self.assertNotEquals(request.getReference(), None)
def stepRejectFreeSubscriptionRequest(self, sequence=None, sequence_list=None):
request = sequence['free_subscription_request']
......
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