Commit 7c8d9e63 authored by Sebastien Robin's avatar Sebastien Robin

first submission


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@1452 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d0d0e240
#!/usr/bin/python
# Authors : Tarek Ziade tziade@nuxeo.com
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as published
# # by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
#
boxes = {
'erp5cps_header': {'type':'Base Box',
'title': 'En-tte page ERP5',
'btype': 'header',
'provider': 'erp5cps',
'slot': 'top',
'order': 1,
},
}
guard_boxes = {'erp5cps_header': {'guard_permissions' : '',
'guard_roles' : 'Authenticated',
'guard_expr' : '',
},
}
def getBoxes():
return boxes
def getGuardBoxes():
return guard_boxes
#
# Authors : Tarek Ziade tziade@nuxeo.com
# Robin Sebastien seb@nexedi.com
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
#
""" CPS ERP5 Portal
"""
import Globals
from Globals import InitializeClass
from zLOG import LOG, INFO, DEBUG
from Products.ExternalMethod.ExternalMethod import ExternalMethod
from Products.CMFDefault.Portal import PortalGenerator
from Products.ERP5.ERP5Site import ERP5Generator
from Products.CPSDefault.Portal import CPSDefaultSite
from Products.CMFCore.utils import getToolByName
from Products.ERP5.ERP5Site import ERP5Site
from os import path
manage_addERP5CPSSiteForm = Globals.HTMLFile(
'zmi/manage_addERP5CPSSite_form',
globals())
def manage_addERP5CPSSite(dispatcher, id,
title='ERP5 CPS Site',
description='',
langs_list=None,
root_id='root',
root_sn='CPS',
root_givenName='Root',
root_email='root@localhost',
root_password1='',
root_password2='',
enable_portal_joining=1,
sql_connection_type='Z MySQL Database Connection',
sql_connection_string='test test',
REQUEST=None):
"""Add a Intranet SN Default Site."""
_log = []
def pr(bla, zlog=1, _log=_log):
if bla == 'flush':
return '\n'.join(_log)
_log.append(bla)
if (bla and zlog):
LOG('addERP5CPSSite:', INFO, bla)
if not root_password1:
raise ValueError, 'You have to fill CPS Administrator password!'
if root_password1 != root_password2:
raise ValueError, 'Password confirmation does not match password'
id = id.strip()
title = title.strip()
description = description.strip()
root_givenName = root_givenName.strip()
root_sn = root_sn.strip()
email_from_name = '%s %s' % (root_givenName, root_sn)
root_email = root_email.strip()
pr('Adding a ERP5CPS Site')
gen = ERP5CPSGenerator()
#portal = gen.create(dispatcher, id, 0,sql_connection_type,sql_connection_string)
portal = gen.create(dispatcher, id, 0)
gen.setupDefaultProperties(portal, title, description,
email_from_address=root_email,
email_from_name=email_from_name,
validate_email=0)
portal.sql_connection_type = sql_connection_type
portal.sql_connection_string = sql_connection_string
pr('Creating cpsupdate External Method in CPS Site')
cpsupdate = ExternalMethod('cpsupdate',
'CPSDefault Updater',
'CPSDefault.cpsinstall',
'cpsupdate')
portal._setObject('cpsupdate', cpsupdate)
pr('Creating benchmark External Method')
benchmarktimer = ExternalMethod('BenchmarkTimer',
'BenchmarkTimer',
'CPSDefault.benchmarktimer',
'BenchmarkTimerInstance')
portal._setObject('Benchmarktimer', benchmarktimer)
pr('Creating i18n Updater Support')
i18n_updater = ExternalMethod('i18n Updater',
'i18n Updater',
'CPSDefault.cpsinstall',
'cps_i18n_update')
portal._setObject('i18n Updater', i18n_updater)
pr('Executing CPSDefault Installer')
pr(portal.cpsupdate(langs_list=langs_list, is_creation=1 ), 0)
pr('Configuring CPSDefault Site')
# editProperties do not work with ZTC due to usage of REQUEST
# to send properties :/
# herve: REQUEST is a mapping. Have you checked using
# REQUEST={'smtp_host': 'localhost'}
# as an argument?
portal.MailHost.smtp_host = 'localhost'
portal.manage_changeProperties(smtp_server='localhost', REQUEST=None)
# Launching specific Intranet SN stuffs
pr('Launching CPS ERP5 Specifics')
ERP5CPS_installer = ExternalMethod('CPS ERP5 UPDATE',
'CPS ERP5 UPDATE',
'ERP5CPS.install',
'install')
portal._setObject('ERP5CPS_installer', ERP5CPS_installer)
pr(portal.ERP5CPS_installer(), 0)
pr('Done')
if REQUEST is not None:
REQUEST.RESPONSE.setHeader('Content-Type', 'text/plain')
return pr('flush')
class ERP5CPSSite(CPSDefaultSite,ERP5Site):
"""CPS ERP5 Site variant of a CPS Default Site.
"""
constructors = (manage_addERP5CPSSiteForm, manage_addERP5CPSSite, )
meta_type = 'ERP5 CPS Site'
icon = 'portal.gif'
enable_portal_joining = 0
_properties = CPSDefaultSite._properties
InitializeClass(ERP5CPSSite)
class ERP5CPSGenerator(PortalGenerator):
"""Set up a CPS Site."""
klass = ERP5CPSSite
<dtml-let form_title="'Add ERP5 CPS Site'">
<dtml-if manage_page_header>
<dtml-var manage_page_header>
<dtml-var manage_form_title>
<dtml-else>
<html><head><title>&dtml-form_title;</title></head>
<body>
<h2>&dtml-form_title;</h2>
</dtml-if>
</dtml-let>
<form action="manage_addERP5CPSSite" method="POST">
<table cellspacing="0" cellpadding="2" border="0">
<tr>
<td align="left" valign="top" colspan="2">
<div class="form-help">
Fill this form to create a Intranet SN Portal.
</div>
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Id
</div>
</td>
<td align="left" valign="top">
<input type="text" name="id" size="40" value="cps">
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Title
</div>
</td>
<td align="left" valign="top">
<input type="text" name="title" size="40" value="CPS Portal">
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Description
</div>
</td>
<td align="left" valign="top">
<textarea name="description" cols="60" rows="10"
style="width: 100%"></textarea>
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
CPS Administrator login
</div>
</td>
<td align="left" valign="top">
<input type="text" name="root_id" size="40" value="root">
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
CPS Administrator Name
</div>
</td>
<td align="left" valign="top">
<input type="text" name="root_sn" size="40" value="CPS">
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
CPS Administrator Given Name
</div>
</td>
<td align="left" valign="top">
<input type="text" name="root_givenName" size="40" value="Root">
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
CPS Administrator E-mail
</div>
</td>
<td align="left" valign="top">
<input type="text" name="root_email" size="40" value="root@cps">
</td>
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
CPS Administrator Password
</div>
</td>
<td align="left" valign="top">
<input type="password" name="root_password1" size="40" value="">
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
CPS Administrator Password Confirmation
</div>
</td>
<td align="left" valign="top">
<input type="password" name="root_password2" size="40" value="">
</td>
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
SQL Connection Type
</div>
</td>
<td align="left" valign="top">
<input type="text" name="sql_connection_type" size="40" value="Z MySQL Database Connection">
</td>
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
SQL Connection String
</div>
</td>
<td align="left" valign="top">
<input type="text" name="sql_connection_string" size="40" value="test test">
</td>
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Languages
</div>
</td>
<td align="left" valign="top">
<dtml-in "[('fr', 'French'),('en','English')]">
<input type="checkbox" name="langs_list:list"
value="<dtml-var sequence-key>"> <dtml-var sequence-item>
</dtml-in>
</td>
</tr>
<tr>
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<div class="form-element">
<input class="form-element" type="submit" name="submit"
value=" Add " />
</div>
</td>
</tr>
</table>
</form>
<dtml-if manage_page_footer>
<dtml-var manage_page_footer>
<dtml-else>
</body></html>
</dtml-if>
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