Commit a8fb43f0 authored by Yoshinori Okuji's avatar Yoshinori Okuji

unused


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@20721 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 41bcedc6
# (C) Copyright 2004 Nexedi SARL <http://nexedi.com>
# Authors: Sebastien Robin <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.
#
from Products.CPSCore.ProxyBase import ProxyBase, ProxyFolder
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions
from Globals import InitializeClass
from Products.ERP5Type.Base import Base
from Products.ERP5Type.Document.Folder import Folder
from Products.CMFCore.CMFCorePermissions import View
from Products.CMFCore.CMFCorePermissions import ModifyPortalContent
from Products.CMFCore.CMFCorePermissions import ViewManagementScreens
from Products.CMFCore.utils import getToolByName
from zLOG import LOG
# First we should make ProxyBase a subclass of Base
# XXX doesn't works at all
#ProxyBase.__bases__ += (ERP5Base,)
#ProxyDocument.__bases__ += (ERP5Base,)
class PatchedProxyBase(ProxyBase):
security = ClassSecurityInfo()
def manage_afterEdit(self):
"""
We have to notify the proxy tool we have modified
this object
"""
px_tool= getToolByName(self,'portal_proxies')
utool = getToolByName(self, 'portal_url')
rpath = utool.getRelativeUrl(self)
px_tool._modifyProxy(self,rpath)
def _propertyMap(self):
"""
Returns fake property sheet
"""
property_sheet = []
#property_sheet += self._properties
property_sheet += [
{
'id' : 'docid',
'type' : 'string'
},
{
'id' : 'default_language',
'type' : 'string'
},
{
'id' : 'default_language',
'type' : 'string'
},
{
'id' : 'sync_language_revisions', # XXX we have to manage dict type
'type' : 'dict'
}
]
return tuple(property_sheet + list(getattr(self, '_local_properties', ())))
security.declareProtected(View, 'getSyncLanguageRevisions')
def getSyncLanguageRevisions(self):
"""Get the mapping of language -> revision."""
return self._language_revs.copy()
security.declareProtected(View, 'setSyncLanguageRevisions')
def setSyncLanguageRevisions(self, dict):
"""Set the mapping of language -> revision."""
for lang in dict.keys():
self.setLanguageRevision(lang,dict[lang])
security.declareProtected(View, 'getSyncRepoHistory')
def getSyncRepoHistory(self):
"""Get the mapping of language -> revision."""
return self._language_revs.copy()
security.declareProtected(View, 'setSyncRepoHistory')
def setSyncRepoHistory(self, dict):
"""Set the mapping of language -> revision."""
repotool = getToolByName(self, 'portal_repository')
#repotool.
for lang in dict.keys():
self.setLanguageRevision(lang,dict[lang])
ProxyBase.getPath = Base.getPath
ProxyBase.getProperty = Base.getProperty
ProxyBase._setProperty = Base._setProperty
ProxyBase._edit = Base._edit
ProxyBase.asXML = Base.asXML
ProxyBase._propertyMap = PatchedProxyBase._propertyMap
ProxyBase.manage_afterEdit = PatchedProxyBase.manage_afterEdit
ProxyBase.getSyncLanguageRevisions = PatchedProxyBase.getSyncLanguageRevisions
ProxyBase.setSyncLanguageRevisions = PatchedProxyBase.setSyncLanguageRevisions
ProxyBase.getSyncRepoHistory = PatchedProxyBase.getSyncRepoHistory
ProxyBase.setSyncRepoHistory = PatchedProxyBase.setSyncRepoHistory
ProxyFolder.asXML = Folder.asXML
ProxyFolder.manage_setLocalPermissions = Folder.manage_setLocalPermissions
ProxyFolder.get_local_permissions = Folder.get_local_permissions
from Products.CPSCore.CPSBase import CPSBaseDocument
class PatchedCPSBaseDocument(CPSBaseDocument):
security = ClassSecurityInfo()
def _propertyMap(self):
"""
Returns fake property sheet
"""
property_sheet = []
property_sheet += self._properties
property_sheet += [
{
'id' : 'Title',
'type' : 'string'
},
{
'id' : 'description',
'type' : 'string'
},
]
return tuple(property_sheet + list(getattr(self, '_local_properties', ())))
CPSBaseDocument.getPath = Base.getPath
CPSBaseDocument.getProperty = Base.getProperty
CPSBaseDocument._setProperty = Base._setProperty
CPSBaseDocument._edit = Base._edit
CPSBaseDocument.asXML = Base.asXML
CPSBaseDocument.get_local_permissions = Base.get_local_permissions
CPSBaseDocument.manage_setLocalPermissions = Base.manage_setLocalPermissions
CPSBaseDocument._propertyMap = PatchedCPSBaseDocument._propertyMap
# (C) Copyright 2004 Nexedi SARL <http://nexedi.com>
# Authors: Sebastien Robin <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.
#
from Products.CPSDocument.CPSDocument import CPSDocument
from Products.CPSSchemas.BasicFields import CPSImageField, CPSFileField, CPSDateTimeField
from Products.CPSSchemas.BasicFields import CPSStringField, CPSIntField
from Products.ERP5Type.Base import Base
from Products.ERP5Type.Utils import UpperCase
from Acquisition import aq_base, aq_inner
from AccessControl import ClassSecurityInfo
from Products.CMFCore.CMFCorePermissions import View
from zLOG import LOG
class PatchedCPSDocument(CPSDocument):
security = ClassSecurityInfo()
security.declareProtected( View, '_propertyMap' )
def _propertyMap(self):
"""
Returns fake property sheet
"""
property_sheet = []
property_sheet.append(
{
'id' : 'layout_and_schema',
'type' : 'object'
}
)
property_sheet.append(
{
'id' : 'cps_frozen',
'type' : 'int'
}
)
type_info = self.getTypeInfo()
field_list = []
if type_info is not None:
if hasattr(type_info,'getDataModel'):
data_model = type_info.getDataModel(self)
if data_model is not None:
field_list = data_model._fields.items()
field_list.sort()
for (prop_id,field) in field_list:
f_type = None
if isinstance(field,CPSImageField):
f_type = 'object'
elif isinstance(field,CPSStringField):
f_type = 'string'
elif isinstance(field,CPSDateTimeField):
f_type = 'date'
elif isinstance(field,CPSFileField):
f_type = 'object'
elif isinstance(field,CPSIntField):
f_type = 'int'
elif isinstance(field,CPSDocument):
pass
if prop_id.find('attachedFile')==0:
f_type='object' # In a flexible content, we do have some attachedFile_f1
# which are CPStringFiels with some binary data
# XXX This should NOT BE NEEDED!!
if f_type is not None:
property_sheet.append(
{
'id' : prop_id,
'type' : f_type
}
)
return tuple(property_sheet + list(getattr(self, '_local_properties', ())))
security.declareProtected( View, 'getProperty' )
def getProperty(self, key, d=None):
"""
Previous Name: getValue
Generic accessor. Calls the real accessor
"""
accessor_name = 'get' + UpperCase(key)
base = aq_base(self)
data_model = None
if hasattr(self,'getTypeInfo'):
type_info = self.getTypeInfo()
if hasattr(type_info,'getDataModel'):
data_model = self.getTypeInfo().getDataModel(self)
if data_model is not None and data_model.has_key(key):
return data_model.get(key)
elif hasattr(base,accessor_name):
method = getattr(base,accessor_name)
return method()
return None
security.declarePrivate('getLayoutAndSchema' )
def getLayoutAndSchema(self):
if hasattr(self,'.cps_layouts') and hasattr(self,'.cps_schemas'):
return (aq_base(self._getOb(".cps_layouts")),aq_base(self._getOb(".cps_schemas")))
return None
security.declarePrivate('setLayoutAndSchema' )
def setLayoutAndSchema(self, data):
"""
data must be : (layout,schema)
"""
if data is not None:
self._setOb(".cps_layouts",data[0])
self._setOb(".cps_schemas",data[1])
security.declarePrivate('_setProperty' )
def _setProperty(self, key, value, type='string'):
"""
Set the property for cps objects
"""
LOG('PatchCPSDoc._setProperty',0,'key: %s, value: %s' % (repr(key),repr(value)))
accessor_name = 'set' + UpperCase(key)
if hasattr(aq_base(self),accessor_name):
method = getattr(self, accessor_name)
return method(value)
else:
setattr(self,key,value)
# This solution below doesn't works well, it is better
# to just set the attribute.
#data_model = self.getTypeInfo().getDataModel(self)
#type_info = self.getTypeInfo()
#kw = {key:value}
#type_info.editObject(self,kw)
security.declarePrivate('edit' )
def edit(self, REQUEST=None, force_update = 0, reindex_object = 0, **kw):
return self._edit(REQUEST=REQUEST, force_update=force_update, reindex_object=reindex_object, **kw)
# Object attributes update method
security.declarePrivate( '_edit' )
def _edit(self, REQUEST=None, force_update = 0, reindex_object = 0, **kw):
"""
Generic edit Method for all ERP5 object
The purpose of this method is to update attributed, eventually do
some kind of type checking according to the property sheet and index
the object.
Each time attributes of an object are updated, they should
be updated through this generic edit method
"""
LOG('PatchCPSDoc._edit, kw: ',0,kw)
try:
categoryIds = self._getCategoryTool().getBaseCategoryIds()
except:
categoryIds = []
#if kw.has_key('layout_and_schema'):
# self.setLayoutAndSchema(kw['layout_and_schema'])
for key in kw.keys():
accessor = 'get' + UpperCase(key)
#if key in categoryIds:
# self._setCategoryMembership(key, kw[key])
#if key != 'id' and key!= 'layout_and_schema':
if key != 'id' :
# We only change if the value is different
# This may be very long....
self._setProperty(key, kw[key])
def getCoverage(self):
"""
"""
if hasattr(self,'coverage'):
return self.coverage
return None
def getCreator(self):
"""
"""
#if hasattr(self,'coverage'):
# return self.coverage
return None
def getRelation(self):
"""
"""
if hasattr(self,'relation'):
return self.relation
return None
def setRelation(self,value):
"""
"""
setattr(self,'relation',value)
def getSource(self):
"""
"""
if hasattr(self,'source'):
return self.source
return None
def getPreview(self):
"""
"""
if hasattr(self,'preview'):
return self.preview
return None
def setCreator(self,value):
"""
"""
setattr(self,'creator',value)
def setCreationDate(self,value):
"""
"""
setattr(self,'creation_date',value)
def setCpsFrozen(self, data):
"""
setter for cps frozen property in order to now
if an object is frozen or not
"""
setattr(self,'_cps_frozen',data)
def getCpsFrozen(self):
"""
getter for cps frozen property in order to now
if an object is frozen or not
"""
return getattr(self,'_cps_frozen',0)
CPSDocument.getCoverage = getCoverage
CPSDocument.getCreator = getCreator
CPSDocument.getRelation = getRelation
CPSDocument.setCreator = setCreator
CPSDocument.setRelation = setRelation
CPSDocument.getSource = getSource
CPSDocument.getCpsFrozen = getCpsFrozen
CPSDocument.setCpsFrozen = setCpsFrozen
CPSDocument.getPreview = getPreview
CPSDocument.setCreationDate = setCreationDate
CPSDocument.getProperty = PatchedCPSDocument.getProperty
CPSDocument.getLayoutAndSchema = PatchedCPSDocument.getLayoutAndSchema
CPSDocument.setLayoutAndSchema = PatchedCPSDocument.setLayoutAndSchema
CPSDocument._propertyMap = PatchedCPSDocument._propertyMap
CPSDocument.setProperty = Base.setProperty
CPSDocument._setProperty = PatchedCPSDocument._setProperty
CPSDocument.get_local_permissions = Base.get_local_permissions
CPSDocument.asXML = Base.asXML
CPSDocument.manage_setLocalPermissions = Base.manage_setLocalPermissions
CPSDocument._edit = PatchedCPSDocument._edit
#!/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
from Products.ERP5SyncML.Conduit.ERP5Conduit import ERP5Conduit
def main(self):
xml_workspace = """<erp5><object id="1320758020__0001" portal_type="Workspace">
<layout_and_schema type="object">None</layout_and_schema>
<Coverage type="string"></Coverage>
<CreationDate type="date">2004-06-01 12:57:21</CreationDate>
<Creator type="string">seb</Creator>
<Description type="string"></Description>
<EffectiveDate type="date">None</EffectiveDate>
<ExpirationDate type="date">None</ExpirationDate>
<Format type="string">text/html</Format>
<Language type="string">en</Language>
<ModificationDate type="date">2004-06-01 12:57:21</ModificationDate>
<Relation type="string"></Relation>
<Rights type="string"></Rights>
<Source type="string"></Source>
<Title type="string">Root of Workspaces</Title>
<allow_discussion type="int">0</allow_discussion>
<hidden_folder type="int">0</hidden_folder>
<preview type="object">None</preview>
<local_role id="seb" type="tokens">permission:Modify_portal_content</local_role>
</object>
</erp5>"""
xml_section = """<erp5><object id="628256376__0001" portal_type="Section">
<layout_and_schema type="object">None</layout_and_schema>
<Coverage type="string"></Coverage>
<CreationDate type="date">2004-06-01 12:57:21</CreationDate>
<Creator type="string">seb</Creator>
<Description type="string"></Description>
<EffectiveDate type="date">None</EffectiveDate>
<ExpirationDate type="date">None</ExpirationDate>
<Format type="string">text/html</Format>
<Language type="string">en</Language>
<ModificationDate type="date">2004-06-01 12:57:21</ModificationDate>
<Relation type="string"></Relation>
<Rights type="string"></Rights>
<Source type="string"></Source>
<Title type="string">Root of Sections</Title>
<allow_discussion type="int">0</allow_discussion>
<hidden_folder type="int">0</hidden_folder>
<preview type="object">None</preview>
</object>
</erp5>"""
portal_repository = self.portal_repository
conduit = ERP5Conduit()
conduit.addNode(xml=xml_workspace,object=portal_repository)
conduit.addNode(xml=xml_section,object=portal_repository)
self.workspaces.setDocid(1320758020)
self.sections.setDocid(628256376)
return "ok"
#!/usr/bin/python
#
# 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.
#
"""
ERP5CPS Installer
HOWTO USE THAT ?
- Log into the ZMI as manager
- Go to your CPS root directory
- Create an External Method with the following parameters:
id : ERP5CPS INSTALLER (or whatever)
title : ERP5CPS INSTALLER (or whatever)
Module Name : ERP5CPS.install
Function Name : install
- save it
- click now the test tab of this external method.
"""
import sys, os
from zLOG import LOG,INFO,DEBUG,TRACE
from OFS.ObjectManager import BadRequestException, BadRequest
from Products.ExternalMethod.ExternalMethod import ExternalMethod
from Products.CMFCore.CMFCorePermissions import View, ModifyPortalContent
from Products.DCWorkflow.Transitions import TRIGGER_USER_ACTION
from Products.CPSCore.CPSWorkflow import TRANSITION_BEHAVIOR_PUBLISHING
from Products.CPSInstaller.CPSInstaller import CPSInstaller
from Products.ERP5.ERP5Site import ERP5Site
from Products.ERP5.ERP5Site import ERP5Generator
from Products.ERP5CPS.ERP5CPSSite import ERP5CPSGenerator
from Products.ERP5CPS import ERP5CPSBoxes
from Products.CMFCore.utils import getToolByName
from os import path
SECTIONS_ID = 'sections'
WORKSPACES_ID = 'workspaces'
SKINS = { 'erp5cps_default': 'Products/ERP5CPS/skins/erp5cps_default',
'erp5cps_style': 'Products/ERP5CPS/skins/erp5cps_style',
'erp5cps_images': 'Products/ERP5CPS/skins/erp5cps_images',
'pro': 'Products/ERP5/skins/pro',
'erp5': 'Products/ERP5/skins/erp5',
'activity': 'Products/CMFActivity/skins/activity',
}
class ERP5CPSInstaller(CPSInstaller,ERP5Generator):
"""ERP5 CPS installer class definition
"""
product_name = 'ERP5CPS'
def log(self,message):
CPSInstaller.log(self,message)
LOG('ERP5CPSInstaller',INFO,message)
def install(self):
"""Main call
"""
self.log("Starting ERP5CPS specific install")
self.updateCPS()
self.verifySkins(SKINS)
self.defineSkins()
self.setupTranslations()
self.installMandatoryProducts()
self.installTreeLoader()
self.setupBoxes()
self.finalize()
#self.reindexCatalog()
self.installERP5()
self.log("End of specific ERP5CPS install")
def updateCPS(self):
"""Update CPS
"""
self.portal.cpsupdate()
def defineSkins(self):
"""check skin order for ERP5/CPS compatibility
"""
portal_skin = getattr(self.portal,'portal_skins')
layers = portal_skin.selections
for key in layers.keys():
selection = layers[key]
position = selection.find('pro')
if position >= 0:
splitted = selection.split(', ')
try:
index_pos = splitted.index('pro')
except:
raise str(splitted)
del(splitted[index_pos])
splitted.append('pro')
selection = ', '.join(splitted)
layers[key] = selection
def installERP5(self):
"""
Install ERP5
"""
gen = ERP5Generator()
gen.setupTools(self.portal)
gen.setupBusinessTemplate(self.portal)
def installProduct(self,ModuleName,
InstallModuleName='install',MethodName='install'):
""" creates an external method for a
product install and launches it
"""
objectName ="cpserp5_"+ModuleName+"_installer"
objectName = objectName.lower()
# Install the product
self.log(ModuleName+" INSTALL [ START ]")
installer = ExternalMethod(objectName,
"",
ModuleName+"."+InstallModuleName,
MethodName)
try:
self.portal._setObject(objectName,installer)
except BadRequestException:
self.log("External Method for "+ModuleName+" already installed")
method_link = getattr(self.portal,objectName)
method_link()
self.log(ModuleName+" INSTALL [ STOP ]")
def installMandatoryProducts(self):
"""Installs the mandatory products for ERP5CPS
"""
pass
# Installing required products
def installTreeLoader(self):
"""Install tree loader
"""
if 'loadTree' not in self.portal.objectIds():
self.log(" Adding loadTree")
loadTree = ExternalMethod('loadTree',
'loadTree',
'CPSDefault.loadTree',
'loadTree')
self.portal._setObject('loadTree', loadTree)
self.log(" Protecting loadTree")
self.portal.loadTree.manage_permission(
'View', roles=['Manager'], acquire=0
)
self.portal.loadTree.manage_permission(
'Access contents information', roles=['Manager'], acquire=0
)
def setupBoxes(self):
"""Setup Boxes
"""
self.log("Adding ERP5CPS default boxes")
idbc = self.portal.portal_boxes.getBoxContainerId(self.portal)
self.log("Checking /%s" % idbc )
if idbc not in self.portal.objectIds():
self.log(" Creating")
self.portal.manage_addProduct['CPSDefault'].addBoxContainer()
# importing boxes
boxes = ERP5CPSBoxes.getBoxes()
guard_boxes = ERP5CPSBoxes.getGuardBoxes()
ttool = self.portal.portal_types
box_container = self.portal[idbc]
existing_boxes = box_container.objectIds()
for box in boxes.keys():
if box not in existing_boxes:
self.log("Creation of box: %s" % box)
apply(ttool.constructContent,
(boxes[box]['type'], box_container,
box, None), {})
ob = getattr(box_container, box)
ob.manage_changeProperties(**boxes[box])
else:
ob = getattr(box_container, box)
# defining guards
if guard_boxes.has_key(box):
guard_box = guard_boxes[box]
self.log("Setting up guards for box: %s" % box)
ob.setGuardProperties(guard_box)
def install(self):
installer = ERP5CPSInstaller(self)
installer.install()
return installer.logResult()
# (C) Copyright 2004 Nexedi SARL <http://nexedi.com>
# Authors: Sebastien Robin <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.
#
from Products.ERP5SyncML.Conduit.ERP5Conduit import ERP5Conduit
from Products.CMFCore.utils import getToolByName
def editDocument(self, object=None, **kw):
"""
This is the default editDocument method. This method
can easily be overwritten.
"""
object._edit(**kw)
portal_trees = getToolByName(object,'portal_trees')
for o in portal_trees.objectValues():
try:
o.rebuild()
except (AttributeError,KeyError):
pass
ERP5Conduit.editDocument = editDocument
# (C) Copyright 2004 Nexedi SARL <http://nexedi.com>
# Authors: Sebastien Robin <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.
#
import CPSCorePatch, CPSDocumentPatch, SynchronizationToolPatch
import CPSCorePatch, CPSDocumentPatch, SynchronizationToolPatch
# Update ERP5 Globals
from Products.ERP5Type.Utils import initializeProduct, updateGlobals
from Products.ERP5Type import Permissions
import sys
this_module = sys.modules[ __name__ ]
document_classes = updateGlobals( this_module, globals(), permissions_module =
Permissions)
# Define object classes and tools
import ERP5CPSSite
object_classes = ( ERP5CPSSite.ERP5CPSSite,)
portal_tools = ( )
content_classes = ()
content_constructors = ()
# Finish installation
def initialize( context ):
import Document
from zLOG import LOG
LOG('In ERP5CPS initialize', 0, '')
initializeProduct(context, this_module, globals(),
document_module = Document,
document_classes = document_classes,
object_classes = object_classes,
portal_tools = portal_tools,
content_constructors = content_constructors,
content_classes = content_classes)
<!-- mci boxes macros -->
<!-- $Id$ -->
<!-- ============================================================ -->
<metal:block define-macro="basebox_header">
<div metal:use-macro="here/global_definition/macros/global_definition" />
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td nowrap>
<!-- Navigation Box Goes Here -->
<form tal:attributes="action here/absolute_url" method="POST">
<div class="NavigationBox">
<div metal:use-macro="here/navigation_box/macros/navigation_box">
Navigation Box
</div>
</div>
</form>
</td>
</tr>
<tr>
<td>
<!-- Empty Menu For Design Consistency -->
<div class="MenuBox">
</div>
</td>
</tr>
</table>
</metal:block>
##parameters=category=None
# $Id$
"""Return available box types."""
"""
{'category': 'basebox',
'title': 'portal_type_BaseBox_title',
'desc': 'portal_type_BaseBox_description',
'types': [
{'provider': 'nuxeo',
'id': 'hr_separator',
'desc': 'description_nuxeo_basebox_hr_separator',
'config': {'title': 'hr_sep'},
} ,
{'provider': 'nuxeo',
'id': 'br_separator',
'desc': 'description_nuxeo_basebox_br_separator',
'config': {'title': 'br_sep'},
} ,
{'provider': 'nuxeo',
'id': 'search',
'desc': 'description_nuxeo_basebox_search'},
{'provider': 'nuxeo',
'id': 'menu',
'desc': 'Onglets affichant la racine des espaces de travails,
celle des sections et les sections de premier niveau.'},
{'provider': 'nuxeo',
'id': 'l10n_select',
'desc': 'description_nuxeo_basebox_l10n_select'},
{'provider': 'nuxeo',
'id': 'folder_header',
'desc': 'description_nuxeo_basebox_folder_header'},
]
},
"""
items = [
{'category': 'textbox',
'title': 'portal_type_TextBox_title',
'desc': 'portal_type_TextBox_description',
'types': [{'provider': 'nuxeo',
'id': 'default',
'desc': 'description_nuxeo_textbox_default'},
]
},
{'category': 'treebox',
'title': 'portal_type_TreeBox_title',
'desc': 'portal_type_TreeBox_description',
'types': [{'provider': 'nuxeo',
'id': 'default',
'desc': 'description_nuxeo_treebox_default'},
{'provider': 'nuxeo',
'id': 'center',
'desc': 'description_nuxeo_treebox_center',
'config': {'contextual': 1,
'children_only': 1,
'depth': 2,
'root': '',
'authorized_only': 1,
'display_managers': 0,
'show_root': 1}
},
{'provider': 'nuxeo',
'id': 'sitemap',
'desc': 'description_nuxeo_treebox_sitemap',
'config': {'authorized_only': 1,
},
},
{'provider': 'nuxeo',
'id': 'sitemap_adv',
'desc': 'description_nuxeo_treebox_sitemap_adv',
}
]
},
{'category': 'contentbox',
'title': 'portal_type_ContentBox_title',
'desc': 'portal_type_ContentBox_description',
'types': [{'provider': 'nuxeo',
'id': 'default',
'desc': 'description_nuxeo_contentbox_default'},
{'provider': 'nuxeo',
'id': 'simple',
'desc': 'description_nuxeo_contentbox_simple'},
{'provider': 'nuxeo',
'id': 'last_modified',
'desc': 'description_nuxeo_contentbox_last_modified',
'config': {'sort_by': 'date',
'direction': 'desc',
'query_status': 'published'}
},
{'provider': 'nuxeo',
'id': 'pending',
'desc': 'description_nuxeo_contentbox_pending',
'config': {'sort_by': 'date',
'direction': 'asc',
'query_status': 'pending'}
},
]
},
{'category': 'actionbox',
'title': 'portal_type_ActionBox_title',
'desc': 'portal_type_ActionBox_description',
'types': [{'provider': 'nuxeo',
'id': 'default',
'desc': 'description_nuxeo_actionbox_default'},
{'provider': 'nuxeo',
'id': 'user',
'desc': 'description_nuxeo_actionbox_user'},
{'provider': 'nuxeo',
'id': 'menu',
'desc': 'description_nuxeo_actionbox_menu'},
{'provider': 'nuxeo',
'id': 'header',
'desc': 'description_nuxeo_actionbox_header'},
]
},
{'category': 'imagebox',
'title': 'portal_type_ImageBox_title',
'desc': 'portal_type_ImageBox_description',
'types': [{'provider': 'nuxeo',
'id': 'default',
'desc': 'description_nuxeo_imagebox_default'},
]
},
{'category': 'flashbox',
'title': 'portal_type_FlashBox_title',
'desc': 'portal_type_FlashBox_description',
'types': [{'provider': 'nuxeo',
'id': 'default',
'desc': 'description_nuxeo_flashbox_default'},
]
},
{'category': 'eventcalendarbox',
'title': 'portal_type_EventCalendarBox_title',
'desc': 'portal_type_EventCalendarBox_description',
'types': [{'provider': 'nuxeo',
'id': 'default',
'desc': 'description_nuxeo_basebox_calendar'},
]
},
]
citems = context.getCustomBoxTypes()
for citem in citems:
found = 0
for item in items:
if item['category'] == citem['category']:
item['types'].extend(citem['types'])
found = 1
break
if not found:
items.append(citem)
if category:
for item in items:
if item['category'] == category:
return item
return items
## Script (Python) "getCustomBoxTypes"
##parameters=
# $Id$
"""Return custom box types."""
items = [
{'category': 'basebox',
'title': 'portal_type_BaseBox_title',
'desc': 'portal_type_BaseBox_description',
'types': [{'provider': 'erp5cps',
'id': 'header',
'desc': 'Entte ERP5'},
,
]
},
]
return items
<!-- html head macro -->
<!-- $Id$ -->
<!-- ============================================================ -->
<metal:block define-macro="header" tal:define="charset string:ISO-8859-15">
<tal:block define="dummy python:request.RESPONSE.setHeader('Content-Type',
'text/html;; charset=%s' % charset)" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-15" />
<meta name="generator" content="Nuxeo CPS" />
<title tal:content="expanded_title|here/expanded_title">CPS Default</title>
<metal:block define-slot="base"></metal:block>
<link rel="Stylesheet" type="text/css" href=""
tal:attributes="href string:${base_url}nuxeo_css1.css" />
<link rel="Stylesheet" type="text/css" href=""
tal:attributes="href string:${base_url}erp5cps.css" />
<style type="text/css" media="all"
tal:content="string:@import url(${base_url}nuxeo_css2.css);"></style>
<link rel="stylesheet" type="text/css" media="print"
tal:attributes="href string:${base_url}nuxeo_print_css.css" />
<link rel="icon" href="" type="image/png" tal:attributes="href
string:${base_url}favicon.png" />
<meta http-equiv="imagetoolbar" content="no" />
<metal:block define-slot="head_slot"></metal:block>
<metal:block define-slot="css_slot"></metal:block>
<style type="text/css" media="all"
tal:condition="exists: here/custom.css"
tal:content="string:@import url(${base_url}custom.css);"></style>
<style type="text/css" media="all"
tal:define="custom_css here/getCPSCustomCSS|nothing"
tal:condition="custom_css"
tal:content="string:@import url(${base_url}${custom_css});"></style>
<metal:block define-slot="javascript_head_slot"></metal:block>
<script type="text/javascript"
tal:attributes="src string:${base_url}functions.js"></script>
</metal:block>
<dtml-with erp5_stylesheet_properties>
/*______________ CSS ERP5-CORAMY _________________ */
/* _________________ Navigation Box _________________ */
.NavigationBox{
color: &dtml-alternate_font_color;;
background-color: &dtml-navigation_background_color;;
vertical-align: middle;
}
.NavigationBox select{
color: &dtml-alternate_font_color;;
vertical-align: middle;
font-family: &dtml-default_font_family;;
}
.input_image{
border:none;
background-color:transparent;
color:transparent;
}
/* _________________ Menu Box _________________ */
.MenuBox{
color: &dtml-alternate_font_color;;
background-color: &dtml-menu_background_color;;
border-color: &dtml-alternate_border_color;;
border-style: solid;
border-bottom-width: 1px;
border-left-width: 0px;
border-top-width: 0px;
border-right-width: 0px;
vertical-align: middle;
padding-top: 2px;
padding-right: 0px;
padding-bottom: 2px;
padding-left: 0px;
}
</dtml-with>
<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>
import Products.ERP5Type
import Products.ERP5
import Products.ERP5.XML
import Products.ERP5.UI
import Products.ERP5.Document
import Products.ERP5.Document.SaleOpportunity
import Products.ERP5Catalog
import Products.ERP5Form
import Products.ERP5SyncML
# Aliases dictionnary for future upgrade
__module_aliases__ = ( ( 'Products.ERP5.ERP5', Products.ERP5.ERP5Site )
, ( 'Products.ERP5.XML.SynchronizationTool',
Products.ERP5SyncML.SynchronizationTool )
, ( 'Products.ERP5.XML.CatalogTool', Products.ERP5Catalog.CatalogTool )
, ( 'Products.ERP5.XML.Base', Products.ERP5Type.Base )
, ( 'Products.ERP5.XML.XMLObject', Products.ERP5Type.XMLObject )
, ( 'Products.ERP5.XML.XMLMatrix', Products.ERP5Type.XMLMatrix )
, ( 'Products.ERP5.XML.CatalogTool', Products.ERP5Catalog.CatalogTool )
, ( 'Products.ERP5.UI.CategoryTool', Products.ERP5.Tool.CategoryTool )
, ( 'Products.ERP5.UI.Category', Products.ERP5.Tool.Category )
, ( 'Products.ERP5.UI.Form', Products.ERP5Form.Form )
, ( 'Products.ERP5.UI.ListBox', Products.ERP5Form.ListBox )
, ( 'Products.ERP5.UI.MatrixBox', Products.ERP5Form.MatrixBox )
, ( 'Products.ERP5.UI.RelationField', Products.ERP5Form.RelationField )
, ( 'Products.ERP5.UI.MultiRelationField', Products.ERP5Form.MultiRelationField )
, ( 'Products.ERP5.UI.ImageField', Products.ERP5Form.ImageField )
, ( 'Products.ERP5.UI.SelectionTool', Products.ERP5Form.SelectionTool )
, ( 'Products.ERP5.Document.Folder', Products.ERP5Type.Document.Folder )
, ( 'Products.ERP5.Document.SalesOpportunity', Products.ERP5.Document.SaleOpportunity )
, ( 'Products.ERP5.Document.SalesOpportunity.SalesOpportunity', Products.ERP5.Document.SaleOpportunity.SaleOpportunity )
)
# Hard wired aliases
Products.ERP5.ERP5 = Products.ERP5.ERP5Site
Products.ERP5.XML.SynchronizationTool = Products.ERP5SyncML.SynchronizationTool
Products.ERP5.Document.Folder = Products.ERP5Type.Document.Folder
Products.ERP5.XML.CatalogTool = Products.ERP5Catalog.CatalogTool
Products.ERP5.XML.Base = Products.ERP5Type.Base
Products.ERP5.XML.XMLObject = Products.ERP5Type.XMLObject
Products.ERP5.XML.XMLMatrix = Products.ERP5Type.XMLMatrix
Products.ERP5.UI.CategoryTool = Products.ERP5.Tool.CategoryTool
Products.ERP5.UI.Category = Products.ERP5.Tool.Category
Products.ERP5.UI.Form = Products.ERP5Form.Form
Products.ERP5.UI.ListBox = Products.ERP5Form.ListBox
Products.ERP5.UI.MatrixBox = Products.ERP5Form.MatrixBox
Products.ERP5.UI.RelationField = Products.ERP5Form.RelationField
Products.ERP5.UI.MultiRelationField = Products.ERP5Form.MultiRelationField
Products.ERP5.UI.ImageField = Products.ERP5Form.ImageField
Products.ERP5.UI.SelectionTool = Products.ERP5Form.SelectionTool
Products.ERP5.Document.SalesOpportunity = Products.ERP5.Document.SaleOpportunity
Products.ERP5.Document.SalesOpportunity.SalesOpportunity = Products.ERP5.Document.SaleOpportunity.SaleOpportunity
This diff is collapsed.
##############################################################################
#
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# 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.
#
##############################################################################
from AccessControl import ClassSecurityInfo
from Products.CMFCore.utils import getToolByName
from Products.ERP5.Document.Resource import Resource
from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
from Products.ERP5Type.XMLMatrix import XMLMatrix
from Products.MMMShop.ShopProduct import ShopProduct as MMMShopProduct
from zLOG import LOG
class ShopProduct(MMMShopProduct, Resource, XMLMatrix):
"""
ERP5 Shop Product.
An ERP5 Shop product
"""
meta_type = 'ERP5 Shop Product'
portal_type = 'Shop Product'
add_permission = Permissions.AddPortalContent
isPortalContent = 1
isRADContent = 1
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.View)
# Declarative interfaces
__implements__ = ( Interface.Variated, )
# Declarative properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore
, PropertySheet.Document
, PropertySheet.Price
, PropertySheet.Resource
, PropertySheet.ShopProduct
)
# Hard Wired Variation List
# XXX - may be incompatible with future versions of ERP5
variation_base_category_list = ()
# Factory Type Information
factory_type_information = \
{ 'id' : portal_type
, 'meta_type' : meta_type
, 'description' : """\
Un tissu est une resource variantable en couleur."""
, 'icon' : 'shop_product_icon.gif'
, 'product' : 'ERP5Shop'
, 'factory' : 'addShopProduct'
, 'immediate_view' : 'shop_product_view'
, 'allow_discussion' : 1
, 'allowed_content_types': ('File', 'Document', 'Image',
)
, 'filter_content_types' : 1
, 'global_allow' : 1
, 'actions' :
( { 'id' : 'view'
, 'name' : 'View'
, 'category' : 'object_view'
, 'action' : 'shop_product_view'
, 'permissions' : (
Permissions.View, )
}
, { 'id' : 'list'
, 'name' : 'Object Contents'
, 'category' : 'object_action'
, 'action' : 'folder_contents'
, 'permissions' : (
Permissions.View, )
}
, { 'id' : 'print'
, 'name' : 'Print'
, 'category' : 'object_print'
, 'action' : 'tissu_print'
, 'permissions' : (
Permissions.View, )
}
, { 'id' : 'metadata'
, 'name' : 'Metadata'
, 'category' : 'object_view'
, 'action' : 'metadata_edit_form'
, 'permissions' : (
Permissions.View, )
}
, { 'id' : 'translate'
, 'name' : 'Translate'
, 'category' : 'object_action'
, 'action' : 'translation_template_view'
, 'permissions' : (
Permissions.TranslateContent, )
}
)
}
# Multiple Inheritance Resolving
security.declareProtected(Permissions.ModifyPortalContent, 'edit')
def edit(self, REQUEST=None, **kw):
kw['force_update'] = 1
Resource._edit(self, **kw)
#LOG("Show kw",0,str(kw))
MMMShopProduct.edit(self, REQUEST)
_setProperty = Resource._setProperty
setProperty = Resource.setProperty
getProperty = Resource.getProperty
security.declareProtected(Permissions.ModifyPortalContent, '_setProductType')
_setProductType = MMMShopProduct.setProductType
def computePrice(self, REQUEST=None):
return self.price
def renderVariation(self, REQUEST=None):
return ''
def shortVariation(self, REQUEST=None):
result = ''
for c in REQUEST.categories:
try:
o = self.portal_categories.restrictedTraverse(c)
result += '%s, ' % o.getTitle()
except:
pass
if len(result) > 0:
return result[0:-2]
return result
def _getPrice(self, context):
"""
Private price depending in the context
"""
return self._price
def getPrice(self, context=None, REQUEST=None, **kw):
"""
Public Generic Price Getter based on the context
This Getter can be called
- from the Web: parameters will be provided
by the REQUEST object (context is None)
- from a Python Script: parameters can
are provided individually (kw is not None).
Optional context object / REQUEST can be
provided
- from another Method: the context is passed
(REQUEST is None and kw is None)
Context instance is created
This s
The REQUEST can either hold a REQUEST object
(resulting from an HTTP access) or a context
object (ie. any object in the ZODB). The context
can
"""
return self._getPrice(self.asContext(context=context, REQUEST=REQUEST, **kw))
def _getExchangedPrice(self, context):
curmanager = getToolByName(self, 'portal_currency_manager')
exchange_rate = curmanager.getMemberExchangeRate()
price = float(self._getPrice(context)) / float(exchange_rate)
return price
def getExchangedPrice(self, context=None, REQUEST=None, **kw):
context = self.asContext(context=context, REQUEST=REQUEST, **kw)
return self._getExchangedPrice(context)
security.declareProtected(Permissions.View, 'shortVariant')
def shortVariant(self, variation_value, REQUEST=None):
result = ''
for c in variation_value.categories:
result += '%s/' % c
if len(result) > 0: del result[-1]
return result
# Compatibility methods with early versions of StoreverShop
security.declareProtected(Permissions.View, 'getProductPath')
def getProductPath(self, REQUEST=None):
return self.getRelativeUrl()
security.declareProtected(Permissions.View, 'getOptionValues')
def getOptionValues(self, REQUEST=None):
return ()
##############################################################################
#
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# 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.
#
##############################################################################
import string
from AccessControl import ClassSecurityInfo
from Products.CMFCore.utils import getToolByName, _getAuthenticatedUser
from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
from Products.ERP5.Document.OrderLine import OrderLine as ERP5OrderLine
from Products.ERP5.Document.Amount import Amount
from Products.MMMShop.ShoppingCart import ShoppingCart as MMMShoppingCart
from Products.MMMShop.ShoppingCart import CartObject as MMMCartObject
from Products.MMMShop import ShopPermissions
from Products.MMMShop.utils import getUniqueID
from Products.Base18.Base18 import Base18
import zLOG
class CartObject(MMMCartObject, ERP5OrderLine):
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.View)
def getVariationValue(self):
product = self.getProduct()
return product.newVariationValue(context=self)
security.declareProtected(Permissions.View, 'getExchangedPrice')
def getExchangedPrice(self):
product = self.getProduct()
price = product.getExchangedPrice(context=self)
return price
_setVariationCategoryList = Amount._setVariationCategoryList
class ShoppingCart(MMMShoppingCart, Base18):
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.View)
title = "Shopping Cart"
security.declareProtected(Permissions.View, 'getTitle')
def getTitle():
return self.title
security.declareProtected(ShopPermissions.CheckoutShoppingCart, 'addProductToCart')
def addProductToCart( self, prod_path, prod_title, quantity, delivery_days,
mail_receive=None, variation_value=None):
"""
Assigns a Product and a Quantity to the ShoppingCart
"""
zLOG.LOG('Shopping Cart', zLOG.INFO, 'Called add to cart')
for item in self.listProducts():
zLOG.LOG('Item', zLOG.INFO, str(( item.getProductPath(),prod_path,
variation_value.__dict__,
item.getVariationValue().__dict__)))
if item.getProductPath() == prod_path:
zLOG.LOG('Item', 0, 'same path')
if variation_value is None or item.getVariationValue() is None:
item.edit(datadict = {'quantity': item.getQuantity() + int(quantity),})
return
elif variation_value == item.getVariationValue():
item.edit(datadict = {'quantity': item.getQuantity() + int(quantity),})
return
prod_id = getUniqueID()
prod = CartObject(prod_id)
self._setObject(prod_id, prod)
cartobj = getattr(self, prod_id)
zLOG.LOG('Shopping Cart', zLOG.INFO, 'Receive by mail? %s' % str(mail_receive))
datadict = { 'product_path': prod_path
, 'title': prod_title
, 'quantity': quantity
, 'delivery_days': delivery_days
, 'mail_receive': mail_receive}
cartobj.edit(datadict=datadict)
cartobj.setResource(prod_path)
if variation_value is not None: cartobj.setVariationValue(variation_value)
security.declareProtected(ShopPermissions.CheckoutShoppingCart, 'clearCart')
def clearCart(self, REQUEST=None):
"""
Empty the cart for all cart objects
"""
for item in self.listProducts():
itemid = item.id
self.manage_delObjects(itemid)
if REQUEST is not None:
msg = 'Cart is empty'
REQUEST.RESPONSE.redirect('%s/view?portal_status_message=%s' % (self.secure_absolute_url(),
msg.replace(' ', '+')))
security.declareProtected(Permissions.ManageProperties, 'edit')
def edit(self, REQUEST):
"""
Edit the items in the cart (quantity)
"""
req = REQUEST
items = self.listProducts()
for item in items:
reqvar = "%s_quantity" % item.id
if req.has_key(reqvar):
data = {'quantity': req.get(reqvar)}
item.edit(datadict=data)
msg = 'Updated cart'
req.RESPONSE.redirect("%s/view?portal_status_message=%s" % (self.secure_absolute_url(),
msg.replace(' ', '+')))
security.declareProtected(ShopPermissions.CheckoutShoppingCart,'setPaymentData')
def setPaymentData(self, REQUEST):
"""
Save the entered personal data for the payment method
"""
zLOG.LOG('Shopping cart - set payment', zLOG.INFO, 'setPaymentData called')
req = REQUEST
shopmanager = getToolByName(self, 'portal_shop_manager')
paymentdata = self._paymentdata
paymentid = req.get('paymentmethod_id', None)
savedata = {}
msg = 'Saved payment data'
returnview = 'checkout'
if paymentid is None:
msg = 'No payment method selected'
returnview = 'prepareOrder'
zLOG.LOG('Shopping cart - set payment', zLOG.INFO, 'paymentid is None')
else:
zLOG.LOG('Shopping cart - set payment', zLOG.INFO, 'paymentid is NOT None')
payment = shopmanager.getPaymentMethod(paymentid)
paymentstructure = payment.getPaymentStructure()
zLOG.LOG('Shopping cart - set payment', zLOG.INFO, 'Payment structure is:\n%s' %
str(paymentstructure))
propmsg = ''
properror = 0
for property in paymentstructure:
propid = property['id']
userdef = property['user_defined']
validationinfo = property['validation_info']
isRequired = property['isRequired']
if isRequired and userdef and not validationinfo:
if not req.has_key(propid) or req[propid] == '':
if not propmsg:
propmsg = 'Missing input for %s' % property['title']
else:
propmsg = "%s, %s" % (propmsg, property['title'])
properror = 1
if req.has_key(propid) and userdef and not validationinfo:
savedata[propid] = req.get(propid)
if propmsg:
msg = propmsg
zLOG.LOG('Shopping cart - set payment', zLOG.INFO, 'Msg is: %s' % msg)
if properror:
returnview = 'prepareOrder'
if shopmanager.isDeliveryNeeded():
if req.has_key('delivery_fee'):
savedata['delivery_fee'] = req.get('delivery_fee')
delivery_error = 0
else:
delivery_error = 1
msg = "%s. You have not selected any delivery method'" % msg
if delivery_error:
returnview = 'prepareOrder'
paymentdata[paymentid] = savedata
self._paymentdata = paymentdata
self._p_changed = 1
self._last_used_payment = paymentid
zLOG.LOG('Shopping cart - set payment', zLOG.INFO, 'Return view is %s and msg is %s' %
(returnview, msg))
req.RESPONSE.redirect("%s/%s?payment_method=%s&portal_status_message=%s" %
(self.secure_absolute_url(), returnview, paymentid, msg.replace(' ', '+')))
MMMShoppingCart.addProductToCart = ShoppingCart.addProductToCart
MMMShoppingCart.clearCart = ShoppingCart.clearCart
MMMShoppingCart.edit = ShoppingCart.edit
MMMShoppingCart.setPaymentData = ShoppingCart.setPaymentData
MMMShoppingCart.getTitle = ShoppingCart.getTitle
##############################################################################
#
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# 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.
#
##############################################################################
try:
from Interface import Interface
except ImportError:
# for Zope versions before 2.6.0
from Interface import Base as Interface
class ShopOrder(Interface):
"""
Common Interface for all ERP5 ShopProduct objects
This is where we define the common interface between MMMShop and ERP5
"""
def edit(self):
"""
Change the product parameters (price, options, etc.)
"""
pass
def addLineToOrder(self, title, description, price, quantity, producturl=None):
"""
Assigns a product and a quantity to the order
"""
pass
def delOrderLine(self, id):
"""
Delete a product from the order
"""
pass
def listOrderLines(self):
"""
List all products in this order
"""
pass
##############################################################################
#
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# 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.
#
##############################################################################
try:
from Interface import Interface
except ImportError:
# for Zope versions before 2.6.0
from Interface import Base as Interface
class ShopProduct(Interface):
"""
Common Interface for all ERP5 ShopProduct objects
This is where we define the common interface between MMMShop and ERP5
"""
def edit(self):
"""
Change the product parameters (price, options, etc.)
"""
pass
def getPrice(self, REQUEST=None):
"""
Provides a context dependent price
The context can be a REQUEST object or
an ERP5 XMLObject or a dictionary (??) or
an instance with attributes
The price is provided
in the member preferred currency
"""
pass
def getCalculatedSendFee(self, REQUEST=None):
"""
Return the calculated send fee
depending on the context.
The price is provided
in the member preferred currency
"""
pass
def setProductType(self, ptype):
"""
Type management. Must be related to ERP5 category system
"""
pass
def getProductType(self):
"""
Type management. Must be related to ERP5 category system
"""
pass
##############################################################################
#
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# 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.
#
##############################################################################
try:
from Interface import Interface
except ImportError:
# for Zope versions before 2.6.0
from Interface import Base as Interface
class ShoppingCart(Interface):
"""
Common Interface for all ERP5 ShopProduct objects
This is where we define the common interface between MMMShop and ERP5
"""
def edit(self):
"""
Change the product parameters (price, options, etc.)
"""
pass
def listProducts(self):
"""
List all products available
"""
pass
def delProduct(self, id):
"""
Delete a product from the shopping cart
"""
pass
def addProductToCart( self, prod_path, prod_title, quantity, delivery_days, mail_receive=None):
"""
Assigns a Product and a Quantity to the ShoppingCart
"""
pass
def createShopOrder(self):
"""
List all products available
"""
pass
def clearCart(self):
"""
List all products available
"""
pass
def getCartTotal(self, REQUEST=None):
"""
List all products available
"""
pass
##############################################################################
#
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# 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.
#
##############################################################################
class ShopOrder:
"""
ShopOrder properties and categories
"""
_properties = (
{ 'id' : 'address',
'description' : 'Address',
'type' : 'string',
'mode' : 'w' },
{ 'id' : 'city',
'description' : 'City',
'type' : 'string',
'mode' : 'w' },
{ 'id' : 'country',
'description' : 'Country',
'type' : 'string',
'mode' : 'w' },
{ 'id' : 'email',
'description' : 'Email',
'type' : 'string',
'mode' : 'w' },
{ 'id' : 'exchange_fee',
'description' : 'Exchange Fee',
'type' : 'float',
'mode' : 'w' },
{ 'id' : 'extra_fee',
'description' : 'Extra Fee',
'type' : 'float',
'mode' : 'w' },
{ 'id' : 'name',
'description' : 'Name',
'type' : 'string',
'mode' : 'w' },
{ 'id' : 'organisation',
'description' : 'Organisation',
'type' : 'string',
'mode' : 'w' },
{ 'id' : 'order_id',
'description' : 'Order Id',
'type' : 'string',
'mode' : 'w' },
{ 'id' : 'phone',
'description' : 'Phone',
'type' : 'string',
'mode' : 'w' },
{ 'id' : 'send_fee',
'description' : 'Send Fee',
'type' : 'float',
'mode' : 'w' },
{ 'id' : 'send_fee_title',
'description' : 'Send Fee Title',
'type' : 'string',
'mode' : 'w' },
{ 'id' : 'price',
'description' : 'Price',
'type' : 'float',
'mode' : 'w' },
{ 'id' : 'total_price',
'description' : 'Total Price',
'type' : 'float',
'mode' : 'w' },
{ 'id' : 'vat',
'description' : 'Vat',
'type' : 'float',
'mode' : 'w' },
{ 'id' : 'euvat',
'description' : 'Euvat',
'type' : 'float',
'mode' : 'w' },
{ 'id' : 'eu_vat',
'description' : 'The eu vat code',
'type' : 'string',
'mode' : 'w' },
{ 'id' : 'zipcode',
'description' : 'Zip Code',
'type' : 'string',
'mode' : 'w' },
{ 'id' : 'billing_address',
'description' : 'Billing Address',
'type' : 'string',
'mode' : 'w' },
{ 'id' : 'owner_account_id',
'description' : 'The id of the member account that own the Shop Order. This property is only used for the synchronisation process with ERP5 Sales Order.',
'type' : 'string',
'mode' : 'w' },
)
_categories = ( )
\ No newline at end of file
##############################################################################
#
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# 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.
#
##############################################################################
class ShopProduct:
"""
ERP5 Shop Product properties and categories
This propertysheet mimics the MMM Shop implementation
of a Shop Product attributes
Catagories are not implemented yet.
"""
_properties = (
{ 'id' : 'price',
'description' : 'Price',
'type' : 'float',
'mode' : 'w' },
{ 'id' : 'delivery_days',
'description' : 'Delivery Days',
'type' : 'int',
'mode' : 'w' },
{ 'id' : 'send_fee',
'description' : 'Sending Fee',
'type' : 'float',
'mode' : 'w' },
{ 'id' : 'send_fee_count',
'description' : 'Sending Fee Count',
'type' : 'int',
'mode' : 'w' },
{ 'id' : 'product_type',
'description' : 'Product Type',
'type' : 'string',
'mode' : 'w' },
{ 'id' : 'image',
'description' : 'Product Default Image',
'portal_type' : ('Image'),
'type' : 'content',
'mode' : 'w' },
)
_categories = ( )
##############################################################################
# Copyright (C) 2001 MMmanager.org
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# 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
#
##############################################################################
"""
"""
ADD_CONTENT_PERMISSION = 'Add portal content'
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass, package_home
from Products.MMMShop.ShopManager import ShopManager as MMMShopManager
from Products.MMMShop import ShopPermissions
from Products.MMMShop.MMMShopGlobals import order_meta_types
class ShopManager(MMMShopManager):
"""
A ShopManager tool
"""
id = 'portal_shop_manager'
meta_type='ERP5 Shop Manager'
security = ClassSecurityInfo()
security.declarePublic('getMemberOrders')
def getMemberOrders(self):
"""
Returns a list containing all the logged-in members orders
"""
orders = []
cart = self.getMemberCart()
if cart:
orders = cart.objectValues(order_meta_types)
orders += cart.aq_parent.objectValues(order_meta_types)
return orders
InitializeClass(ShopManager)
##############################################################################
#
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# 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.
#
##############################################################################
"""
ERP5Shop Free ERP + eCommerce
"""
# Update ERP5 Globals
from Products.ERP5Type.Utils import initializeProduct, updateGlobals
import sys, Permissions
this_module = sys.modules[ __name__ ]
document_classes = updateGlobals( this_module, globals(), permissions_module = Permissions)
# Define object classes and tools
import ShopManager
object_classes = ()
portal_tools = ( ShopManager.ShopManager,
)
content_classes = ()
content_constructors = ()
# Finish installation
def initialize( context ):
import Document
initializeProduct(context, this_module, globals(),
document_module = Document,
document_classes = document_classes,
object_classes = object_classes,
portal_tools = portal_tools,
content_constructors = content_constructors,
content_classes = content_classes)
This diff is collapsed.
import cmmac
def CMLang(langue):
if langue == 'fr':
langue = 'francais'
elif langue == 'en':
langue = 'anglais'
return langue
def CreerFormulaireCM(url_banque = "https://ssl.paiement.cic-banques.fr",
version = "1.2",
TPE = "/var/www/payment/storever.key",
montant = "1EUR",
reference = "STVR1",
texte_libre = "Toto",
url_retour = "http://www.storever.com",
url_retour_ok = "https://secure.storever.com/payment/accept",
url_retour_err = "https://secure.storever.com/payment/reject",
langue = "fr",
code_societe = "storever",
texte_bouton = "Paiement par carte bancaire"):
# Create Bing String
formulaire = '1234567890' * 500
langue = CMLang(langue)
formulaire = cmmac.CreerFormulaireCM2(url_banque, version, TPE, str(montant)+'EUR', str(reference), texte_libre, url_retour, url_retour_ok, url_retour_err, langue, str(code_societe), texte_bouton, formulaire)
return formulaire
def CalculMAC(version="",
TPE="",
cdate="",
montant="",
reference="",
texte_libre="",
langue="",
code_societe=""):
# Adapt Parameters
langue = CMLang(langue)
return cmmac.CalculMAC(version,TPE,cdate,montant,reference,texte_libre,langue,code_societe)
def TestMAC(code_MAC="",
version="",
TPE="",
cdate="",
montant="",
reference="",
texte_libre="",
code_retour="Code Retour Par Défaut"):
return cmmac.TestMAC(code_MAC,version,TPE,cdate,montant,reference,texte_libre,code_retour)
def CreerReponseCM(phrase=""):
# Create Bing String
reponse = '1234567890' * 500
return cmmac.CreerReponseCM2(phrase,reponse)
This diff is collapsed.
##############################################################################
# Copyright (C) 2001 MMmanager.org
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# 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
#
##############################################################################
"""
"""
ADD_CONTENT_PERMISSION = 'Add portal content'
import Globals
import zLOG
from Products.CMFCore import CMFCorePermissions
from Products.CMFCore.CMFCorePermissions import View
from Products.CMFCore.CMFCorePermissions import ManageProperties
from AccessControl import ClassSecurityInfo
from Products.CMFCore.PortalContent import PortalContent
from Products.CMFDefault.DublinCore import DefaultDublinCoreImpl
from DateTime.DateTime import DateTime
from Products.StoreverShop.ComputerProduct import ComputerProduct
from ZODB.PersistentMapping import PersistentMapping
from Products.Base18.Document import Document18
factory_type_information = {
'id': 'Service Product',
'meta_type': 'Storever Service Product',
'description': 'Use products to create an online shopping catalog',
'product': 'StoreverShop',
'icon': 'file_icon.gif',
'factory': 'addServiceProduct',
'filter_content_types': 0,
'immediate_view': 'serviceproduct_edit_form',
'actions':
({'name': 'View',
'id': 'view',
'action': 'serviceproduct_view',
'permissions': ('View',),
'category': 'object'},
{'name': 'Edit',
'id': 'edit',
'action': 'serviceproduct_edit_form',
'permissions': ('Modify portal content',),
'category': 'object'})
}
class ServiceProduct( ComputerProduct ):
"""
A Link
"""
meta_type='MMM Service Product'
portal_type='Object'
effective_date = expiration_date = None
_isDiscussable = 1
security = ClassSecurityInfo()
def addServiceProduct(self, id, title='', REQUEST=None):
ob=ComputerProduct(id,title)
self._setObject(id, ob)
Globals.InitializeClass(ServiceProduct)
##############################################################################
# Copyright (C) 2001 MMmanager.org
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# 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
#
##############################################################################
"""
"""
ADD_CONTENT_PERMISSION = 'Add portal content'
import Globals, string
import zLOG
from Products.CMFCore import CMFCorePermissions
from Products.CMFCore.CMFCorePermissions import View
from Products.CMFCore.CMFCorePermissions import ManageProperties
from AccessControl import ClassSecurityInfo
from Products.CMFCore.PortalContent import PortalContent
from Products.CMFDefault.DublinCore import DefaultDublinCoreImpl
from DateTime.DateTime import DateTime
from Products.MMMShop.ShopProduct import ShopProduct
from ZODB.PersistentMapping import PersistentMapping
from Products.Base18.Document import Document18
factory_type_information = {
'id': 'Simple Product',
'meta_type': 'Storever Simple Product',
'description': 'Use simple products to create products with variations',
'product': 'StoreverShop',
'icon': 'file_icon.gif',
'factory': 'addSimpleProduct',
'filter_content_types': 0,
'immediate_view': 'simpleproduct_edit_form',
'actions':
({'name': 'View',
'id': 'view',
'action': 'simpleproduct_view',
'permissions': ('View',),
'category': 'object'},
{'name': 'Edit',
'id': 'edit',
'action': 'simpleproduct_edit_form',
'permissions': ('Modify portal content',),
'category': 'object'})
}
def SecondSort(a,b):
if a[1] > b[1]:
return 1
if a[1] < b[1]:
return -1
return 0
class SimpleProduct( ShopProduct, Document18 ):
"""
A Product with variations
"""
meta_type='Storever Simple Product'
portal_type='Simple Product'
effective_date = expiration_date = None
_isDiscussable = 1
price = 0.0
thumbnail = ''
image = ''
isCredit = 0
credits = 0
delivery_days = 0
default_variant = ()
text = ''
security = ClassSecurityInfo()
def __init__( self
, id
, title=''
, description=''
):
DefaultDublinCoreImpl.__init__(self)
self.id=id
self.title=title
self.description=description
self.delivery_days=0
self.processor_price = PersistentMapping()
self.disk_price = PersistentMapping()
self.memory_price = PersistentMapping()
self.option_price = PersistentMapping()
self.text = ''
def SearchableText(self):
"""
text for indexing
"""
return "%s %s" % (self.title, self.description)
security.declareProtected(ManageProperties, 'editProduct')
def editProduct(self,
title=None,
description=None,
price=None,
isCredit=None,
credits=None,
category=None,
delivery_days=None,
product_path=None,
text=None):
if title is not None:
self.setTitle(title)
if description is not None:
self.setDescription(description)
if price is not None:
self.price = price
if isCredit is not None:
if isCredit == '1':
self.isCredit = 1
else:
self.isCredit = 0
if product_path is not None:
self.product_path = product_path
if credits is not None:
self.credits = int(credits)
if category is not None:
self.setSubject(category)
if delivery_days is not None:
self.delivery_days = int(delivery_days)
if text is not None:
self.text = text
self.reindexObject()
security.declareProtected(ManageProperties, 'setOptionPrice')
def setOptionPrice(self, option, price):
self.option_price[option] = price
security.declareProtected(View, 'getOptions')
def getOptions(self,pattern=''):
if not hasattr(self,'option_price'):
self.option_price = PersistentMapping()
return filter(lambda s,p=pattern: s.find(p) >= 0, self.option_price.keys())
security.declareProtected(View, 'getOptionValues')
def getOptionValues(self,pattern=''):
"""
Return a sequence of tuples (option,price)
"""
diskvalues = map(lambda i,product=self: (i, product.getOptionPrice(i)), self.getOptions(pattern))
diskvalues.sort(SecondSort)
return diskvalues
security.declareProtected(View, 'getOptionPrice')
def getOptionPrice(self,size):
if self.option_price.has_key(size):
return self.option_price[size]
else:
return 0
security.declareProtected(ManageProperties, 'deleteOptionPrice')
def deleteOptionPrice(self,size):
del self.option_price[size]
def editThumbnail(self, thumbnail=None):
if thumbnail is not None:
self.thumbnail = thumbnail
def editImage(self, image=None):
if image is not None:
self.image = image
security.declareProtected(View, 'computePrice')
def computePrice(self, variant):
"""
variant is defined as:
(color,processor,memory,disk,options,setup,config_url,
root,boot,usr,home,var,tmp,swap,free)
"""
base_price = self.price
options_price = 0.0
for option in variant[4]:
if option != '':
options_price = options_price + self.getOptionPrice(option)
return (base_price + options_price)
security.declareProtected(View, 'renderVariant')
def renderVariant(self, variant, REQUEST=None):
option_text = ''
for option in variant[4]:
if option != '':
option_text = option_text + "<li>%s</li>" % option
return "<p>Options:</p><ul>%s</ul>" % option_text
security.declareProtected(View, 'shortVariant')
def shortVariant(self, variant, REQUEST=None):
option_text = ''
for option in variant[4]:
if option != '':
option_text = option_text + "%s/" % option
return '<font size="-2"><i>%s</i></font>' % option_text
def addSimpleProduct(self, id, title='', REQUEST=None):
ob=SimpleProduct(id,title)
self._setObject(id, ob)
Globals.InitializeClass(SimpleProduct)
Zope Public License (ZPL) Version 2.0
-----------------------------------------------
This software is Copyright (c) Zope Corporation (tm) and
Contributors. All rights reserved.
This license has been certified as open source. It has also
been designated as GPL compatible by the Free Software
Foundation (FSF).
Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the
following conditions are met:
1. Redistributions in source code must retain the above
copyright notice, this list of conditions, and the following
disclaimer.
2. Redistributions in binary form must reproduce the above
copyright notice, this list of conditions, and the following
disclaimer in the documentation and/or other materials
provided with the distribution.
3. The name Zope Corporation (tm) must not be used to
endorse or promote products derived from this software
without prior written permission from Zope Corporation.
4. The right to distribute this software or to use it for
any purpose does not give you the right to use Servicemarks
(sm) or Trademarks (tm) of Zope Corporation. Use of them is
covered in a separate agreement (see
http://www.zope.com/Marks).
5. If any files are modified, you must cause the modified
files to carry prominent notices stating that you changed
the files and the date of any change.
Disclaimer
THIS SOFTWARE IS PROVIDED BY ZOPE CORPORATION ``AS IS''
AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
NO EVENT SHALL ZOPE CORPORATION OR ITS CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
This software consists of contributions made by Zope
Corporation and many individuals on behalf of Zope
Corporation. Specific attributions are listed in the
accompanying credits file.
##############################################################################
#
# Copyright (c) 2002 Jean-Paul Smets
# Copyright (c) 2002 Nexedi SARL
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version, with the special
# provision that the authors explicitly grant hereby the right to link this
# program with any versions of the Qt library including non GPL versions
#
# 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.
#
##############################################################################
"""
"""
ADD_FOLDERS_PERMISSION = 'Add portal folders'
import ComputerProduct
import ServiceProduct
import SimpleProduct
from Products.CMFCore import utils
from Products.CMFCore.DirectoryView import registerDirectory
import Products.MMMShop
# Aliases for previous mixed up version
__module_aliases__ = ( ( 'Products.MMMShop.ComputerProduct', ComputerProduct )
, ( 'Products.MMMShop.ServiceProduct', ServiceProduct )
)
# ...and make sure we can find them in PTKBase when we do
# 'manage_migrate_content()'.
Products.MMMShop.ComputerProduct = ComputerProduct
Products.MMMShop.ServiceProduct = ServiceProduct
contentClasses = (
ComputerProduct.ComputerProduct
, SimpleProduct.SimpleProduct
, ServiceProduct.ServiceProduct
)
contentConstructors = (
ComputerProduct.addComputerProduct
, SimpleProduct.addSimpleProduct
, ServiceProduct.addServiceProduct
)
bases = contentClasses
boring_globals = globals()
import sys
this_module = sys.modules[ __name__ ]
z_bases = utils.initializeBasesPhase1( bases, this_module )
#Make the skins availiable as DirectoryViews
registerDirectory('skins/storever', globals())
registerDirectory('skins/zpt_storever', globals())
registerDirectory('skins/cm_storever', globals())
def initialize( context ):
utils.initializeBasesPhase2( z_bases, context )
utils.ContentInit( 'Storever Shop Content'
, content_types=contentClasses
, permission=ADD_FOLDERS_PERMISSION
, extra_constructors=contentConstructors
, fti = (
ComputerProduct.factory_type_information
, ServiceProduct.factory_type_information
, SimpleProduct.factory_type_information )
).initialize( context )
<dtml-var standard_html_header>
<div class="Desktop">
<p><dtml-gettext>This form allows to pay online a custom service
or order which price has been defined specifically.</dtml-gettext></p>
<h1><dtml-gettext>Order Summary</dtml-gettext></h1>
<p><dtml-gettext><b>Invoice number</b>: </dtml-gettext><dtml-var invoice_number></p>
<p><dtml-gettext><b>Grand total</b>: </dtml-gettext><dtml-var montant> EUR.</p>
<p><dtml-gettext>Please refer to the invoice you received</dtml-gettext></p>
<h3><dtml-gettext>Online Payment</dtml-gettext></h3>
<p><dtml-gettext>With our secure online payment system operated by CIC, you can simply use you credit card to pay</dtml-gettext> <dtml-if payvat><dtml-var montantvat><dtml-else><dtml-var montant></dtml-if> EUR
<dtml-gettext> online with the same or better level of security as in the real world.</dtml-gettext></p>
<center>
<dtml-let code_societe="'nexedi'"
texte_bouton="gettext('Secure Online Payment')"
langue="gettext.get_selected_language()"
TPE="'/etc/cmmac/6496547.key'"
url_banque="'https://ssl.paiement.cic-banques.fr/paiement.cgi'"
texte_libre="invoice_number"
reference="invoice_number"
url_retour_err="'payme_rejected'"
url_retour_ok="'payme_accepted'">
<dtml-var "payment.CreerFormulaireCM(url_retour_err=url_retour_err,url_retour_ok=url_retour_ok,texte_libre=texte_libre,reference=reference,code_societe=code_societe,texte_bouton=texte_bouton, langue=langue, TPE=TPE, url_banque=url_banque,montant=montant)">
</dtml-let>
<dtml-var standard_html_footer>
\ No newline at end of file
<dtml-var standard_html_header>
<div class="Desktop">
<h1><dtml-gettext>Your payment has been accepted. Thank you.</dtml-gettext></h1>
</div>
<dtml-var standard_html_footer>
\ No newline at end of file
<dtml-var standard_html_header>
<div class="Desktop">
<h1><dtml-gettext>Sorry, your payment has been rejected.</dtml-gettext></h1>
</div>
<dtml-var standard_html_footer>
\ No newline at end of file
##parameters=setup_list
# Example code:
# Import a standard function, and get the HTML request and response objects.
from random import randrange
random_list0 = []
random_list1 = []
for (key, value) in setup_list:
if value == 0.0:
if randrange(0,2) == 0:
random_list0 = random_list0 + [(key , value)]
else:
random_list0 = [(key , value)] + random_list0
else:
random_list1 = random_list1 + [(key , value)]
return random_list0 + random_list1
\ No newline at end of file
## Script (Python) "addToCart"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=REQUEST=None,variant=None
##title=Add a product to the shopping cart
##
if REQUEST['quantity'] > 0:
shopping_cart = context.getShoppingCart()
prod_obj = context.restrictedTraverse(REQUEST['product_path'])
del_days = prod_obj.delivery_days
shopping_cart.addProductToCart(product=REQUEST['product_path']
, quantity=REQUEST['quantity']
, delivery_days=del_days
, variant=variant)
status_msg = 'Cart+updated'
else:
status_msg = 'Please+enter+a+quantity'
context.REQUEST.RESPONSE.redirect('shoppingcart_view' + '?portal_status_message=' + status_msg)
<dtml-let lang="gettext.get_selected_language()">
<dtml-let man_obj="getShopManager()">
<dtml-if "man_obj[0] == 0">
<dtml-let portal_status_message="'No shop manager found'">
<dtml-return checkOut>
</dtml-let>
<dtml-else>
<dtml-call "REQUEST.set('manager_obj', man_obj[1])">
</dtml-if>
</dtml-let>
<dtml-call "setCurrencyParams()">
<dtml-call "setPersonalDetailsParams()">
<dtml-call "REQUEST.set('cart_obj', getShoppingCart())">
<dtml-call "REQUEST.set('all_price', getTotalPrice())">
<dtml-in "cart_obj.listProducts()" sort=delivery_days>
<dtml-if sequence-end>
<dtml-let item="_.getitem('sequence-item')"
d_days="item.getDeliveryDays()">
<dtml-call "REQUEST.set('exp_delivery_days', d_days)">
</dtml-let>
</dtml-if>
</dtml-in>
<dtml-let delivery_date="ZopeTime() + _.int(REQUEST['exp_delivery_days'])"
formatted_delivery_date="delivery_date.strftime('%Y/%m/%d')">
<dtml-call "REQUEST.set('correct_ddate', formatted_delivery_date)">
</dtml-let>
<dtml-call "REQUEST.set('loggedin_user', getMemberObj().getUserName())">
<TABLE BORDER="0" width="100%">
<FORM ACTION="<dtml-var "manager_obj.httpsRoot">/&dtml-lang;/create_order_page" METHOD="POST">
<TR CLASS="NewsTitle">
<TD CLASS="NewsTitle" COLSPAN="2"><dtml-gettext>Check Out</dtml-gettext></TD>
</TR>
<INPUT TYPE="hidden" NAME="shopid" VALUE="<dtml-var "manager_obj.shopid">">
<INPUT TYPE="hidden" NAME="amount" VALUE="<dtml-var all_price fmt="%0.2f">">
<INPUT TYPE="hidden" NAME="cust_fax" VALUE="&dtml-loggedin_user;">
<INPUT TYPE="hidden" NAME="currency" VALUE="<dtml-var "REQUEST['cur_code']">">
<INPUT TYPE="hidden" NAME="sessionid" VALUE="<dtml-var "REQUEST['HTTP_COOKIE']">">
<TR>
<TD COLSPAN="2">
<p><dtml-gettext>You are about to submit an order to</dtml-gettext> <dtml-var "gettext(manager_obj.shop_from_name)"> <dtml-gettext>for a total amount of</dtml-gettext> <B><dtml-var expr="all_price + all_price * portal_properties.vat" fmt="%0.2f">&nbsp;&dtml-money_unit;</B> <dtml-gettext>(incl. VAT)</dtml-gettext> /
&nbsp;<b><dtml-var expr="all_price "
fmt="%0.2f">&nbsp;&dtml-money_unit;</B> <dtml-gettext>(excl. VAT)</dtml-gettext></p>
<p><dtml-gettext>Expected day of delivery:</dtml-gettext> <B>&dtml-correct_ddate;</B></p>
<p><dtml-gettext>Before we proceed to payment options, please provide the shipping address for this order:</dtml-gettext></p>
<p />
</TD>
</TR>
<TR>
<TD><dtml-gettext>Name:</dtml-gettext></TD>
<TD><INPUT TYPE="text" NAME="cust_name" VALUE="<dtml-var "REQUEST['cust_name']">"></TD>
</TR>
<TR>
<TD><dtml-gettext>Organisation:</dtml-gettext></TD>
<TD><INPUT TYPE="text" NAME="cust_organisation" VALUE="<dtml-var "REQUEST['cust_organisation']">"></TD>
</TR>
<TR>
<TD><dtml-gettext>Address:</dtml-gettext></TD>
<TD><textarea NAME="cust_address"><dtml-var "REQUEST['cust_address']"></textarea></TD>
</TR>
<TR>
<TD><dtml-gettext>Zip code:</dtml-gettext></TD>
<TD><INPUT TYPE="text" NAME="cust_zipcode" VALUE="<dtml-var "REQUEST['cust_zipcode']">"></TD>
</TR>
<TR>
<TD><dtml-gettext>City:</dtml-gettext></TD>
<TD><INPUT TYPE="text" NAME="cust_city" VALUE="<dtml-var "REQUEST['cust_city']">"></TD>
</TR>
<TR>
<TD><dtml-gettext>Country:</dtml-gettext></TD>
<TD><select name="cust_country">
<dtml-in "portal_properties.shipping_countries">
<option value="&dtml-sequence-item;" <dtml-if "REQUEST['cust_country'] == _['sequence-item']">selected</dtml-if>><dtml-var "gettext(_['sequence-item'])"></option>
</dtml-in>
</select>
<br><font size="-2"><dtml-gettext>If your country is not listed here, it simply means we are unable to ship to your country at the present time. We deeply apologize for this inconvenience.</dtml-gettext>
</TD>
</TR>
<TR>
<TD><dtml-gettext>Phone:</dtml-gettext></TD>
<TD><INPUT TYPE="text" NAME="cust_phone" VALUE="<dtml-var "REQUEST['cust_phone']">"></TD>
</TR>
<TR>
<TD><dtml-gettext>Email:</dtml-gettext></TD>
<TD><INPUT TYPE="text" NAME="cust_email" VALUE="<dtml-var "REQUEST['cust_email']">"></TD>
</TR>
<TR>
<TD><dtml-gettext>VAT Number:</dtml-gettext></TD>
<TD><INPUT TYPE="text" NAME="cust_vat" VALUE="<dtml-var "REQUEST['cust_vat']">">
<br><font size="-2"><dtml-gettext>EU Companies outside France will not pay the VAT if they provide a valid EU VAT Number. Customers outside EU (company or not) will not pay the VAT at all.
</dtml-gettext>
</TD>
</TR>
<TR>
<TD COLSPAN="2" HEIGHT="4">&nbsp;</TD>
</TR>
<TR>
<TD COLSPAN="2" align="center"><INPUT TYPE="submit" VALUE=" <dtml-gettext>Proceed to payment options</dtml-gettext> "></TD>
</TR>
</FORM>
</TABLE>
</dtml-let>
\ No newline at end of file
<dtml-var standard_html_header>
<dtml-call "REQUEST.set('currency_manager', getCurrencyManager())">
<dtml-call "REQUEST.set('member_currency', getMemberObj().pref_currency)">
<TABLE BORDER="0" WIDTH="100%">
<TR>
<TD VALIGN="top" WIDTH="50%"><dtml-var checkOut></TD>
</TR>
</TABLE>
<dtml-var standard_html_footer>
\ No newline at end of file
<dtml-var standard_html_header>
<dtml-call "REQUEST.set('local_currency_name', getLocalCurrencyName())">
<TABLE BORDER="0" WIDTH="100%" CLASS="FormLayout">
<FORM ACTION="update_computer_product" METHOD="POST" ENCTYPE="multipart/form-data">
<TR>
<TH VALIGN="top">Navn:</TD>
<TD><INPUT TYPE="text" NAME="prod_name" VALUE="&dtml-title;">
<DL CLASS="FieldHelp">
<DD>The name of the product.</DD>i
</DL>
</TD>
</TR>
<TR>
<TH VALIGN="top">Short Description:</TD>
<TD><TEXTAREA NAME="description" ROWS="5" COLS="30">&dtml-description;</TEXTAREA>
<DL CLASS="FieldHelp">
<DD>The description of the product.</DD>
</DL>
</TD>
</TR>
<TR>
<TH VALIGN="top">Long Description:</TD>
<TD><textarea name="text:text"
rows="20" cols="80"><dtml-var text html_quote></textarea>
</TD>
</TR>
<TR>
<TH VALIGN="top">Category:</TD>
<TD>
<SELECT NAME="prod_category:list" SIZE="3" MULTIPLE>
<dtml-let contentSubject=Subject
allowedSubjects="portal_metadata.listAllowedSubjects(this())">
<dtml-in allowedSubjects>
<dtml-let item=sequence-item
sel="item in contentSubject and 'selected' or ''">
<OPTION VALUE="&dtml-sequence-item;" &dtml-sel;>&dtml-sequence-item;</OPTION>
</dtml-let>
</dtml-in>
</dtml-let>
</SELECT>
<DL CLASS="FieldHelp">
<DD>You should place your procu in one - or more - category, so visitors on the site can find your product easier.
Pick the category that fits your product best.</DD>
</DL>
</TD>
</TR>
<TR>
<TH VALIGN="top">Price:</TD>
<TD><INPUT TYPE="text" NAME="price:float" VALUE="&dtml-price;">
<DL CLASS="FieldHelp">
<DD>The price of your product (in <dtml-var "REQUEST['local_currency_name']">).</DD>
</DL>
</TD>
</TR>
<TR>
<TH VALIGN="top">Days to deliver:</TD>
<TD><INPUT TYPE="text" NAME="delivery_days:int" VALUE="&dtml-delivery_days;">
<DL CLASS="FieldHelp">
<DD>How many days will it take to deliver your product (as precise as possible).</DD>
</DL>
</TD>
</TR>
<TR>
<TH VALIGN="top">Thumbnail picture:</TD>
<TD><INPUT TYPE="file" NAME="thumbnail" VALUE=""><BR>
&dtml-thumbnail;
<DL CLASS="FieldHelp">
<DD>A little picturre of the product that can be shown in the product catalog.</DD>
</DL>
</TD>
</TR>
<TR>
<TH VALIGN="top">Large picture:</TD>
<TD><INPUT TYPE="file" NAME="image" VALUE=""><BR>
&dtml-image;
<DL CLASS="FieldHelp">
<DD>Picture of your product that will be used at the product page.</DD>
</DL>
</TD>
</TR>
<TR>
<TH VALIGN="top">Product Path:</TD>
<TD><INPUT TYPE="text" NAME="product_path" VALUE="<dtml-if product_path><dtml-var product_path></dtml-if>"><BR>
<DL CLASS="FieldHelp">
<DD>Product path.</DD>
</DL>
</TD>
</TR>
<TR>
<TH VALIGN="top">Processor:</TD>
<TD>
<dtml-in "getProcessorSizes()">
<INPUT TYPE="text" NAME="procsize_&dtml-sequence-number;" VALUE="&dtml-sequence-item;">&nbsp;
<INPUT TYPE="text" NAME="procprice_&dtml-sequence-number;:float" VALUE="<dtml-var "getProcessorPrice(_['sequence-item'])">"><br>
</dtml-in>
<INPUT TYPE="text" NAME="procsize_new" VALUE="">&nbsp;
<INPUT TYPE="text" NAME="procprice_new:float" VALUE="0.0">
<DL CLASS="FieldHelp">
<DD>The price of processor options.</DD>
</DL>
</TD>
</TR>
<TR>
<TH VALIGN="top">Memory:</TD>
<TD>
<dtml-in "getMemorySizes()">
<INPUT TYPE="text" NAME="memsize_&dtml-sequence-number;" VALUE="&dtml-sequence-item;">&nbsp;
<INPUT TYPE="text" NAME="memprice_&dtml-sequence-number;:float" VALUE="<dtml-var "getMemoryPrice(_['sequence-item'])">"><br>
</dtml-in>
<INPUT TYPE="text" NAME="memsize_new" VALUE="">&nbsp;
<INPUT TYPE="text" NAME="memprice_new:float" VALUE="0.0">
<DL CLASS="FieldHelp">
<DD>The price of memory options.</DD>
</DL>
</TD>
</TR>
<TR>
<TH VALIGN="top">Disk:</TD>
<TD>
<dtml-in "getDiskSizes()">
<INPUT TYPE="text" NAME="disksize_&dtml-sequence-number;" VALUE="&dtml-sequence-item;">&nbsp;
<INPUT TYPE="text" NAME="diskprice_&dtml-sequence-number;:float" VALUE="<dtml-var "getDiskPrice(_['sequence-item'])">"><br>
</dtml-in>
<INPUT TYPE="text" NAME="disksize_new" VALUE="">&nbsp;
<INPUT TYPE="text" NAME="diskprice_new:float" VALUE="0.0">
<DL CLASS="FieldHelp">
<DD>The price of disk options.</DD>
</DL>
</TD>
</TR>
<TR>
<TH VALIGN="top">Options:</TD>
<TD>
<dtml-in "getOptions()">
<INPUT TYPE="text" NAME="option_&dtml-sequence-number;" VALUE="&dtml-sequence-item;">&nbsp;
<INPUT TYPE="text" NAME="optionprice_&dtml-sequence-number;:float" VALUE="<dtml-var "getOptionPrice(_['sequence-item'])">"><br>
</dtml-in>
<INPUT TYPE="text" NAME="option_new" VALUE="">&nbsp;
<INPUT TYPE="text" NAME="optionprice_new:float" VALUE="0.0">
<DL CLASS="FieldHelp">
<DD>The price of service options.</DD>
</DL>
</TD>
</TR>
<!-- test to see if NON option should be checked -->
<dtml-if "this().isCredit">
<dtml-if "this().isCredit == 1">
<dtml-call "REQUEST.set('credit_sel', '')">
<dtml-else>
<dtml-call "REQUEST.set('credit_sel', 'CHECKED')">
</dtml-if>
<dtml-else>
<dtml-call "REQUEST.set('credit_sel', 'CHECKED')">
</dtml-if>
<TR>
<TH VALIGN="top">Is this a credit product?</TD>
<TD><INPUT TYPE="radio" NAME="isCredit" VALUE="1"
<dtml-if "this().isCredit"><dtml-if "this().isCredit == 1">CHECKED</dtml-if></dtml-if>
>Yes&nbsp;
<INPUT TYPE="radio" NAME="isCredit" VALUE="0" &dtml-credit_sel;>No
<DL CLASS="FieldHelp">
<DD>If your product is a credits product, the visitors can buy minutes to be used in pay-per-view cinemas.</DD>
</DL>
</TD>
</TR>
<dtml-if "this().isCredit">
<TR>
<TH VALIGN="top">Credits amount:</TD>
<TD><INPUT TYPE="text" NAME="credits:int" VALUE="&dtml-credits;">
<DL CLASS="FieldHelp">
<DD>How many credits the users get.</DD>
</DL>
</TD>
</TR>
<dtml-else>
<INPUT TYPE="hidden" NAME="credits:int" VALUE="&dtml-credits;">
</dtml-if>
<TR>
<TD COLSPAN="2"><INPUT TYPE="submit" VALUE=" Save "></TD>
</TR>
</FORM>
</TABLE>
<dtml-var standard_html_footer>
<table width="100%"><tr>
<td valign="top">
<p><dtml-gettext>Hardware:</dtml-gettext></p>
<ul>
<li><dtml-gettext>Color:</dtml-gettext> <dtml-var "variant[0]"></li>
<li><dtml-gettext>Processor:</dtml-gettext> <dtml-var "variant[1]"></li>
<li><dtml-gettext>Memory:</dtml-gettext> <dtml-var "variant[2]"></li>
<li><dtml-gettext>Disk:</dtml-gettext> <dtml-var "variant[3]"></li>
</ul>
<p><dtml-gettext>Options:</dtml-gettext></p>
<ul>
<dtml-in "variant[4]">
<li><dtml-var "gettext(_['sequence-item'])"></li>
</dtml-in>
</ul>
</td>
<td valign="top">
<p><dtml-gettext>Setup:</dtml-gettext> <dtml-var "variant[5]"></p>
<p><dtml-gettext>Configuration URL:</dtml-gettext> <dtml-var "variant[6]"></p>
<p><dtml-gettext>Partition:</dtml-gettext></p>
<ul>
<li>/root: <dtml-var "variant[7]"></li>
<li>/boot: <dtml-var "variant[8]"></li>
<li>/usr: <dtml-var "variant[9]"></li>
<li>/home: <dtml-var "variant[10]"></li>
<li>/var: <dtml-var "variant[11]"></li>
<li>/tmp: <dtml-var "variant[12]"></li>
<li>/swap: <dtml-var "variant[13]"></li>
<li>/free: <dtml-var "variant[14]"></li></ul>
</td>
</tr></table>
<dtml-var standard_html_header>
<dtml-in "portal_catalog.searchResults(meta_type='MMM Shop Currency Manager')">
<dtml-call "REQUEST.set('currency_manager', restrictedTraverse(path))">
</dtml-in>
<dtml-if "portal_membership.isAnonymousUser()">
<dtml-call "REQUEST.set('member_currency', 'EUR')">
<dtml-else>
<dtml-let member="portal_membership.getAuthenticatedMember()">
<dtml-call "REQUEST.set('member_currency', member.pref_currency)">
</dtml-let>
</dtml-if>
<div CLASS="Desktop">
<TABLE BORDER="0" WIDTH="100%" cellspacing="3" cellpadding="3">
<TR>
<TD ALIGN="CENTER" VALIGN="top">
<dtml-var computerproduct_presentation>
</TD>
</TR>
</TABLE>
</div>
<dtml-var standard_html_footer>
<dtml-let man_obj="getShopManager()">
<dtml-if "man_obj[0] == 0">
<dtml-let portal_status_message="'No shop manager found'">
<dtml-return checkOut>
</dtml-let>
<dtml-else>
<dtml-call "REQUEST.set('manager_obj', man_obj[1])">
</dtml-if>
</dtml-let>
<dtml-call "manager_obj.createOrder(REQUEST)">
<dtml-let order_obj="portal_membership.getHomeFolder(getMemberObj().getUserName())[orderid]">
<dtml-call "REQUEST.RESPONSE.redirect('%s/order_confirm_form' % order_obj.local_absolute_url())">
</dtml-let>
<dtml-let show_language_selector="0" show_breadcrumb="0">
<dtml-var standard_html_header>
<h1><dtml-gettext>Custommer Registration</dtml-gettext></h1>
<table>
<tr>
<td valign="top">
<h2><dtml-gettext>New Custommers</dtml-gettext></h2>
<p><dtml-gettext>If you are a new custommer, please provide bellow your
personal information in order to let us identify you.</dtml-gettext></p>
<form method="POST" action="register_and_addToCart">
<dtml-in "('color',
'quantity','product_path','processor','memory','disk','drive','setup',
'fs','root_partition','boot_partition','usr_partition','home_partition',
'var_partition','swap_partition','tmp_partition','free_partition', 'config_url',
'support','monitoring','backup','archive','hosting','keyboard')">
<input type="hidden" name="&dtml-sequence-item;" value="<dtml-var
"REQUEST[_['sequence-item']]">">
</dtml-in>
<dtml-in "getOptionValues('Option')">
<dtml-if "REQUEST.has_key('option_%s' % _['sequence-number'])">
<input type="hidden" name="option_&dtml-sequence-number;"
value="&dtml-sequence-item">
</dtml-if>
</dtml-in>
<input type="hidden" name="last_visit:date" value="<dtml-var ZopeTime>">
<input type="hidden" name="prev_visit:date" value="<dtml-var ZopeTime>">
<table class="FormLayout">
<tr valign="top">
<th> <dtml-gettext>Login Name</dtml-gettext>
</th>
<td>
<input type="text"
name="username" size="30"
value="<dtml-if username><dtml-var username></dtml-if>">
</td>
</tr>
<tr>
<th> <dtml-gettext>Email Address</dtml-gettext>
</th>
<td align="left" valign="top">
<input type="text" name="email" size="30"
value="<dtml-if email><dtml-var email></dtml-if>">
</td>
</tr>
<dtml-unless expr="portal_properties.validate_email">
<tr>
<th> <dtml-gettext>Password</dtml-gettext>
</th>
<td align="left" valign="top">
<input type="password" name="password" size="30">
</td>
</tr>
<tr>
<th> <dtml-gettext>Password (confirm)</dtml-gettext>
</th>
<td align="left" valign="top">
<input type="password" name="confirm" size="30">
</td>
</tr>
<tr>
<th> <dtml-gettext>Mail Password?</dtml-gettext>
</th>
<td>
<input type="checkbox" name="mail_me" size="30" id="cb_mailme" />
<em><label for="cb_mailme"><dtml-gettext>Check this box to have your password
mailed to you.</dtml-gettext></label></em>
</td>
</tr>
</dtml-unless>
<dtml-comment> These items do not actually exist (yet?)
<tr>
<th> Full Name<br>(Optional)
</th>
<td>
<input type="text" name="full_name" size="30"
value="<dtml-if full_name><dtml-var full_name></dtml-if>">
</td>
</tr>
<tr>
<th> Company<br>(Optional)
</th>
<td>
<input type="text" name="company" size="30"
value="<dtml-if company><dtml-var company></dtml-if>">
</td>
</tr>
</dtml-comment>
<dtml-comment>
<dtml-in CommonProperties>
<dtml-let property_name=sequence-item
current_value="_.has_key(property_name) and _[property_name] or ''">
<tr>
<th> <dtml-var sequence-item spacify>
</th>
<td>
<input type="text" name="<dtml-var sequence-item>" size="30"
value="&dtml-current_value;">
</td>
</tr>
</dtml-let>
</dtml-in>
</dtml-comment>
</table>
<p align="center"><input type="submit" value=" <dtml-gettext>Register & Add
to Cart</dtml-gettext> "></p>
</form>
</td>
<td valign="top">
<h2><dtml-gettext>Existing Custommers</dtml-gettext></h2>
<p><dtml-gettext>If you are a registered custommer, please provide your user
login and password in order to proceed.</dtml-gettext></p>
<form method="POST" action="login_and_addToCart">
<dtml-in
"('color','processor','quantity','product_path','memory','disk','drive','setup'
,
'fs','root_partition','boot_partition','usr_partition','home_partition',
'var_partition','swap_partition','tmp_partition','free_partition', 'config_url',
'support','monitoring','backup','archive','hosting','keyboard')">
<input type="hidden" name="&dtml-sequence-item;" value="<dtml-var
"REQUEST[_['sequence-item']]">">
</dtml-in>
<dtml-in "getOptionValues('Option')">
<dtml-if "REQUEST.has_key('option_%s' % _['sequence-number'])">
<input type="hidden" name="option_&dtml-sequence-number;"
value="&dtml-sequence-item">
</dtml-if>
</dtml-in>
<table class="FormLayout">
<tr>
<td align="left" valign="top">
<strong><dtml-gettext>Name:</dtml-gettext></strong>
</td>
<td align="left" valign="top">
<input type="TEXT" name="__ac_name" size="20"
value="<dtml-var "REQUEST.get('__ac_name', '')">">
</td>
</tr>
<tr>
<td align="left" valign="top">
<strong><dtml-gettext>Password:</dtml-gettext></strong>
</td>
<td align="left" valign="top">
<input type="PASSWORD" name="__ac_password" size="20">
</td>
</tr>
</table>
<p align="center"><input type="submit" value=" <dtml-gettext>Login & Add to
Cart</dtml-gettext> "></p>
</form>
</td>
</tr>
</table>
<dtml-var standard_html_footer>
</dtml-let>
This diff is collapsed.
<dtml-if "'index.html' in objectIds()">
<dtml-var index.html>
<dtml-elif "'index.stx' in objectIds()">
<dtml-var index.stx>
<dtml-elif "'default.htm' in objectIds()">
<dtml-var default.htm>
<dtml-else>
<dtml-var standard_html_header>
<dtml-let folder_url=absolute_url>
<div class="Document">
<dtml-if name="Description">
<p><dtml-var TranslatedDescription></p>
</dtml-if>
<dtml-in expr="objectValues(['MMM Computer Product','Base18 Folder'])" skip_unauthorized
sort=TranslatedTitle_or_id>
<dtml-let obj="_.getitem('sequence-item', 0 )"
folderish=isPrincipiaFolderish
portalish="_.hasattr( obj, 'isPortalContent' ) and obj.isPortalContent"
getIcon="_.hasattr(obj, 'getIcon') and obj.getIcon()"
icon="getIcon or _.getattr(obj, 'icon', '')">
<dtml-if portalish>
<h1>
<dtml-if icon>
<a href="&dtml-folder_url;/&dtml.url_quote-getId;"><img
src="&dtml-portal_url;/&dtml-icon;" alt="&dtml-Type;" border="0">
</a>
</dtml-if>
<a href="&dtml-folder_url;/&dtml.url_quote-getId;"
>&dtml-TranslatedTitle_or_id;</a>
</h1>
<dtml-if name="Description">
<p>&dtml.html_quote-TranslatedDescription;</p>
</dtml-if>
</dtml-if>
</dtml-let>
</dtml-in>
</div>
</dtml-let>
<dtml-var standard_html_footer>
</dtml-if>
\ No newline at end of file
## Script (Python) "getCurrencyManager"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=Uggly patch to bypass ZSQLCatalog issue
##
return context.CurrencyManager
## Script (Python) "getShopManager"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=Uggly patch to bypass ZSQLCatalog issue
##
return 1, context.ShopManager
## Script (Python) "getTotalPrice"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=Computer Total Price
##
shopping_cart = context.getShoppingCart()
exchange_rate = context.REQUEST['exchange_rate']
cur_code = context.REQUEST['cur_code']
shopmanager = context.getShopManager()[1]
local_fee = shopmanager.send_fee_local
world_fee = shopmanager.send_fee_world
exchange_fee = shopmanager.exchange_fee
all_price = 0
for item in shopping_cart.listProducts():
product_path = item.getProduct()
quantity = item.getQuantity()
variant = item.getVariant()
product = context.restrictedTraverse(product_path)
prod_deliver_days = product.delivery_days
prod_price = product.computePrice(variant)
price = float(prod_price) / float(exchange_rate)
total_price = int(quantity) * float(price)
all_price = float(all_price) + float(total_price)
item.setDeliveryDays(prod_deliver_days)
if cur_code == shopmanager.local_currency:
send_fee = float(local_fee)
exc_fee = float(0)
else:
send_fee = float(world_fee) / float(exchange_rate)
exc_fee = float(exchange_fee) / float(exchange_rate)
all_price = float(all_price) + float(send_fee) + float(exc_fee)
return all_price
##parameters=euvat , country
# Tells if this client has to pay VAT
eu_countries = [ 'Austria', 'Belgium', 'Denmark', 'Finland', 'France', 'Germany', 'Greece', 'Ireland', 'Italy', 'Luxembourg', 'Netherlands', 'Portugal', 'Spain', 'Sweden' ,'United Kingdom']
if euvat != '' and country != 'France':
return 0
if not country in eu_countries:
return 0
return 1
\ No newline at end of file
<dtml-var standard_html_header>
<p>
<dtml-if expr="portal_membership.isAnonymousUser()">
You have been logged out.
<dtml-else>
You are logged in outside the portal. You may need to
<a href="/manage_zmi_logout">log out of the Zope management interface</a>.
</dtml-if>
</p>
<dtml-var standard_html_footer>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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