From 6e4b7a7c44c61d6c96eaaec5cd56d9a04d5ba9fc Mon Sep 17 00:00:00 2001
From: Mohamadou Mbengue <mmbengue@gmail.com>
Date: Mon, 28 Jun 2010 16:30:24 +0000
Subject: [PATCH] add a script in setUpEgovInstance to allow acces on Persons
 and Organisations to administrative agents

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@36651 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../SetUpEGovInstance.py                      | 24 +++++++++++++++++++
 bt5/erp5_egov/bt/change_log                   |  3 +++
 bt5/erp5_egov/bt/revision                     |  2 +-
 3 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/bt5/erp5_egov/ExtensionTemplateItem/SetUpEGovInstance.py b/bt5/erp5_egov/ExtensionTemplateItem/SetUpEGovInstance.py
index ba322d7f42..584a8c7340 100644
--- a/bt5/erp5_egov/ExtensionTemplateItem/SetUpEGovInstance.py
+++ b/bt5/erp5_egov/ExtensionTemplateItem/SetUpEGovInstance.py
@@ -33,6 +33,29 @@ from Products import ERP5Security
 from Products import PluggableAuthService
 from zLOG import LOG, WARNING, INFO
 
+
+def allowAccessOnPersonAndOrganisation(self):
+  '''use safi PAS to be able to login organisation'''
+
+  self.portal = self.getPortalObject()
+  person_portal_type = self.portal.portal_types.getTypeInfo('Person')
+  person_module_portal_type = self.portal.portal_types.getTypeInfo('Person Module')
+  organisation_portal_type = self.portal.portal_types.getTypeInfo('Organisation')
+  organisation_module_portal_type = self.portal.portal_types.getTypeInfo('Organisation Module')
+
+  portal_type_list = (person_portal_type, person_module_portal_type, organisation_portal_type, \
+                      organisation_module_portal_type)
+  role_category_list = ['role/gouvernement']
+  for ptype in portal_type_list:
+    role_info_list=[role_info.getTitle() for role_info in ptype.contentValues(portal_type='Role Information')]
+    if 'Agent Administratif' not in role_info_list:
+      ptype.newContent(portal_type='Role Information',
+                     title='Agent Administratif',
+                     role_name='Auditor',
+                     role_category_list=role_category_list)
+
+  return '- Access on Person and Organisation allowed for administrative agent'
+
 def enableEgovProcedureLogin(self, portal_type):
   '''
   set properties to enable the login on Person and Organisation
@@ -112,6 +135,7 @@ def setUpInstance(self):
   '''call all other set up method to prepare the site for eGOV Instance'''
   message_list = []
   message_list.append(setUpEGovSecurityManager(self))
+  message_list.append(allowAccessOnPersonAndOrganisation(self))
 
   message_list.append('')
   message_list.append('Set Up sequence completed')
diff --git a/bt5/erp5_egov/bt/change_log b/bt5/erp5_egov/bt/change_log
index 095ec16b7c..aa8889fbdc 100644
--- a/bt5/erp5_egov/bt/change_log
+++ b/bt5/erp5_egov/bt/change_log
@@ -1,3 +1,6 @@
+2010-06-28 mohamadou
+* add a script in setUpEgovInstance to allow acces on Persons and Organisations to administrative agents
+
 2010-06-26 mayoro
 * correct previous commit, use contentValues because  of caching method
 
diff --git a/bt5/erp5_egov/bt/revision b/bt5/erp5_egov/bt/revision
index 929530e883..876cce90b1 100644
--- a/bt5/erp5_egov/bt/revision
+++ b/bt5/erp5_egov/bt/revision
@@ -1 +1 @@
-653
\ No newline at end of file
+654
\ No newline at end of file
-- 
2.30.9