Skip to content

Commit

Permalink
refactored python_script templates for bootstrap zmi
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr. Frank Hoffmann authored and Dr. Frank Hoffmann committed Jun 29, 2018
1 parent 890ca6c commit f9addd5
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 137 deletions.
4 changes: 2 additions & 2 deletions src/Products/PythonScripts/PythonScript.py
Expand Up @@ -92,7 +92,7 @@ def manage_addPythonScript(self, id, REQUEST=None, submit=None):
u = self.DestinationURL()
except Exception:
u = REQUEST['URL1']
if submit == " Add and Edit ":
if submit == "Add and Edit":
u = "%s/%s" % (u, quote(id))
REQUEST.RESPONSE.redirect(u + '/manage_main')
return ''
Expand All @@ -106,7 +106,7 @@ class PythonScript(Script, Historical, Cacheable):
"""

meta_type = 'Script (Python)'
zmi_icon = 'fab fa-python'
zmi_icon = 'fa fa-terminal'
_proxy_roles = ()

_params = _body = ''
Expand Down
60 changes: 33 additions & 27 deletions src/Products/PythonScripts/www/pyScriptAdd.dtml
@@ -1,32 +1,38 @@
<dtml-var manage_page_header>

<main>

<dtml-var "manage_form_title(this(), _,
form_title='Add Python Script',
)">
<p class="form-help">
Python Scripts allow you to add functionality to Zope by writing
scripts in the Python programming language
that are exposed as callable Zope objects. You may choose to upload
the script from a local file by typing the file name or using the
<em>browse</em> button.
</p>

<form action="manage_addPythonScript" method="post"
enctype="multipart/form-data" class="zmi-add zmi-script zmi-python">
<div class="form-group row">
<label for="id" class="form-label col-sm-2">Id</label>
<input id="id" class="form-control col-sm-9 col-md-6" type="text" name="id" size="40" />
</div>
<div class="form-group row">
<label for="file-data" class="form-label col-sm-2">File</label>
<input id="file-data" class="form-control-file col-sm-9 col-md-6" type="file" name="file" size="25" value="" />
</div>
<div class="controls">
<input class="btn btn-primary" type="submit" name="submit" value=" Add " />
<input class="btn btn-primary" type="submit" name="submit" value=" Add and Edit " />
</div>
<main class="container-fluid">

<dtml-var "manage_form_title(this(), _, form_title='Add Python Script', )">

<p class="form-help">
Python Scripts allow you to add functionality to Zope by writing
scripts in the Python programming language that are exposed as callable
Zope objects. You may choose to upload the script from a local file by
typing the file name or using the <em>browse</em> button.
</p>

<form action="manage_addPythonScript" method="post" enctype="multipart/form-data"
class="zmi-add zmi-pythonscript">

<div class="form-group row">
<label for="id" class="form-label col-sm-3 col-md-2">Id</label>
<div class="col-sm-9 col-md-10">
<input id="id" class="form-control" type="text" name="id" />
</div>
</div>

<div class="form-group row">
<label for="file-data" class="form-label col-sm-3 col-md-2">File</label>
<div class="col-sm-9 col-md-10">
<input id="file-data" class="form-control form-control-file" type="file" name="file" value="" />
</div>
</div>

<div class="zmi-controls">
<input class="btn btn-primary" type="submit" name="submit" value="Add" />
<input class="btn btn-primary" type="submit" name="submit" value="Add and Edit" />
</div>

</form>

</main>
Expand Down
153 changes: 75 additions & 78 deletions src/Products/PythonScripts/www/pyScriptEdit.dtml
@@ -1,91 +1,88 @@
<dtml-var manage_page_header>
<dtml-var manage_tabs>
<main>

<form action="&dtml-URL1;" method="post" class="zmi-edit zmi-script zmi-python">
<dtml-var manage_tabs>

<dtml-with keyword_args mapping>
<div class="form-group row ">
<label for="title" class="form-label col-sm-3 col-md-3">
Title
</label>
<input id="title" class="form-control col-sm-9 col-md-6" type="text" name="title" size="40"
value="&dtml-title;" />
</div>
<div class="form-group row ">
<label for="params" class="form-label col-sm-3 col-md-3">
Parameter List
</label>
<input id="params" class="form-control col-sm-9 col-md-6" type="text" name="params" size="40"
value="&dtml-params;" />
</div>
</dtml-with>
<dtml-with getBindingAssignments>
<dtml-if getAssignedNamesInOrder>
<div class="form-group row ">
<label for="bound" class="form-label col-sm-3 col-md-3">
Bound Names
</label>
<div id="bound" class="form-text col-sm-9 col-md-6">
<dtml-in getAssignedNamesInOrder>
&dtml-sequence-item;<dtml-unless sequence-end>, </dtml-unless>
</dtml-in>
</div>
</div>
</dtml-if>
</dtml-with>
<main class="container-fluid">

<dtml-if errors>
<div class="alert alert-danger" role="alert">
<pre><dtml-var expr="'\n'.join(errors)" html_quote></pre>
</div>
</dtml-if>
<form action="&dtml-URL1;" method="post" class="zmi-edit zmi-pythonscript">

<dtml-if warnings>
<div class="alert alert-warning" role="alert">
<pre><dtml-var expr="'\n'.join(warnings)" html_quote></pre>
</div>
</dtml-if>
<dtml-with keyword_args mapping>
<div class="form-group row ">
<label for="title" class="form-label col-sm-3 col-md-2">Title</label>
<div class="col-sm-9 col-md-10">
<input id="title" class="form-control" type="text" name="title" value="&dtml-title;" />
</div>
</div>
<div class="form-group row ">
<label for="params" class="form-label col-sm-3 col-md-2">Parameter List</label>
<div class="col-sm-9 col-md-10">
<input id="params" class="form-control" type="text" name="params" value="&dtml-params;" />
</div>
</div>
</dtml-with>

<dtml-with getBindingAssignments>
<dtml-if getAssignedNamesInOrder>
<div class="form-group row ">
<label for="bound" class="form-label col-sm-3 col-md-2">Bound Names</label>
<div id="bound" class="col-sm-9 col-md-10">
<p class="form-control alert-secondary code"><dtml-in getAssignedNamesInOrder>&dtml-sequence-item;<dtml-unless sequence-end>, </dtml-unless></dtml-in>
</div>
</div>
</dtml-if>
</dtml-with>

<dtml-if errors>
<div class="alert alert-danger" role="alert">
<pre><dtml-var expr="'\n'.join(errors)" html_quote></pre>
</div>
</dtml-if>
<dtml-if warnings>
<div class="alert alert-warning" role="alert">
<pre><dtml-var expr="'\n'.join(warnings)" html_quote></pre>
</div>
</dtml-if>

<dtml-with keyword_args mapping>
<textarea id="content" class="form-control zmi-zpt zmi-code col-sm-12"
name="body:text" wrap="off" rows="20">&dtml-body;</textarea>
</dtml-with>

<dtml-with keyword_args mapping>
<textarea id="content" class="form-control zmi-zpt zmi-code col-sm-12"
name="body:text" wrap="off" rows="20">
&dtml-body;
</textarea>
</dtml-with>
<div class="zmi-controls">
<dtml-if wl_isLocked>
<input class="btn btn-primary disabled" type="submit" name="submit" value="Save Changes" disabled="disabled" />
<span class="badge badge-warning" title="This item has been locked by WebDAV"><i class="fa fa-lock"></i></span>
<dtml-else>
<input class="btn btn-primary" type="submit" name="ZPythonScriptHTML_editAction:method" value="Save Changes" />
</dtml-if>
</div>

<div class="controls mt-2">
<dtml-if wl_isLocked>
<em>Locked</em>
<dtml-else>
<input class="btn btn-primary" type="submit"
name="ZPythonScriptHTML_editAction:method" value="Save Changes">
</dtml-if>
</div>
</form>

<p class="form-help">
You may upload the source for &dtml-title_and_id; using the form below.
Choose an existing file from your local computer by clicking <em>browse</em>
The contents of the file should be a valid script with an optional
&quot;##data&quot; block at the start. You may click the following link
to <a href="document_src">view or download</a> the current source.
</p>

<form action="ZPythonScriptHTML_upload" method="post"
enctype="multipart/form-data" class="zmi-upload">
<div class="form-group row">
<label for="file-data" class="col-sm-3 col-md-2">File</label>
<input id="file-data" class="form-control-file col-sm-9 col-md-6" type="file" name="file" size="25" value="">
</div>
<div class="controls">
<dtml-if wl_isLocked>
<em>Locked</em>
<dtml-else>
<input class="btn btn-primary" type="submit" value="Upload File">
</dtml-if>
</div>
</form>
<dtml-unless wl_isLocked>
<form action="ZPythonScriptHTML_upload" method="post" enctype="multipart/form-data" class="zmi-upload mt-4">

<p class="form-help">
You may upload the source for &dtml-title_and_id; using the form below.
Choose an existing file from your local computer by clicking <em>browse</em>
The contents of the file should be a valid script with an optional
&quot;##data&quot; block at the start. You may click the following link
to <a href="document_src">view or download</a> the current source.
</p>

<div class="input-group" title="Select Local File for Uploading">
<div class="custom-file">
<input type="file" name="file" class="custom-file-input" id="file-data" value=""
onchange="$('.custom-file label span').html($(this).val().replace(/^.*(\\|\/|\:)/, ''));" />
<label class="custom-file-label" for="file-data"><span>Choose file</span></label>
</div>
<div class="input-group-append">
<input class="btn btn-outline-secondary" type="submit" value="Upload File" />
</div>
</div>
</form>
</dtml-unless>

</main>

Expand Down
64 changes: 34 additions & 30 deletions src/Products/PythonScripts/www/pyScriptProxy.dtml
@@ -1,34 +1,38 @@
<dtml-var manage_page_header>

<dtml-var manage_tabs>
<main>

<p class="form-help">
Proxy roles allow you to control the access that a script has. Proxy roles
replace the roles of the user who is executing the script. This can be used
to both expand and limit access to resources. Select the proxy roles for
this object from the list below.
</p>

<form action="manage_proxy" method="post" class="zmi-proxy">
<div class="form-group row">
<label for="roles" class="form-label col-sm-3 col-md-2">
Proxy Roles
</label>
<select id="roles" class="form-control col-sm-9 col-md-6" name="roles:list" size="7" multiple>
<dtml-in valid_roles>
<dtml-if expr="_vars['sequence-item'] != 'Shared'">
<option <dtml-if
expr="manage_haveProxy(_vars['sequence-item'])">selected</dtml-if
>>&dtml-sequence-item;</option>
</dtml-if>
</dtml-in valid_roles>
</select>
</div>

<div class="controls">
<input class="btn btn-primary" type="submit" name="SUBMIT" value="Save Changes">
</div>

</form>

<main class="container-fluid">

<p class="form-help">
Proxy roles allow you to control the access that a script has. Proxy roles
replace the roles of the user who is executing the script. This can be used
to both expand and limit access to resources. Select the proxy roles for
this object from the list below.
</p>

<form action="manage_proxy" method="post" class="zmi-proxy">
<div class="form-group row">
<label for="roles" class="form-label col-sm-3 col-md-2">Proxy Roles</label>
<div class="col-sm-9 col-md-10">
<select id="roles" class="form-control" name="roles:list" size="7" multiple>
<dtml-in valid_roles>
<dtml-if expr="_vars['sequence-item'] != 'Shared'">
<option
<dtml-if expr="manage_haveProxy(_vars['sequence-item'])">selected="selected"</dtml-if>
>&dtml-sequence-item;</option>
</dtml-if>
</dtml-in>
</select>
</div>
</div>

<div class="zmi-controls">
<input class="btn btn-primary" type="submit" name="submit" value="Save Changes" />
</div>

</form>

</main>

<dtml-var manage_page_footer>
Binary file removed src/Products/PythonScripts/www/pyscript.gif
Binary file not shown.

0 comments on commit f9addd5

Please sign in to comment.