Commit cfaf6369 authored by Fabien Morin's avatar Fabien Morin

* remove unused lines in MyDocuments_listMethod

* change behaviour in case of Subscription Form with an existing organisation
or with existing acount in existing organisation
* add the exetention ERP5EGov_Extensions wich will contain all ERP5EGov generic
extenal methods

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@21366 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 8bbf0b5a
from zLOG import LOG
def sendCrendentialsByEMail(self, login, password, user_email):
activity_tool = self.getPortalObject().portal_activities
from Products.MailHost.MailHost import MailHostError
from Products.CMFActivity.ActivityTool import Message
import socket
portal = activity_tool.getPortalObject()
mail_text="""From: %s
To: %s
Subject: %s
Thanks for registrering to SAFI, now you can connect in on www.safi.sn with the followin credentials :
Login: %s
Password: %s
""" % ('fabien@nexedi.com', user_email, 'your credential for www.safi.sn',
login, password)
try:
activity_tool.MailHost.send( mail_text )
except (socket.error, MailHostError), message:
LOG('ActivityTool.notifyUser', 0, 'Mail containing failure information failed to be sent: %s.' % (message))
def getPoralTypeListForWorkflow(self, workflow):
'''
return a list of portal_types that use workflow
'''
pw = self.portal_workflow
cbt = pw._chains_by_type
ti = pw._listTypeInfo()
portal_type_list = []
for t in ti:
id = t.getId()
if cbt is not None and cbt.has_key(id) and workflow in cbt[id]:
portal_type_list.append(id)
return portal_type_list
def getPortalTypeWorklistDictForWorkflow(self, workflow):
"""
return a dict containing portal_type and all informations about work_list
of workflow :
{ 'Declaration TVA': { 'id':'applications_to_submit',
'description':'Applications to submit',
'validation_state':'draft',
'formated_name':'Applications to submit (%(count)s)'
'formated_url':'Base_viewSearchResultList?validation_state=submitted&local_roles=%(local_roles)s&reset=1&portal_type=%(portal_type)s',
'category':'global',
'count':2,
'roles':['Owner'],
},
.....
}
"""
portal_type_list = self.getPoralTypeListForWorkflow(self, workflow=workflow)
portal_workflow = self.getPortalObject().portal_workflow
workflow = getattr(portal_workflow, workflow, None)
portal_type_worklist_dict = {}
if workflow is not None:
worklist_dict = workflow.worklists._mapping
for portal_type in portal_type_list:
for worklist_id, worklist in worklist_dict.items():
state = None
if worklist.var_matches.has_key('validation_state'):
state=worklist.var_matches['validation_state']
local_role_list=worklist.guard.roles
if state is None:
continue
result = self.getPortalObject().portal_catalog(portal_type=portal_type,
local_roles=local_role_list,
validation_state=state)
if not len(result):
continue
if not portal_type_worklist_dict.has_key(portal_type):
portal_type_worklist_dict[portal_type] = {}
portal_type_worklist_dict[portal_type][worklist_id] = {}
result_dict = portal_type_worklist_dict[portal_type][worklist_id]
result_dict['id']=worklist_id
result_dict['count']=len(result)
result_dict['description']=worklist.description
result_dict['validation_state']=state
result_dict['formated_name']=worklist.actbox_name
result_dict['formated_url']=worklist.actbox_url
result_dict['formated_url']='Base_viewSearchResultList?validation_state=%s&local_roles=%s&reset=1&portal_type=%s'\
% (state[0], local_role_list[0], portal_type)
result_dict['category']=worklist.actbox_category
result_dict.update(worklist.guard.__dict__)
return portal_type_worklist_dict
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="WebSite" module="Products.ERP5Type.Document.WebSite"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>__before_publishing_traverse__</string> </key>
<value>
<object>
<klass>
<global name="MultiHook" module="ZPublisher.BeforeTraverse"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_defined_in_class</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>_hookname</string> </key>
<value> <string>__before_publishing_traverse__</string> </value>
</item>
<item>
<key> <string>_list</string> </key>
<value>
<list>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</list>
</value>
</item>
<item>
<key> <string>_prior</string> </key>
<value>
<none/>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>__before_traverse__</string> </key>
<value>
<dictionary>
<item>
<key>
<tuple>
<int>99</int>
<string>ERP5 Web Site/dgid</string>
</tuple>
</key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>webmaster</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>container_layout</string> </key>
<value> <string>erp5_egov_dgid_agent_workspace_layout</string> </value>
</item>
<item>
<key> <string>content_layout</string> </key>
<value> <string>erp5_egov_dgid_agent_form_layout</string> </value>
</item>
<item>
<key> <string>custom_render_method_id</string> </key>
<value> <string>WebSection_dgid_agent_renderEGovPortal</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>This portal provides to agents an access to their workspace.</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>dgid</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Site</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value> <string>DGID Agent Workspace</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>ERP5 eGov DGID Agent Workspace</string> </value>
</item>
<item>
<key> <string>uid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>webmaster</string> </key>
<value> <string>admin</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<global name="WebSiteTraversalHook" module="Products.ERP5Type.Document.WebSite"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary/>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="ExternalMethod" module="Products.ExternalMethod.ExternalMethod"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_function</string> </key>
<value> <string>getPoralTypeListForWorkflow</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>ERP5EGov_Extensions</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>getPoralTypeListForWorkflow</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="ExternalMethod" module="Products.ExternalMethod.ExternalMethod"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_function</string> </key>
<value> <string>getPortalTypeWorklistDictForWorkflow</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>ERP5EGov_Extensions</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>getPortalTypeWorklistDictForWorkflow</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -65,18 +65,13 @@ ...@@ -65,18 +65,13 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>document_module = context.portal_url.getPortalObject().getDefaultModule(\'document_module\')\n <value> <string># get user name\n
\n
# get user name\n
user_name = context.portal_membership.getAuthenticatedMember().getUserName()\n user_name = context.portal_membership.getAuthenticatedMember().getUserName()\n
\n \n
return context.portal_catalog(portal_type=context.getPortalDocumentTypeList(), \n return context.portal_catalog(portal_type=context.getPortalDocumentTypeList(), \n
sort_on=\'creation_date\', \n sort_on=\'creation_date\', \n
sort_order=\'reverse\',\n sort_order=\'reverse\',\n
owner=user_name);\n owner=user_name);\n
\n
#document_module.searchFolder(portal_type=context.getPortalDocumentTypeList(), \n
# owner=user_name)\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -129,7 +124,6 @@ return context.portal_catalog(portal_type=context.getPortalDocumentTypeList(), \ ...@@ -129,7 +124,6 @@ return context.portal_catalog(portal_type=context.getPortalDocumentTypeList(), \
<string>kw</string> <string>kw</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>document_module</string>
<string>user_name</string> <string>user_name</string>
</tuple> </tuple>
</value> </value>
......
...@@ -79,7 +79,7 @@ ...@@ -79,7 +79,7 @@
<key> <string>script_name</string> </key> <key> <string>script_name</string> </key>
<value> <value>
<list> <list>
<string>check_companyInexistance</string> <string>checkAccountInexistance</string>
</list> </list>
</value> </value>
</item> </item>
......
...@@ -65,7 +65,9 @@ ...@@ -65,7 +65,9 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>organisation.setPassword(password)\n <value> <string>organisation.setRole(\'registry/entreprise\') #XXX this should not be hardcoded\n
organisation.setReference(login)\n
organisation.setPassword(password)\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -82,7 +84,7 @@ ...@@ -82,7 +84,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>organisation, password</string> </value> <value> <string>organisation, login, password</string> </value>
</item> </item>
<item> <item>
<key> <string>_proxy_roles</string> </key> <key> <string>_proxy_roles</string> </key>
...@@ -110,13 +112,14 @@ ...@@ -110,13 +112,14 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>co_argcount</string> </key> <key> <string>co_argcount</string> </key>
<value> <int>2</int> </value> <value> <int>3</int> </value>
</item> </item>
<item> <item>
<key> <string>co_varnames</string> </key> <key> <string>co_varnames</string> </key>
<value> <value>
<tuple> <tuple>
<string>organisation</string> <string>organisation</string>
<string>login</string>
<string>password</string> <string>password</string>
<string>_getattr_</string> <string>_getattr_</string>
</tuple> </tuple>
...@@ -135,7 +138,7 @@ ...@@ -135,7 +138,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>EGov_setPasswordAsManager</string> </value> <value> <string>EGov_setLoginAndPasswordAsManager</string> </value>
</item> </item>
<item> <item>
<key> <string>warnings</string> </key> <key> <string>warnings</string> </key>
......
...@@ -70,9 +70,12 @@ ...@@ -70,9 +70,12 @@
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
login = changed_object.getCompanyName().lower()\n result = changed_object.portal_catalog(portal_type=\'Organisation\',\n
corporate_registration_code=changed_object.getRccm())\n
\n \n
new_organisation = organisation_module.newContent(\\\n # if the organisation don\'t exists, create it\n
if not len(result):\n
organisation = organisation_module.newContent(\\\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
...@@ -80,21 +83,22 @@ new_organisation = organisation_module.newContent(\\\n ...@@ -80,21 +83,22 @@ new_organisation = organisation_module.newContent(\\\n
address_zip_code=changed_object.getAddressZipCode(),\n address_zip_code=changed_object.getAddressZipCode(),\n
address_city=changed_object.getAddressCity(),\n address_city=changed_object.getAddressCity(),\n
address_region=changed_object.getAddressRegion(),\n address_region=changed_object.getAddressRegion(),\n
corporate_registration_code=changed_object.getNinea(),\n corporate_registration_code=changed_object.getRccm(),\n
role=\'registry/entreprise\', #XXX this should not be hardcoded\n vat_code=changed_object.getNinea())\n
reference=login)\n else:\n
\n organisation = result[0].getObject()\n
\n \n
# set the password required a manager role, so a script with a proxy role is\n # set the login and password required a manager role, so a script with a \n
# used\n # proxy role is used\n
login = changed_object.getCompanyName().lower()\n
password = changed_object.Person_generatePassword()\n password = changed_object.Person_generatePassword()\n
context.EGov_setPasswordAsManager(new_organisation, password)\n context.EGov_setLoginAndPasswordAsManager(organisation, login, password)\n
\n \n
# here, call a method to send credentials by email\n # here, call a method to send credentials by email\n
# XXX in the future, it should be possible to chose the mean to receive\n # XXX in the future, it should be possible to chose the mean to receive\n
# credentials (email, sms, postal mail)\n # credentials (email, sms, postal mail)\n
user_email = changed_object.getEmail()\n user_email = changed_object.getEmail()\n
changed_object.sendCrendentialsByEMail(login, password, user_email)\n context.sendCrendentialsByEMail(login, password, user_email)\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -149,8 +153,10 @@ changed_object.sendCrendentialsByEMail(login, password, user_email)\n ...@@ -149,8 +153,10 @@ changed_object.sendCrendentialsByEMail(login, password, user_email)\n
<string>_getattr_</string> <string>_getattr_</string>
<string>portal</string> <string>portal</string>
<string>organisation_module</string> <string>organisation_module</string>
<string>result</string>
<string>len</string>
<string>organisation</string>
<string>login</string> <string>login</string>
<string>new_organisation</string>
<string>password</string> <string>password</string>
<string>context</string> <string>context</string>
<string>user_email</string> <string>user_email</string>
......
...@@ -65,21 +65,31 @@ ...@@ -65,21 +65,31 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>changed_object = state_change[\'object\']\n <value> <string encoding="cdata"><![CDATA[
changed_object = state_change[\'object\']\n
login = changed_object.getCompanyName().lower()\n login = changed_object.getCompanyName().lower()\n
\n \n
# check that no existing organisation have the same RCCM number or login\n # check that no existing organisation have the same RCCM number or login\n
from Products.DCWorkflow.DCWorkflow import ValidationFailed\n from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
if len(changed_object.portal_catalog(portal_type=\'Organisation\',\n \n
corporate_registration_code=changed_object.getNinea())):\n result = changed_object.portal_catalog(portal_type=\'Organisation\',\n
corporate_registration_code=changed_object.getRccm())\n
if len(result) > 1:\n
raise ValidationFailed, "Error : There is more than one company with the "\\\n
" registration code \'%s\'" % changed_object.getRccm()\n
\n
if len(result) and result[0].getObject().getReference():\n
raise ValidationFailed, "Error : A company with the registration code \'%s\'"\\\n raise ValidationFailed, "Error : A company with the registration code \'%s\'"\\\n
" already exists" % changed_object.getNinea()\n " already exists and have already an account" % changed_object.getRccm()\n
\n \n
if len((changed_object.portal_catalog(portal_type=\'Organisation\',\n if len((changed_object.portal_catalog(portal_type=\'Organisation\',\n
reference=login))):\n reference=login))):\n
raise ValidationFailed, "Error : A company with the login \'%s\'"\\\n raise ValidationFailed, "Error : A company with the login \'%s\'"\\\n
" already exists" % login\n " already exists" % login\n
</string> </value>
]]></string> </value>
</item> </item>
<item> <item>
<key> <string>_code</string> </key> <key> <string>_code</string> </key>
...@@ -128,6 +138,7 @@ if len((changed_object.portal_catalog(portal_type=\'Organisation\',\n ...@@ -128,6 +138,7 @@ if len((changed_object.portal_catalog(portal_type=\'Organisation\',\n
<string>login</string> <string>login</string>
<string>Products.DCWorkflow.DCWorkflow</string> <string>Products.DCWorkflow.DCWorkflow</string>
<string>ValidationFailed</string> <string>ValidationFailed</string>
<string>result</string>
<string>len</string> <string>len</string>
</tuple> </tuple>
</value> </value>
...@@ -145,7 +156,7 @@ if len((changed_object.portal_catalog(portal_type=\'Organisation\',\n ...@@ -145,7 +156,7 @@ if len((changed_object.portal_catalog(portal_type=\'Organisation\',\n
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>check_companyInexistance</string> </value> <value> <string>checkAccountInexistance</string> </value>
</item> </item>
<item> <item>
<key> <string>warnings</string> </key> <key> <string>warnings</string> </key>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="ExternalMethod" module="Products.ExternalMethod.ExternalMethod"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_function</string> </key>
<value> <string>sendCrendentialsByEMail</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>ERP5EGov_Extensions</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>sendCrendentialsByEMail</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
127 143
\ No newline at end of file \ No newline at end of file
StandardSecurity StandardSecurity
Captcha Captcha
ERP5EGov_Extensions
\ No newline at end of file
web_page_module/* web_page_module/*
web_site_module/dgid
web_site_module/dgid/*
web_site_module/egov_portal web_site_module/egov_portal
web_site_module/egov_portal/* web_site_module/egov_portal/*
\ 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