diff --git a/product/ERP5Type/InitGenerator.py b/product/ERP5Type/InitGenerator.py index a8880717a1f24176b754d8e28283fd367bb1438d..e8b44b477746db805055bcaea86ee521f1f97c74 100755 --- a/product/ERP5Type/InitGenerator.py +++ b/product/ERP5Type/InitGenerator.py @@ -36,6 +36,11 @@ from zLOG import LOG global product_document_registry product_document_registry = [] +def getProductDocumentPathList(): + result = product_document_registry + result.sort() + return result + def InitializeDocument(document_class, document_path=None): global product_document_registry # Register class in ERP5Type.Document diff --git a/product/ERP5Type/Permissions.py b/product/ERP5Type/Permissions.py index 6a2b0c98ac988ec43acf4783783b8c338e2367d3..d6fdbe1e1baca22c1bd91d8ae2c4a1293394dcd4 100755 --- a/product/ERP5Type/Permissions.py +++ b/product/ERP5Type/Permissions.py @@ -134,3 +134,6 @@ setDefaultRoles(TranslateContent, ('Manager', 'Owner', 'Member')) #setDefaultRoles(AddERP5Content, ('Manager', )) AddERP5Content = AddPortalContent # Since we put come CPS content in ERP5 documents, there is no rationale in having 2 permissions +# Source Code Management - this is the highest possible permission +ManageExtensions = "Manage extensions" + diff --git a/product/ERP5Type/Tool/ClassTool.py b/product/ERP5Type/Tool/ClassTool.py index 7492835aec1fa93d2ca6ef9679a14a555847f9e1..c7f0c32a2c9d02cf61ae8c9ff24c63a77fcbd9f1 100755 --- a/product/ERP5Type/Tool/ClassTool.py +++ b/product/ERP5Type/Tool/ClassTool.py @@ -39,6 +39,7 @@ from Products.ERP5Type.Document.Folder import Folder from Products.ERP5Type.Utils import readLocalPropertySheet, writeLocalPropertySheet, getLocalPropertySheetList from Products.ERP5Type.Utils import readLocalExtension, writeLocalExtension, getLocalExtensionList from Products.ERP5Type.Utils import readLocalDocument, writeLocalDocument, getLocalDocumentList +from Products.ERP5Type.InitGenerator import getProductDocumentPathList class ClassTool(BaseTool): """ @@ -85,6 +86,12 @@ class ClassTool(BaseTool): security.declareProtected( Permissions.ManagePortal, 'manage_editDocumentForm' ) manage_editDocumentForm = DTMLFile( 'editDocumentForm', _dtmldir ) + security.declareProtected( Permissions.ManagePortal, 'manage_editExtensionForm' ) + manage_editExtensionForm = DTMLFile( 'editExtensionForm', _dtmldir ) + + security.declareProtected( Permissions.ManagePortal, 'manage_editPropertySheetForm' ) + manage_editPropertySheetForm = DTMLFile( 'editPropertySheetForm', _dtmldir ) + security.declareProtected( Permissions.ManagePortal, 'getLocalPropertySheetList' ) def getLocalPropertySheetList(self): """ @@ -106,6 +113,13 @@ class ClassTool(BaseTool): """ return getLocalDocumentList() + security.declareProtected( Permissions.ManagePortal, 'getProductDocumentPathList' ) + def getProductDocumentPathList(self): + """ + Return a list of Document id which can be modified through the web + """ + return getProductDocumentPathList() + security.declareProtected( Permissions.ManagePortal, 'getDocumentText' ) def getDocumentText(self, class_id): """ @@ -113,7 +127,7 @@ class ClassTool(BaseTool): """ return readLocalDocument(class_id) - security.declareProtected( Permissions.ManagePortal, 'newDocument' ) + security.declareProtected( Permissions.ManageExtensions, 'newDocument' ) def newDocument(self, class_id, REQUEST=None): """ Updates a Document with a new text @@ -173,7 +187,7 @@ class %s(XMLObject): if REQUEST is not None: REQUEST.RESPONSE.redirect('%s/manage_editDocumentForm?class_id=%s&message=Document+Created' % (self.absolute_url(), class_id)) - security.declareProtected( Permissions.ManagePortal, 'editDocument' ) + security.declareProtected( Permissions.ManageExtensions, 'editDocument' ) def editDocument(self, class_id, text, REQUEST=None): """ Updates a Document with a new text @@ -183,16 +197,154 @@ class %s(XMLObject): if REQUEST is not None: REQUEST.RESPONSE.redirect('%s/manage_editDocumentForm?class_id=%s&message=Document+Saved' % (self.absolute_url(), class_id)) - security.declareProtected( Permissions.ManagePortal, 'importDocument' ) - def importDocument(self, class_id, REQUEST=None): + security.declareProtected( Permissions.ManageExtensions, 'importDocument' ) + def importDocument(self, class_id, class_path=None, REQUEST=None): """ Imports a document class """ from Products.ERP5Type.Utils import importLocalDocument local_product = self.Control_Panel.Products.ERP5Type app = local_product._p_jar.root()['Application'] - importLocalDocument(class_id) - if REQUEST is not None: + importLocalDocument(class_id, document_path=class_path) + if REQUEST is not None and class_path is None: REQUEST.RESPONSE.redirect('%s/manage_editDocumentForm?class_id=%s&message=Document+Reloaded+Successfully' % (self.absolute_url(), class_id)) + + security.declareProtected( Permissions.ManagePortal, 'getPropertySheetText' ) + def getPropertySheetText(self, class_id): + """ + Updates a PropertySheet with a new text + """ + return readLocalPropertySheet(class_id) + + security.declareProtected( Permissions.ManageExtensions, 'newPropertySheet' ) + def newPropertySheet(self, class_id, REQUEST=None): + """ + Updates a PropertySheet with a new text + """ + text = """ +############################################################################## +# +# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved. +# +# 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 PropertySheetTemplate: + \"\"\" + PropertySheetTemplate properties for all ERP5 objects + \"\"\" + + _properties = ( + { 'id' : 'a_property', + 'description' : 'A local property description', + 'type' : 'string', + 'mode' : '' }, + ) + + +""" + writeLocalPropertySheet(class_id, text) + if REQUEST is not None: + REQUEST.RESPONSE.redirect('%s/manage_editPropertySheetForm?class_id=%s&message=PropertySheet+Created' % (self.absolute_url(), class_id)) + + security.declareProtected( Permissions.ManageExtensions, 'editPropertySheet' ) + def editPropertySheet(self, class_id, text, REQUEST=None): + """ + Updates a PropertySheet with a new text + """ + previous_text = readLocalPropertySheet(class_id) + writeLocalPropertySheet(class_id, text) + if REQUEST is not None: + REQUEST.RESPONSE.redirect('%s/manage_editPropertySheetForm?class_id=%s&message=PropertySheet+Saved' % (self.absolute_url(), class_id)) + + security.declareProtected( Permissions.ManageExtensions, 'importPropertySheet' ) + def importPropertySheet(self, class_id, REQUEST=None): + """ + Imports a PropertySheet class + """ + from Products.ERP5Type.Utils import importLocalPropertySheet + local_product = self.Control_Panel.Products.ERP5Type + app = local_product._p_jar.root()['Application'] + importLocalPropertySheet(class_id) + if REQUEST is not None: + REQUEST.RESPONSE.redirect('%s/manage_editPropertySheetForm?class_id=%s&message=PropertySheet+Reloaded+Successfully' % (self.absolute_url(), class_id)) + + security.declareProtected( Permissions.ManagePortal, 'getExtensionText' ) + def getExtensionText(self, class_id): + """ + Updates a Extension with a new text + """ + return readLocalExtension(class_id) + + security.declareProtected( Permissions.ManageExtensions, 'newExtension' ) + def newExtension(self, class_id, REQUEST=None): + """ + Updates a Extension with a new text + """ + text = """ +############################################################################## +# +# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved. +# +# 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. +# +############################################################################## + +def myExtensionMethod(context, param=None): + pass +""" + writeLocalExtension(class_id, text) + if REQUEST is not None: + REQUEST.RESPONSE.redirect('%s/manage_editExtensionForm?class_id=%s&message=Extension+Created' % (self.absolute_url(), class_id)) + + security.declareProtected( Permissions.ManageExtensions, 'editExtension' ) + def editExtension(self, class_id, text, REQUEST=None): + """ + Updates a Extension with a new text + """ + previous_text = readLocalExtension(class_id) + writeLocalExtension(class_id, text) + if REQUEST is not None: + REQUEST.RESPONSE.redirect('%s/manage_editExtensionForm?class_id=%s&message=Extension+Saved' % (self.absolute_url(), class_id)) + InitializeClass(ClassTool) diff --git a/product/ERP5Type/Utils.py b/product/ERP5Type/Utils.py index 887718d53e41b7970e08e14c0a32a62fa6d00ce8..ca1aeb0c663df9bd48e0ed6be12fb16f6f2e480c 100755 --- a/product/ERP5Type/Utils.py +++ b/product/ERP5Type/Utils.py @@ -251,6 +251,7 @@ def getLocalPropertySheetList(): for fname in file_list: if python_file_parser.match(fname) is not None: result.append(python_file_parser.match(fname).groups()[0]) + result.sort() return result def readLocalPropertySheet(class_id): @@ -308,6 +309,7 @@ def getLocalExtensionList(): for fname in file_list: if python_file_parser.match(fname) is not None: result.append(python_file_parser.match(fname).groups()[0]) + result.sort() return result def readLocalExtension(class_id): @@ -334,6 +336,7 @@ def getLocalDocumentList(): for fname in file_list: if python_file_parser.match(fname) is not None: result.append(python_file_parser.match(fname).groups()[0]) + result.sort() return result def readLocalDocument(class_id): diff --git a/product/ERP5Type/dtml/editExtensionForm.dtml b/product/ERP5Type/dtml/editExtensionForm.dtml new file mode 100755 index 0000000000000000000000000000000000000000..20cd53c94561a6b0e9658a95df0b96e9340233db --- /dev/null +++ b/product/ERP5Type/dtml/editExtensionForm.dtml @@ -0,0 +1,15 @@ +<dtml-var manage_page_header> +<dtml-var manage_tabs> + +<h2>Edit Extension Class: <dtml-var class_id></h2> + +<dtml-if message><dtml-var message></dtml-if> + +<form method="POST" action="<dtml-var absolute_url>"> +<textarea name="text:text" rows="20" cols="82"><dtml-var "getExtensionText(class_id)"></textarea> +<br> +<input type="hidden" name="class_id:string" value="<dtml-var class_id>"> +<input type="submit" value="Save" name="editExtension:method"> +</form> + +<dtml-var manage_page_footer> diff --git a/product/ERP5Type/dtml/editPropertySheetForm.dtml b/product/ERP5Type/dtml/editPropertySheetForm.dtml new file mode 100755 index 0000000000000000000000000000000000000000..acbf14bef1ca6a19589df4f05933a82eef48d761 --- /dev/null +++ b/product/ERP5Type/dtml/editPropertySheetForm.dtml @@ -0,0 +1,16 @@ +<dtml-var manage_page_header> +<dtml-var manage_tabs> + +<h2>Edit Property Sheet Class: <dtml-var class_id></h2> + +<dtml-if message><dtml-var message></dtml-if> + +<form method="POST" action="<dtml-var absolute_url>"> +<textarea name="text:text" rows="20" cols="82"><dtml-var "getPropertySheetText(class_id)"></textarea> +<br> +<input type="hidden" name="class_id:string" value="<dtml-var class_id>"> +<input type="submit" value="Save" name="editPropertySheet:method"> +<input type="submit" value="Reload" name="importPropertySheet:method"> +</form> + +<dtml-var manage_page_footer> diff --git a/product/ERP5Type/dtml/viewDocumentList.dtml b/product/ERP5Type/dtml/viewDocumentList.dtml index 3e379437eb23f68e03c5d02f039e875645e5005a..2a07c36073902afb2a84bbf3f7e8843338c337b9 100755 --- a/product/ERP5Type/dtml/viewDocumentList.dtml +++ b/product/ERP5Type/dtml/viewDocumentList.dtml @@ -1,15 +1,64 @@ <dtml-var manage_page_header> <dtml-var manage_tabs> -<h1>Document Classes</h1> - -<ul> -<dtml-in getLocalDocumentList><li><a href="manage_editDocumentForm?class_id=<dtml-var sequence-item>"><dtml-var sequence-item></a></li></dtml-in> - -<hr> +<div class="std-text"><p><strong>Local Document Classes</strong></p></div> <form method="POST" action="newDocument"> +<table width="100%"> + <tr class="list-header"> + <th> + Class + </th> + <th> + Action + </th> + <dtml-in getLocalDocumentList> + <tr> + <td> + <div class="list-item"><dtml-var sequence-item></div> + </td> + <td> + <div class="list-item"><a href="manage_editDocumentForm?class_id=<dtml-var sequence-item>">edit</a> <a href="importDocument?class_id=<dtml-var sequence-item>">reload</a> + </div> + </td> + </tr> + </dtml-in> +</table> + <input type="text" name="class_id" /> <input type="submit" value="Create New Document" /> + </form> +<hr/> + +<div class="std-text"><p><strong>Product Document Classes</strong></p></div> + +<table width="100%"> + <tr class="list-header"> + <th> + Class + </th> + <th> + Path + </th> + <th> + Action + </th> + <dtml-in getProductDocumentPathList> + <tr> + <td> + <div class="list-item"><dtml-var sequence-key></div> + </td> + <td> + <div class="list-item"><dtml-var sequence-item></div> + </td> + <td> + <div class="list-item"><a href="importDocument?class_id=<dtml-var sequence-key>&class_path=<dtml-var sequence-item>">reload</a> + </div> + </td> + </tr> + </dtml-in> +</table> + + <dtml-var manage_page_footer> diff --git a/product/ERP5Type/dtml/viewExtensionList.dtml b/product/ERP5Type/dtml/viewExtensionList.dtml index fbaf851e748767f1c723f4acb5def2c6dfd64ad1..413cb2c7bd51cbb4852a46af6d0ab513b5b1146e 100755 --- a/product/ERP5Type/dtml/viewExtensionList.dtml +++ b/product/ERP5Type/dtml/viewExtensionList.dtml @@ -1,6 +1,32 @@ <dtml-var manage_page_header> <dtml-var manage_tabs> -<p>Explain SumulationTool</p> +<div class="std-text"><p><strong>Local Extension Classes</strong></p></div> + +<form method="POST" action="newExtension"> +<table width="100%"> + <tr class="list-header"> + <th> + Class + </th> + <th> + Actions + </th> + <dtml-in getLocalExtensionList> + <tr> + <td> + <div class="list-item"><dtml-var sequence-item></div> + </td> + <td> + <div class="list-item"><a href="manage_editExtensionForm?class_id=<dtml-var sequence-item>">edit</a> + </div> + </td> + </tr> + </dtml-in> +</table> + +<input type="text" name="class_id" /> <input type="submit" value="Create New Extension" /> + +</form> <dtml-var manage_page_footer> diff --git a/product/ERP5Type/dtml/viewPropertySheetList.dtml b/product/ERP5Type/dtml/viewPropertySheetList.dtml index fbaf851e748767f1c723f4acb5def2c6dfd64ad1..526b721014db88e554833803ae449fce34deedee 100755 --- a/product/ERP5Type/dtml/viewPropertySheetList.dtml +++ b/product/ERP5Type/dtml/viewPropertySheetList.dtml @@ -1,6 +1,32 @@ <dtml-var manage_page_header> <dtml-var manage_tabs> -<p>Explain SumulationTool</p> +<div class="std-text"><p><strong>Local Property Sheet Classes</strong></p></div> + +<form method="POST" action="newPropertySheet"> +<table width="100%"> + <tr class="list-header"> + <th> + Class + </th> + <th> + Actions + </th> + <dtml-in getLocalPropertySheetList> + <tr> + <td> + <div class="list-item"><dtml-var sequence-item></div> + </td> + <td> + <div class="list-item"><a href="manage_editPropertySheetForm?class_id=<dtml-var sequence-item>">edit</a> + </div> + </td> + </tr> + </dtml-in> +</table> + +<input type="text" name="class_id" /> <input type="submit" value="Create New Property Sheet" /> + +</form> <dtml-var manage_page_footer>