[gen] Pod field: allow to upload a replacement file for a frozen pod document.
This commit is contained in:
parent
d0749cc365
commit
e969bbf362
12 changed files with 158 additions and 79 deletions
|
@ -113,31 +113,7 @@ class ToolMixin(BaseMixin):
|
|||
rq = self.REQUEST
|
||||
# Get the object that is the target of this action.
|
||||
obj = self.getObject(rq.get('objectUid'), appy=True)
|
||||
fieldName = rq.get('fieldName')
|
||||
# What is the action to perform?
|
||||
action = rq.get('action', 'generate')
|
||||
if action == 'generate':
|
||||
# Generate a (or get a frozen) document by accessing the value of
|
||||
# the pod field.
|
||||
res = getattr(obj, fieldName)
|
||||
if isinstance(res, basestring):
|
||||
# An error has occurred, and p_res contains the error message
|
||||
obj.say(res)
|
||||
return self.goto(rq.get('HTTP_REFERER'))
|
||||
# res contains a FileInfo instance.
|
||||
res.writeResponse(rq.RESPONSE)
|
||||
elif action == 'freeze':
|
||||
# (Re-)freeze a document in the database.
|
||||
res = obj.freeze(fieldName, rq.get('template'), rq.get('podFormat'),
|
||||
noSecurity=False, freezeOdtOnError=False)
|
||||
obj.say(obj.translate('action_done'))
|
||||
return self.goto(rq.get('HTTP_REFERER'))
|
||||
elif action == 'unfreeze':
|
||||
# Unfreeze a document in the database.
|
||||
obj.unfreeze(fieldName, rq.get('template'), rq.get('podFormat'),
|
||||
noSecurity=False)
|
||||
obj.say(obj.translate('action_done'))
|
||||
return self.goto(rq.get('HTTP_REFERER'))
|
||||
return obj.getField(rq.get('fieldName')).onUiRequest(obj, rq)
|
||||
|
||||
def getAppName(self):
|
||||
'''Returns the name of the application.'''
|
||||
|
|
|
@ -295,6 +295,10 @@ msgstr ""
|
|||
msgid "uploadField"
|
||||
msgstr ""
|
||||
|
||||
#. Default: "Please upload a file of the same type."
|
||||
msgid "upload_invalid"
|
||||
msgstr ""
|
||||
|
||||
#. Default: "Welcome to this Appy-powered site."
|
||||
msgid "front_page_text"
|
||||
msgstr ""
|
||||
|
|
|
@ -295,6 +295,10 @@ msgstr ""
|
|||
msgid "uploadField"
|
||||
msgstr ""
|
||||
|
||||
#. Default: "Please upload a file of the same type."
|
||||
msgid "upload_invalid"
|
||||
msgstr ""
|
||||
|
||||
#. Default: "Welcome to this Appy-powered site."
|
||||
msgid "front_page_text"
|
||||
msgstr ""
|
||||
|
|
|
@ -295,6 +295,10 @@ msgstr ""
|
|||
msgid "uploadField"
|
||||
msgstr ""
|
||||
|
||||
#. Default: "Please upload a file of the same type."
|
||||
msgid "upload_invalid"
|
||||
msgstr ""
|
||||
|
||||
#. Default: "Welcome to this Appy-powered site."
|
||||
msgid "front_page_text"
|
||||
msgstr ""
|
||||
|
|
|
@ -296,6 +296,10 @@ msgstr "Unfreeze"
|
|||
msgid "uploadField"
|
||||
msgstr "Upload a new file"
|
||||
|
||||
#. Default: "Please upload a file of the same type."
|
||||
msgid "upload_invalid"
|
||||
msgstr "Please upload a file of the same type."
|
||||
|
||||
#. Default: "Welcome to this Appy-powered site."
|
||||
msgid "front_page_text"
|
||||
msgstr "Welcome to this Appy-powered site."
|
||||
|
|
|
@ -295,6 +295,10 @@ msgstr ""
|
|||
msgid "uploadField"
|
||||
msgstr ""
|
||||
|
||||
#. Default: "Please upload a file of the same type."
|
||||
msgid "upload_invalid"
|
||||
msgstr ""
|
||||
|
||||
#. Default: "Welcome to this Appy-powered site."
|
||||
msgid "front_page_text"
|
||||
msgstr ""
|
||||
|
|
|
@ -296,6 +296,10 @@ msgstr "Dégeler"
|
|||
msgid "uploadField"
|
||||
msgstr "Écraser par..."
|
||||
|
||||
#. Default: "Please upload a file of the same type."
|
||||
msgid "upload_invalid"
|
||||
msgstr "Veuillez uploader un fichier du même type."
|
||||
|
||||
#. Default: "Welcome to this Appy-powered site."
|
||||
msgid "front_page_text"
|
||||
msgstr "Bienvenue sur ce site fabriqué avec <a href=\"http://appyframework.org\" target=\"_blank\">Appy</a>"
|
||||
|
|
|
@ -295,6 +295,10 @@ msgstr ""
|
|||
msgid "uploadField"
|
||||
msgstr ""
|
||||
|
||||
#. Default: "Please upload a file of the same type."
|
||||
msgid "upload_invalid"
|
||||
msgstr ""
|
||||
|
||||
#. Default: "Welcome to this Appy-powered site."
|
||||
msgid "front_page_text"
|
||||
msgstr ""
|
||||
|
|
|
@ -295,6 +295,10 @@ msgstr ""
|
|||
msgid "uploadField"
|
||||
msgstr ""
|
||||
|
||||
#. Default: "Please upload a file of the same type."
|
||||
msgid "upload_invalid"
|
||||
msgstr ""
|
||||
|
||||
#. Default: "Welcome to this Appy-powered site."
|
||||
msgid "front_page_text"
|
||||
msgstr ""
|
||||
|
|
|
@ -545,13 +545,14 @@ function freezePod(uid, fieldName, template, podFormat, action) {
|
|||
askConfirm('form', 'podForm', action_confirm);
|
||||
}
|
||||
|
||||
// Function that allows to upload a file for freezing it in a od field.
|
||||
// Function that allows to upload a file for freezing it in a pod field.
|
||||
function uploadPod(uid, fieldName, template, podFormat) {
|
||||
var f = document.getElementById('uploadForm');
|
||||
f.objectUid.value = uid;
|
||||
f.fieldName.value = fieldName;
|
||||
f.template.value = template;
|
||||
f.podFormat.value = podFormat;
|
||||
f.uploadedFile.value = null;
|
||||
openPopup('uploadPopup');
|
||||
}
|
||||
|
||||
|
|
|
@ -126,11 +126,12 @@ class AbstractWrapper(object):
|
|||
<!-- Popup for uploading a file in a pod field -->
|
||||
<div id="uploadPopup" class="popup" align="center">
|
||||
<form id="uploadForm" name="uploadForm" enctype="multipart/form-data"
|
||||
method="post" action=":ztool.absolute_url() + '/uploadPod'">
|
||||
method="post" action=":ztool.absolute_url() + '/doPod'">
|
||||
<input type="hidden" name="objectUid"/>
|
||||
<input type="hidden" name="fieldName"/>
|
||||
<input type="hidden" name="template"/>
|
||||
<input type="hidden" name="podFormat"/>
|
||||
<input type="hidden" name="action" value="upload"/>
|
||||
<input type="file" name="uploadedFile"/><br/><br/>
|
||||
<input type="submit" value=":_('object_save')"/>
|
||||
<input type="button" onclick="closePopup('uploadPopup')"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue