Commit 3dfccdfb authored by Jean-Paul Smets's avatar Jean-Paul Smets

Completed ClassTool - now useable - includes specific permission


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@1318 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d1a0f4aa
...@@ -36,6 +36,11 @@ from zLOG import LOG ...@@ -36,6 +36,11 @@ from zLOG import LOG
global product_document_registry global product_document_registry
product_document_registry = [] product_document_registry = []
def getProductDocumentPathList():
result = product_document_registry
result.sort()
return result
def InitializeDocument(document_class, document_path=None): def InitializeDocument(document_class, document_path=None):
global product_document_registry global product_document_registry
# Register class in ERP5Type.Document # Register class in ERP5Type.Document
......
...@@ -134,3 +134,6 @@ setDefaultRoles(TranslateContent, ('Manager', 'Owner', 'Member')) ...@@ -134,3 +134,6 @@ setDefaultRoles(TranslateContent, ('Manager', 'Owner', 'Member'))
#setDefaultRoles(AddERP5Content, ('Manager', )) #setDefaultRoles(AddERP5Content, ('Manager', ))
AddERP5Content = AddPortalContent # Since we put come CPS content in ERP5 documents, there is no rationale in having 2 permissions 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"
...@@ -39,6 +39,7 @@ from Products.ERP5Type.Document.Folder import Folder ...@@ -39,6 +39,7 @@ from Products.ERP5Type.Document.Folder import Folder
from Products.ERP5Type.Utils import readLocalPropertySheet, writeLocalPropertySheet, getLocalPropertySheetList from Products.ERP5Type.Utils import readLocalPropertySheet, writeLocalPropertySheet, getLocalPropertySheetList
from Products.ERP5Type.Utils import readLocalExtension, writeLocalExtension, getLocalExtensionList from Products.ERP5Type.Utils import readLocalExtension, writeLocalExtension, getLocalExtensionList
from Products.ERP5Type.Utils import readLocalDocument, writeLocalDocument, getLocalDocumentList from Products.ERP5Type.Utils import readLocalDocument, writeLocalDocument, getLocalDocumentList
from Products.ERP5Type.InitGenerator import getProductDocumentPathList
class ClassTool(BaseTool): class ClassTool(BaseTool):
""" """
...@@ -85,6 +86,12 @@ class ClassTool(BaseTool): ...@@ -85,6 +86,12 @@ class ClassTool(BaseTool):
security.declareProtected( Permissions.ManagePortal, 'manage_editDocumentForm' ) security.declareProtected( Permissions.ManagePortal, 'manage_editDocumentForm' )
manage_editDocumentForm = DTMLFile( 'editDocumentForm', _dtmldir ) 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' ) security.declareProtected( Permissions.ManagePortal, 'getLocalPropertySheetList' )
def getLocalPropertySheetList(self): def getLocalPropertySheetList(self):
""" """
...@@ -106,6 +113,13 @@ class ClassTool(BaseTool): ...@@ -106,6 +113,13 @@ class ClassTool(BaseTool):
""" """
return getLocalDocumentList() 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' ) security.declareProtected( Permissions.ManagePortal, 'getDocumentText' )
def getDocumentText(self, class_id): def getDocumentText(self, class_id):
""" """
...@@ -113,7 +127,7 @@ class ClassTool(BaseTool): ...@@ -113,7 +127,7 @@ class ClassTool(BaseTool):
""" """
return readLocalDocument(class_id) return readLocalDocument(class_id)
security.declareProtected( Permissions.ManagePortal, 'newDocument' ) security.declareProtected( Permissions.ManageExtensions, 'newDocument' )
def newDocument(self, class_id, REQUEST=None): def newDocument(self, class_id, REQUEST=None):
""" """
Updates a Document with a new text Updates a Document with a new text
...@@ -173,7 +187,7 @@ class %s(XMLObject): ...@@ -173,7 +187,7 @@ class %s(XMLObject):
if REQUEST is not None: if REQUEST is not None:
REQUEST.RESPONSE.redirect('%s/manage_editDocumentForm?class_id=%s&message=Document+Created' % (self.absolute_url(), class_id)) 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): def editDocument(self, class_id, text, REQUEST=None):
""" """
Updates a Document with a new text Updates a Document with a new text
...@@ -183,16 +197,154 @@ class %s(XMLObject): ...@@ -183,16 +197,154 @@ class %s(XMLObject):
if REQUEST is not None: if REQUEST is not None:
REQUEST.RESPONSE.redirect('%s/manage_editDocumentForm?class_id=%s&message=Document+Saved' % (self.absolute_url(), class_id)) REQUEST.RESPONSE.redirect('%s/manage_editDocumentForm?class_id=%s&message=Document+Saved' % (self.absolute_url(), class_id))
security.declareProtected( Permissions.ManagePortal, 'importDocument' ) security.declareProtected( Permissions.ManageExtensions, 'importDocument' )
def importDocument(self, class_id, REQUEST=None): def importDocument(self, class_id, class_path=None, REQUEST=None):
""" """
Imports a document class Imports a document class
""" """
from Products.ERP5Type.Utils import importLocalDocument from Products.ERP5Type.Utils import importLocalDocument
local_product = self.Control_Panel.Products.ERP5Type local_product = self.Control_Panel.Products.ERP5Type
app = local_product._p_jar.root()['Application'] app = local_product._p_jar.root()['Application']
importLocalDocument(class_id) importLocalDocument(class_id, document_path=class_path)
if REQUEST is not None: 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)) 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) InitializeClass(ClassTool)
...@@ -251,6 +251,7 @@ def getLocalPropertySheetList(): ...@@ -251,6 +251,7 @@ def getLocalPropertySheetList():
for fname in file_list: for fname in file_list:
if python_file_parser.match(fname) is not None: if python_file_parser.match(fname) is not None:
result.append(python_file_parser.match(fname).groups()[0]) result.append(python_file_parser.match(fname).groups()[0])
result.sort()
return result return result
def readLocalPropertySheet(class_id): def readLocalPropertySheet(class_id):
...@@ -308,6 +309,7 @@ def getLocalExtensionList(): ...@@ -308,6 +309,7 @@ def getLocalExtensionList():
for fname in file_list: for fname in file_list:
if python_file_parser.match(fname) is not None: if python_file_parser.match(fname) is not None:
result.append(python_file_parser.match(fname).groups()[0]) result.append(python_file_parser.match(fname).groups()[0])
result.sort()
return result return result
def readLocalExtension(class_id): def readLocalExtension(class_id):
...@@ -334,6 +336,7 @@ def getLocalDocumentList(): ...@@ -334,6 +336,7 @@ def getLocalDocumentList():
for fname in file_list: for fname in file_list:
if python_file_parser.match(fname) is not None: if python_file_parser.match(fname) is not None:
result.append(python_file_parser.match(fname).groups()[0]) result.append(python_file_parser.match(fname).groups()[0])
result.sort()
return result return result
def readLocalDocument(class_id): def readLocalDocument(class_id):
......
<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>
<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>
<dtml-var manage_page_header> <dtml-var manage_page_header>
<dtml-var manage_tabs> <dtml-var manage_tabs>
<h1>Document Classes</h1> <div class="std-text"><p><strong>Local Document Classes</strong></p></div>
<ul>
<dtml-in getLocalDocumentList><li><a href="manage_editDocumentForm?class_id=<dtml-var sequence-item>"><dtml-var sequence-item></a></li></dtml-in>
<hr>
<form method="POST" action="newDocument"> <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>&nbsp;<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" /> <input type="text" name="class_id" /> <input type="submit" value="Create New Document" />
</form> </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>&nbsp;
</div>
</td>
</tr>
</dtml-in>
</table>
<dtml-var manage_page_footer> <dtml-var manage_page_footer>
<dtml-var manage_page_header> <dtml-var manage_page_header>
<dtml-var manage_tabs> <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>&nbsp;
</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> <dtml-var manage_page_footer>
<dtml-var manage_page_header> <dtml-var manage_page_header>
<dtml-var manage_tabs> <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>&nbsp;
</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> <dtml-var manage_page_footer>
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