Commit 20dd426a authored by Fabien Morin's avatar Fabien Morin

2008-11-11 fabien

* modify some scripts to be able to make a subscription using the new safi form

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@24548 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b0fd6c20
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
</tuple>
</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[
"""\n
This script tries to send a message containing the credentials to the\n
person. It uses portal_notifications and the getObject API of ERP5Catalog.\n
"""\n
from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
\n
\n
translateString = context.Base_translateString\n
portal_catalog = context.portal_catalog\n
\n
# get the new person :\n
result = portal_catalog(portal_type=\'Person\',\n
title=context.getTitle(),\n
default_email_text=context.getDefaultEmailText())\n
\n
if len(result) > 1:\n
msg = "Error : There is more than one person with the title ${title} and the email ${email}"\n
msg = translateString(msg,\n
mapping=dict(title=context.getTitle(),\n
email=context.getDefaultEmailText()))\n
raise ValidationFailed, msg\n
\n
if len(result) == 0:\n
msg = "Error : No person with the title ${title} and the email ${email}"\n
msg = translateString(msg,\n
mapping=dict(title=context.getTitle(),\n
email=context.getDefaultEmailText()))\n
raise ValidationFailed, msg\n
\n
person = result[0]\n
\n
# Build the message and translate it\n
subject = translateString("Your credential for ${site_address}", mapping=dict(site_address=\'www.safi.sn\'))\n
msg = """Thanks for registrering to SAFI. Now you can connect in on ${site_address} with this credentials : \n
\n
Login : ${login}\n
Password : ${password}\n
\n
This credentials are usefull to track your application and more. Please visit ${site_address} for more information.\n
"""\n
msg = translateString(msg,\n
mapping=dict(site_address=\'www.safi.sn\',\n
login=person.getReference(),\n
password=person.getPassword())\n
)\n
\n
# We can now notify the owner through the notification tool\n
context.portal_notifications.sendMessage(recipient=person.getReference(), \n
subject=subject, message=msg, portal_type_list=(\'Person\', \'Organisation\'),\n
store_as_event=True)\n
]]></string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</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>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>Products.DCWorkflow.DCWorkflow</string>
<string>ValidationFailed</string>
<string>_getattr_</string>
<string>context</string>
<string>translateString</string>
<string>portal_catalog</string>
<string>result</string>
<string>len</string>
<string>msg</string>
<string>dict</string>
<string>_getitem_</string>
<string>person</string>
<string>subject</string>
<string>True</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Person_sendCrendentialsByEMail</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -58,8 +58,25 @@ ...@@ -58,8 +58,25 @@
portal = changed_object.getPortalObject()\n portal = changed_object.getPortalObject()\n
organisation_module = portal.getDefaultModule(portal_type=\'Organisation\')\n organisation_module = portal.getDefaultModule(portal_type=\'Organisation\')\n
\n \n
# create the person wich represent the company\n
person_module = portal.getDefaultModule(portal_type=\'Person\')\n
accountant = person_module.newContent(portal_type=\'Person\',\n
title=changed_object.getAccountantName(),\n
default_telephone_text=changed_object.getAccountantTelNumber(),\n
default_fax_text=changed_object.getAccountantFax(),\n
default_email_text=changed_object.getAccountantEmail(),\n
address_street_address=changed_object.getAccountantAddress(),\n
address_city=changed_object.getAccountantCity(),\n
default_address_region=changed_object.getAccountantCountry())\n
if changed_object.getOptionAdministrator():\n
accountant.setFunction(\'entreprise/directeur/pdg/administrateur\')\n
elif changed_object.getOptionManager():\n
accountant.setFunction(\'entreprise/directeur/pdg/gerant\')\n
elif changed_object.getOptionDirector():\n
accountant.setFunction(\'entreprise/directeur/pdg/pdg\')\n
\n
result = changed_object.portal_catalog(portal_type=\'Organisation\',\n result = changed_object.portal_catalog(portal_type=\'Organisation\',\n
corporate_registration_code=changed_object.getRccm())\n vat_code=changed_object.getNineaNumber())\n
\n \n
# if the organisation don\'t exists, create it\n # if the organisation don\'t exists, create it\n
if not len(result):\n if not len(result):\n
...@@ -67,26 +84,24 @@ if not len(result):\n ...@@ -67,26 +84,24 @@ if not len(result):\n
portal_type=\'Organisation\',\n portal_type=\'Organisation\',\n
title=changed_object.getCompanyName(),\n title=changed_object.getCompanyName(),\n
corporate_name=changed_object.getCompanyName(),\n corporate_name=changed_object.getCompanyName(),\n
address_street_address=changed_object.getAddressStreetAddress(),\n address_street_address=changed_object.getCompanyAddress(),\n
address_zip_code=changed_object.getAddressZipCode(),\n address_city=changed_object.getCityName(),\n
address_city=changed_object.getAddressCity(),\n address_region=changed_object.getCountryName(),\n
address_region=changed_object.getAddressRegion(),\n corporate_registration_code=changed_object.getRccmNumber(),\n
corporate_registration_code=changed_object.getRccm(),\n vat_code=changed_object.getNineaNumber(),\n
vat_code=changed_object.getNinea(),\n default_email_text=changed_object.getCompanyEmail(),\n
default_email_text=changed_object.getEmail(),\n
activity_kw={\'tag\':\'organisation_creation_%s\' % changed_object.getRelativeUrl()}\n
)\n )\n
else:\n else:\n
organisation = result[0].getObject()\n organisation = result[0].getObject()\n
\n \n
# set the login and password required a manager role, so a script with a \n # set the login and password required a manager role, so a script with a \n
# proxy role is used\n # proxy role is used\n
login = context.generateNewLogin(text=changed_object.getCompanyName())\n login = context.generateNewLogin(text=changed_object.getAccountantName())\n
password = changed_object.Person_generatePassword()\n password = changed_object.Person_generatePassword()\n
context.EGov_setLoginAndPasswordAsManager(organisation, login, password)\n context.EGov_setLoginAndPasswordAsManager(accountant, login, password)\n
organisation.immediateReindexObject()\n accountant.immediateReindexObject()\n
\n \n
organisation.Organisation_sendCrendentialsByEMail()\n accountant.Person_sendCrendentialsByEMail()\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -135,6 +150,8 @@ organisation.Organisation_sendCrendentialsByEMail()\n ...@@ -135,6 +150,8 @@ organisation.Organisation_sendCrendentialsByEMail()\n
<string>_getattr_</string> <string>_getattr_</string>
<string>portal</string> <string>portal</string>
<string>organisation_module</string> <string>organisation_module</string>
<string>person_module</string>
<string>accountant</string>
<string>result</string> <string>result</string>
<string>len</string> <string>len</string>
<string>organisation</string> <string>organisation</string>
......
...@@ -59,13 +59,12 @@ changed_object = state_change[\'object\']\n ...@@ -59,13 +59,12 @@ changed_object = state_change[\'object\']\n
translateString = changed_object.Base_translateString\n translateString = changed_object.Base_translateString\n
login = changed_object.getCompanyName().lower()\n login = changed_object.getCompanyName().lower()\n
portal_catalog = changed_object.portal_catalog\n portal_catalog = changed_object.portal_catalog\n
ninea = changed_object.getNinea()\n ninea = changed_object.getNineaNumber()\n
\n \n
# check that no existing organisation have the same NINEA number or login\n # check that no existing organisation have the same NINEA number or login\n
from Products.DCWorkflow.DCWorkflow import ValidationFailed\n from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
\n \n
result = portal_catalog( portal_type=\'Organisation\',\n result = portal_catalog(portal_type=\'Organisation\', vat_code=ninea)\n
vat_code=changed_object.getNinea())\n
\n \n
if len(result) > 1:\n if len(result) > 1:\n
msg = "Error : There is more than one company with the NINEA code ${code}"\n msg = "Error : There is more than one company with the NINEA code ${code}"\n
......
2008-11-11 fabien
* modify some scripts to be able to make a subscription using the new safi form
2008-11-03 fabien 2008-11-03 fabien
* add an interaction to raise an error on subscription submission if an account already exists * add an interaction to raise an error on subscription submission if an account already exists
* add a default parameter to NOT be in editable mode * add a default parameter to NOT be in editable mode
......
439 444
\ 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