Commit 029367bd authored by Aurel's avatar Aurel

make edition in portal classes more configurable by adding

"Taller/Shorter/Wider/Narrower" buttons as it is in the rest of zope


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@37202 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e0fbf3c5
......@@ -383,6 +383,29 @@ if allowClassTool():
LOG('_clearCache', 0, str(name))
database[name].manage_minimize()
def _changeEditingPreferences(self, REQUEST, height=None, width=None,
dtpref_cols="100%", dtpref_rows="20"):
"""Change editing preferences."""
dr = {"Taller":5, "Shorter":-5}.get(height, 0)
dc = {"Wider":5, "Narrower":-5}.get(width, 0)
if isinstance(height, int): dtpref_rows = height
if isinstance(width, int) or \
isinstance(width, str) and width.endswith('%'):
dtpref_cols = width
rows = str(max(1, int(dtpref_rows) + dr))
cols = str(dtpref_cols)
if cols.endswith('%'):
cols = str(min(100, max(25, int(cols[:-1]) + dc))) + '%'
else:
cols = str(max(35, int(cols) + dc))
e = (DateTime("GMT") + 365).rfc822()
setCookie = REQUEST["RESPONSE"].setCookie
setCookie("dtpref_rows", rows, path='/', expires=e)
setCookie("dtpref_cols", cols, path='/', expires=e)
REQUEST.other.update({"dtpref_cols":cols, "dtpref_rows":rows})
security.declareProtected( Permissions.ManagePortal, 'getLocalPropertySheetList' )
def getLocalPropertySheetList(self):
"""
......@@ -495,7 +518,14 @@ class %s(XMLObject):
Updates a Document with a new text
"""
previous_text = readLocalDocument(class_id)
try:
self.writeLocalDocument(class_id, text, create=0)
except SyntaxError, msg:
if REQUEST is not None:
REQUEST.RESPONSE.redirect('%s/manage_editDocumentForm?class_id=%s&errors=%s' % (self.absolute_url(), class_id, msg))
return
else:
return msg
if REQUEST is not None:
REQUEST.RESPONSE.redirect('%s/manage_editDocumentForm?class_id=%s&manage_tabs_message=Document+Saved' % (self.absolute_url(), class_id))
......@@ -516,6 +546,31 @@ class %s(XMLObject):
if REQUEST is not None and class_path is None:
REQUEST.RESPONSE.redirect('%s/manage_editDocumentForm?class_id=%s&manage_tabs_message=Document+Reloaded+Successfully' % (self.absolute_url(), class_id))
security.declareProtected( Permissions.ManageExtensions, 'editAndImportDocument' )
def editAndImportDocument(self, class_id, text, REQUEST=None):
"""
Edit & Import a document class
"""
errors = self.editDocument(class_id, text)
if errors is not None:
if REQUEST is not None:
REQUEST.RESPONSE.redirect('%s/manage_editDocumentForm?class_id=%s&errors=%s' % (self.absolute_url(), class_id, errors))
return
else:
return errors
self.importDocument(class_id)
if REQUEST is not None:
REQUEST.RESPONSE.redirect('%s/manage_editDocumentForm?class_id=%s&manage_tabs_message=Document+Save+And+Reloaded+Successfully' % (self.absolute_url(), class_id))
def changeDocumentEditingPreferences(self, REQUEST, class_id, height=None, width=None,
dtpref_cols="100%", dtpref_rows="20"):
"""Change editing preferences for documents."""
self._changeEditingPreferences(REQUEST, height=height, width=width,
dtpref_cols=dtpref_cols, dtpref_rows=dtpref_rows)
REQUEST.RESPONSE.redirect('%s/manage_editDocumentForm?class_id=%s' % (self.absolute_url(),
class_id))
security.declareProtected( Permissions.ManagePortal, 'getPropertySheetText' )
def getPropertySheetText(self, class_id):
......@@ -601,6 +656,14 @@ class %s:
if REQUEST is not None:
REQUEST.RESPONSE.redirect('%s/manage_editPropertySheetForm?class_id=%s&manage_tabs_message=PropertySheet+Reloaded+Successfully' % (self.absolute_url(), class_id))
def changePropertySheetEditingPreferences(self, REQUEST, class_id, height=None, width=None,
dtpref_cols="100%", dtpref_rows="20"):
"""Change editing preferences for property sheet."""
self._changeEditingPreferences(REQUEST, height=height, width=width,
dtpref_cols=dtpref_cols, dtpref_rows=dtpref_rows)
REQUEST.RESPONSE.redirect('%s/manage_editPropertySheetForm?class_id=%s' % (self.absolute_url(),
class_id))
security.declareProtected( Permissions.ManagePortal, 'getExtensionText' )
def getExtensionText(self, class_id):
"""
......@@ -658,6 +721,15 @@ def myExtensionMethod(self, param=None):
if REQUEST is not None:
REQUEST.RESPONSE.redirect('%s/manage_editExtensionForm?class_id=%s&manage_tabs_message=Extension+Saved' % (self.absolute_url(), class_id))
def changeExtensionEditingPreferences(self, REQUEST, class_id, height=None, width=None,
dtpref_cols="100%", dtpref_rows="20"):
"""Change editing preferences for extensions."""
self._changeEditingPreferences(REQUEST, height=height, width=width,
dtpref_cols=dtpref_cols, dtpref_rows=dtpref_rows)
REQUEST.RESPONSE.redirect('%s/manage_editExtensionForm?class_id=%s' % (self.absolute_url(),
class_id))
security.declareProtected( Permissions.ManagePortal, 'getTestText' )
def getTestText(self, class_id):
"""
......@@ -748,6 +820,15 @@ class Test(ERP5TypeTestCase):
if REQUEST is not None:
REQUEST.RESPONSE.redirect('%s/manage_editTestForm?class_id=%s&manage_tabs_message=Test+Saved' % (self.absolute_url(), class_id))
def changeTestEditingPreferences(self, REQUEST, class_id, height=None, width=None,
dtpref_cols="100%", dtpref_rows="20"):
"""Change editing preferences for test."""
self._changeEditingPreferences(REQUEST, height=height, width=width,
dtpref_cols=dtpref_cols, dtpref_rows=dtpref_rows)
REQUEST.RESPONSE.redirect('%s/manage_editTestForm?class_id=%s' % (self.absolute_url(),
class_id))
security.declareProtected( Permissions.ManagePortal, 'getConstraintText' )
def getConstraintText(self, class_id):
"""
......@@ -842,6 +923,15 @@ class %s(Constraint):
if REQUEST is not None:
REQUEST.RESPONSE.redirect('%s/manage_editConstraintForm?class_id=%s&manage_tabs_message=Constraint+Reloaded+Successfully' % (self.absolute_url(), class_id))
def changeConstraintEditingPreferences(self, REQUEST, class_id, height=None, width=None,
dtpref_cols="100%", dtpref_rows="20"):
"""Change editing preferences for constraint."""
self._changeEditingPreferences(REQUEST, height=height, width=width,
dtpref_cols=dtpref_cols, dtpref_rows=dtpref_rows)
REQUEST.RESPONSE.redirect('%s/manage_editConstraintForm?class_id=%s' % (self.absolute_url(),
class_id))
security.declareProtected( Permissions.ManageExtensions, 'generateProduct' )
def generateProduct(self, product_id,
document_id_list=(), property_sheet_id_list=(), constraint_id_list=(),
......
......@@ -3,11 +3,51 @@
<h2>Edit Constraint Class: <dtml-var class_id></h2>
<form method="POST" action="<dtml-var absolute_url>">
<textarea name="text:text" rows="20" cols="82"><dtml-var "getConstraintText(class_id)"></textarea>
<br>
<input type="hidden" name="class_id:string" value="<dtml-var class_id>">
<input type="submit" value="Save" name="editConstraint:method">
<input type="submit" value="Reload" name="importConstraint:method">
<input type="hidden" name=":default_method" value="changeConstraintEditingPreferences">
<table width="100%" cellspacing="0" cellpadding="2" border="0">
<dtml-if errors>
<tr>
<td align="left" valign="middle" class="form-label">Errors</td>
<td align="left" valign="middle" style="background-color: #FFDDDD">
<pre><dtml-var expr="str(errors)" html_quote></pre>
</td>
</tr>
</dtml-if>
<dtml-with keyword_args mapping>
<tr>
<td align="left" valign="top" colspan="2">
<div style="width: 100%;">
<dtml-let cols="REQUEST.get('dtpref_cols', '100%')"
rows="REQUEST.get('dtpref_rows', '20')">
<dtml-if "cols[-1]=='%'">
<textarea name="text:text" wrap="off" style="width: &dtml-cols;;"
<dtml-else>
<textarea name="text:text" wrap="off" cols="&dtml-cols;"
</dtml-if>
rows="&dtml-rows;"><dtml-var "getConstraintText(class_id)"></textarea>
</dtml-let>
</div>
</td>
</tr>
</dtml-with>
<tr>
<td>
<div class="form-element">
<input class="form-element" type="hidden" name="class_id:string" value="<dtml-var class_id>">
<input class="form-element" type="submit" value="Save" name="editConstraint:method">
<input class="form-element" type="submit" value="Reload" name="importConstraint:method">
&nbsp;&nbsp;
<input class="form-element" type="submit" name="height" value="Taller">
<input class="form-element" type="submit" name="height" value="Shorter">
<input class="form-element" type="submit" name="width" value="Wider">
<input class="form-element" type="submit" name="width" value="Narrower">
</div>
</td>
</tr>
</table>
</form>
<dtml-var manage_page_footer>
......@@ -3,11 +3,53 @@
<h2>Edit Document Class: <dtml-var class_id></h2>
<form method="POST" action="<dtml-var absolute_url>">
<textarea name="text:text" rows="20" cols="82"><dtml-var "getDocumentText(class_id)"></textarea>
<br>
<input type="hidden" name="class_id:string" value="<dtml-var class_id>">
<input type="submit" value="Save" name="editDocument:method">
<input type="submit" value="Reload" name="importDocument:method">
<input type="hidden" name=":default_method" value="changeDocumentEditingPreferences">
<table width="100%" cellspacing="0" cellpadding="2" border="0">
<dtml-if errors>
<tr>
<td align="left" valign="middle" class="form-label">Errors</td>
<td align="left" valign="middle" style="background-color: #FFDDDD">
<pre><dtml-var expr="str(errors)" html_quote></pre>
</td>
</tr>
</dtml-if>
<dtml-with keyword_args mapping>
<tr>
<td align="left" valign="top" colspan="2">
<div style="width: 100%;">
<dtml-let cols="REQUEST.get('dtpref_cols', '100%')"
rows="REQUEST.get('dtpref_rows', '20')">
<dtml-if "cols[-1]=='%'">
<textarea name="text:text" wrap="off" style="width: &dtml-cols;;"
<dtml-else>
<textarea name="text:text" wrap="off" cols="&dtml-cols;"
</dtml-if>
rows="&dtml-rows;"><dtml-var "getDocumentText(class_id)"></textarea>
</dtml-let>
</div>
</td>
</tr>
</dtml-with>
<tr>
<td>
<div class="form-element">
<input class="form-element" type="hidden" name="class_id:string" value="<dtml-var class_id>">
<input class="form-element" type="submit" value="Save" name="editDocument:method">
<input class="form-element" type="submit" value="Reload" name="importDocument:method">
<input class="form-element" type="submit" value="Save & Reload" name="editAndImportDocument:method">
&nbsp;&nbsp;
<input class="form-element" type="submit" name="height" value="Taller">
<input class="form-element" type="submit" name="height" value="Shorter">
<input class="form-element" type="submit" name="width" value="Wider">
<input class="form-element" type="submit" name="width"
value="Narrower">
</div>
</td>
</tr>
</table>
</form>
<dtml-var manage_page_footer>
......@@ -3,10 +3,52 @@
<h2>Edit Extension Class: <dtml-var class_id></h2>
<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">
<input type="hidden" name=":default_method" value="changeExtensionEditingPreferences">
<table width="100%" cellspacing="0" cellpadding="2" border="0">
<dtml-if errors>
<tr>
<td align="left" valign="middle" class="form-label">Errors</td>
<td align="left" valign="middle" style="background-color: #FFDDDD">
<pre><dtml-var expr="str(errors)" html_quote></pre>
</td>
</tr>
</dtml-if>
<dtml-with keyword_args mapping>
<tr>
<td align="left" valign="top" colspan="2">
<div style="width: 100%;">
<dtml-let cols="REQUEST.get('dtpref_cols', '100%')"
rows="REQUEST.get('dtpref_rows', '20')">
<dtml-if "cols[-1]=='%'">
<textarea name="text:text" wrap="off" style="width: &dtml-cols;;"
<dtml-else>
<textarea name="text:text" wrap="off" cols="&dtml-cols;"
</dtml-if>
rows="&dtml-rows;"><dtml-var "getExtensionText(class_id)"></textarea>
</dtml-let>
</div>
</td>
</tr>
</dtml-with>
<tr>
<td>
<div class="form-element">
<input class="form-element" type="hidden" name="class_id:string" value="<dtml-var class_id>">
<input class="form-element" type="submit" value="Save" name="editExtension:method">
&nbsp;&nbsp;
<input class="form-element" type="submit" name="height" value="Taller">
<input class="form-element" type="submit" name="height" value="Shorter">
<input class="form-element" type="submit" name="width" value="Wider">
<input class="form-element" type="submit" name="width"
value="Narrower">
</div>
</td>
</tr>
</table>
</form>
<dtml-var manage_page_footer>
......@@ -3,11 +3,51 @@
<h2>Edit Property Sheet Class: <dtml-var class_id></h2>
<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">
<input type="hidden" name=":default_method" value="changePropertySheetEditingPreferences">
<table width="100%" cellspacing="0" cellpadding="2" border="0">
<dtml-if errors>
<tr>
<td align="left" valign="middle" class="form-label">Errors</td>
<td align="left" valign="middle" style="background-color: #FFDDDD">
<pre><dtml-var expr="str(errors)" html_quote></pre>
</td>
</tr>
</dtml-if>
<dtml-with keyword_args mapping>
<tr>
<td align="left" valign="top" colspan="2">
<div style="width: 100%;">
<dtml-let cols="REQUEST.get('dtpref_cols', '100%')"
rows="REQUEST.get('dtpref_rows', '20')">
<dtml-if "cols[-1]=='%'">
<textarea name="text:text" wrap="off" style="width: &dtml-cols;;"
<dtml-else>
<textarea name="text:text" wrap="off" cols="&dtml-cols;"
</dtml-if>
rows="&dtml-rows;"><dtml-var "getPropertySheetText(class_id)"></textarea>
</dtml-let>
</div>
</td>
</tr>
</dtml-with>
<tr>
<td>
<div class="form-element">
<input class="form-element" type="hidden" name="class_id:string" value="<dtml-var class_id>">
<input class="form-element" type="submit" value="Save" name="editPropertySheet:method">
<input class="form-element" type="submit" value="Reload" name="importPropertySheet:method">
&nbsp;&nbsp;
<input class="form-element" type="submit" name="height" value="Taller">
<input class="form-element" type="submit" name="height" value="Shorter">
<input class="form-element" type="submit" name="width" value="Wider">
<input class="form-element" type="submit" name="width" value="Narrower">
</div>
</td>
</tr>
</table>
</form>
<dtml-var manage_page_footer>
......@@ -3,10 +3,50 @@
<h2>Edit Test Class: <dtml-var class_id></h2>
<form method="POST" action="<dtml-var absolute_url>">
<textarea name="text:text" rows="20" cols="82"><dtml-var "getTestText(class_id)"></textarea>
<br>
<input type="hidden" name="class_id:string" value="<dtml-var class_id>">
<input type="submit" value="Save" name="editTest:method">
<input type="hidden" name=":default_method" value="changeTestEditingPreferences">
<table width="100%" cellspacing="0" cellpadding="2" border="0">
<dtml-if errors>
<tr>
<td align="left" valign="middle" class="form-label">Errors</td>
<td align="left" valign="middle" style="background-color: #FFDDDD">
<pre><dtml-var expr="str(errors)" html_quote></pre>
</td>
</tr>
</dtml-if>
<dtml-with keyword_args mapping>
<tr>
<td align="left" valign="top" colspan="2">
<div style="width: 100%;">
<dtml-let cols="REQUEST.get('dtpref_cols', '100%')"
rows="REQUEST.get('dtpref_rows', '20')">
<dtml-if "cols[-1]=='%'">
<textarea name="text:text" wrap="off" style="width: &dtml-cols;;"
<dtml-else>
<textarea name="text:text" wrap="off" cols="&dtml-cols;"
</dtml-if>
rows="&dtml-rows;"><dtml-var "getTestText(class_id)"></textarea>
</dtml-let>
</div>
</td>
</tr>
</dtml-with>
<tr>
<td>
<div class="form-element">
<input class="form-element" type="hidden" name="class_id:string" value="<dtml-var class_id>">
<input class="form-element" type="submit" value="Save" name="editTest:method">
&nbsp;&nbsp;
<input class="form-element" type="submit" name="height" value="Taller">
<input class="form-element" type="submit" name="height" value="Shorter">
<input class="form-element" type="submit" name="width" value="Wider">
<input class="form-element" type="submit" name="width" value="Narrower">
</div>
</td>
</tr>
</table>
</form>
<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