From d0f468d49c5b0fa822310c1cdb9584b47ca36c35 Mon Sep 17 00:00:00 2001 From: "Dr. Frank Hoffmann" Date: Thu, 28 Mar 2019 22:42:48 +0100 Subject: [PATCH] Merged to version 3.4.13 --- README | 12 +- conf/zms3.formulator.langdict.xml | 6 + conf/zms3.formulator.metaobj.xml | 1357 +++++------------------------ setup.py | 10 +- zms3/formulator/JSONEditor.js | 132 ++- zms3/formulator/JSONEditor.py | 2 +- 6 files changed, 296 insertions(+), 1223 deletions(-) diff --git a/README b/README index 0b9f010..9608f88 100644 --- a/README +++ b/README @@ -1,18 +1,18 @@ zms3.formulator =============== -This Python Package is an Extension for the `ZMS3 Publishing System `_ (Open Source Content Management for Science, Technology and Medicine) to integrate the `JSON Editor by Jeremy Dorn `_, Redwood City, CA. +This Python Package is an Extension for the ZMS3 Publishing System (Open Source Content Management for Science, Technology and Medicine) to integrate the `JSON Editor by Jeremy Dorn `_, Redwood City, CA. A JSON Schema is generated based on special content objects and used to transform it into an HTML Form handling all the front-end validations. -The data submitted by the generated HTML Form can be transmitted into a remote `SQL Storage `_ for further processing and evaluation using standard reporting tools - or data will be stored into the included `ZODB `_ and/or sent by mail. +The data submitted by the generated HTML Form can be transmitted into a remote SQL Storage for further processing and evaluation using standard reporting tools - or data will be stored into the included `ZODB `_ and/or sent by mail. -Form submission provides support for the `reCAPTCHA service by Google `_ to protect from spam and abuse. +Form submission provides support for the reCAPTCHA service by Google to protect from spam and abuse. References ---------- - * https://bitbucket.org/zms3/formulator + * https://github.com/zms-publishing/zms3.formulator * https://pypi.python.org/pypi/ZMS3 * https://github.com/jdorn/json-editor * https://developers.google.com/recaptcha/intro @@ -22,6 +22,6 @@ References Changelog --------- - * https://bitbucket.org/zms3/formulator/commits/all + * https://github.com/zms-publishing/zms3.formulator/commits/master -Copyright (c) 2014-2017 `HOFFMANN+LIEBENBERG `_ in association with `SNTL Publishing `_, Berlin. Code released under the `GNU Affero General Public License v3 `_ license. \ No newline at end of file +Copyright (c) 2014-2019 HOFFMANN+LIEBENBERG in association with SNTL Publishing `_, Berlin. Code released under the GNU Affero General Public License v3 license. \ No newline at end of file diff --git a/conf/zms3.formulator.langdict.xml b/conf/zms3.formulator.langdict.xml index 133afb1..b3c4911 100644 --- a/conf/zms3.formulator.langdict.xml +++ b/conf/zms3.formulator.langdict.xml @@ -262,6 +262,12 @@ xmlns:html="http://www.w3.org/TR/REC-html40"> Value is mandatory + +ZMSFORMULATOR_FEEDBACK_MSG +Vielen Dank, die Daten sind bei uns eingegangen. + +Thank you, we have received the data. + \ No newline at end of file diff --git a/conf/zms3.formulator.metaobj.xml b/conf/zms3.formulator.metaobj.xml index 55827c8..d65bdff 100644 --- a/conf/zms3.formulator.metaobj.xml +++ b/conf/zms3.formulator.metaobj.xml @@ -19,6 +19,21 @@ + + + + + + + + + 0 + 1 + Bitte beachten! Legen Sie Formulare, sowie Formularelemente immer zuerst in der Primärsprache an. Falls Sie das Formular nur in der Sekundärsprache verwenden, dann deaktivieren Sie das Objekt in der Primärsprache.]]> + 0 + + + @@ -49,6 +64,17 @@ + + + + + 0 + 1 + Im Feld Feedback haben Sie die Möglichkeit, eine eigene Meldung zu definieren, welche dem Absender nach dem Ausfüllen des Formulars im Browser angezeigt wird. Sie können zum Formatieren der Nachricht HTML-Tags verwenden. Wenn das Feld leer bleibt, wird eine Standardmeldung ausgegeben.]]> + 0 + + + @@ -100,6 +126,16 @@ + + + + 0 + 1 + + 0 + + + @@ -141,7 +177,8 @@ ZMSFormulator.options.required_by_default = true;]]> 0 0 - + +
@@ -170,7 +207,8 @@ ZMSFormulator.options.required_by_default = true;]]> 0 0 - + +
@@ -197,7 +235,9 @@ ZMSFormulator.options.required_by_default = true;]]> 0 0 - + + +
@@ -214,7 +254,8 @@ ZMSFormulator.options.required_by_default = true;]]> 0 0 - + +
See JSON-Editor README for options and usage of custom Schema (JSON).
@@ -249,7 +290,8 @@ ZMSFormulator.options.required_by_default = true;]]> 0 0 - + +
@@ -322,7 +364,8 @@ ZMSFormulator.options.required_by_default = true;]]> 0 0 - + +
Leave blank to use default ZMSAdministrator.email set in System-Properties.
@@ -342,7 +385,7 @@ ZMSFormulator.options.required_by_default = true;]]> 0 -
+
0 0 - + +
data
]]> @@ -432,7 +476,8 @@ button { 0 0 - + + ]]> @@ -606,38 +659,6 @@ $ZMI.registerReady(function() { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -646,38 +667,6 @@ $ZMI.registerReady(function() { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -686,7 +675,7 @@ $ZMI.registerReady(function() { - +
@@ -769,7 +758,8 @@ $ZMI.registerReady(function() { 0 0 - + +
You can use the received value of this ZMSFormulatorItem as default for mail replies on notifications and/or send copies of the submitted data as acknowledgement.
@@ -819,7 +809,8 @@ $ZMI.registerReady(function() { 0 0 - + +
Used as column name in data table – one single word without special characters is recommended.
@@ -905,7 +896,8 @@ $ZMI.registerReady(function() { 0 0 - + +
@@ -922,7 +914,8 @@ $ZMI.registerReady(function() { 0 0 - + + -
- '''%(self.getLangStr('ZMSFORMULATOR_BUTTON_SUBMIT',self.REQUEST.get('lang')), self.getLangStr('ZMSFORMULATOR_BUTTON_RESTORE',self.REQUEST.get('lang')), frmu.GoogleAPIKey, self.getLanguageLabel(self.REQUEST.get('lang'))[:2].lower()) - - if (frmu.feedbackMsg!=''): - feedback = ''' - - '''%(frmu.feedbackMsg.replace('\n','
')) - else: +
+ + + +
+ '''%(self.getLangStr('ZMSFORMULATOR_BUTTON_SUBMIT',self.REQUEST.get('lang')), self.getLangStr('ZMSFORMULATOR_BUTTON_RESTORE',self.REQUEST.get('lang'))) + else: + output = ''' +
+ + + + + + +
+ '''%(frmu.GoogleAPIKey,self.getLangStr('ZMSFORMULATOR_BUTTON_SUBMIT',self.REQUEST.get('lang')),self.getLangStr('ZMSFORMULATOR_BUTTON_RESTORE',self.REQUEST.get('lang'))) + + if (frmu.feedbackMsg!=''): + feedback = ''' + + '''%(frmu.feedbackMsg.replace('\n','
')) + else: feedback = ''' '''%(self.getLangStr('ZMSFORMULATOR_FEEDBACK_MSG',self.REQUEST.get('lang')).replace('\n','
')) - - self.REQUEST.RESPONSE.setHeader('Cache-Control', 'no-cache') - self.REQUEST.RESPONSE.setHeader('Pragma', 'no-cache') - return output + jsed.render(frmu) + feedback]]> + + self.REQUEST.RESPONSE.setHeader('Cache-Control', 'no-cache') + self.REQUEST.RESPONSE.setHeader('Pragma', 'no-cache') + return output + jsed.render(frmu) + feedback +]]> 0 @@ -2262,13 +1341,13 @@ def getJSONEditor(self): - @@ -2309,17 +1388,21 @@ def printData(self): - @@ -2332,17 +1415,17 @@ def putData(self): - 0 and True or False - if not authorized: - raise zExceptions.Unauthorized - else: - frmu = ZMSFormulator.ZMSFormulator(self) + 0 and True or False + if not authorized: + raise zExceptions.Unauthorized + else: + frmu = ZMSFormulator.ZMSFormulator(self) frmu.clearData()]]> @@ -2441,7 +1524,7 @@ def downloadData(self): - + diff --git a/setup.py b/setup.py index 8bf9d84..77fc432 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ ################################################################################ # -# Copyright (c) 2017 HOFFMANN+LIEBENBERG in association with SNTL Publishing +# Copyright (c) 2019 HOFFMANN+LIEBENBERG in association with SNTL Publishing # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by @@ -34,11 +34,11 @@ else: site_packages = get_python_lib() -VERSION = '3.4.11' +VERSION = '3.4.13' zmspkg_name = 'formulator' branch_name = 'master' -downld_file = 'https://bitbucket.org/zms3/%s/get/%s.zip'%(zmspkg_name, branch_name) +downld_file = 'https://github.com/zms-publishing/zms3.%s/archive/%s.zip'%(zmspkg_name, branch_name) if 'dev' in VERSION: import subprocess @@ -104,8 +104,8 @@ version = VERSION, author = 'HOFFMANN+LIEBENBERG in association with SNTL Publishing, Berlin', author_email = 'zms@sntl-publishing.com', - url = 'https://bitbucket.org/zms3/formulator', - download_url = 'https://bitbucket.org/zms3/formulator/downloads', + url = 'https://github.com/zms-publishing/zms3.formulator', + download_url = 'https://github.com/zms-publishing/zms3.formulator/releases', namespace_packages = ['zms3'], packages = ['zms3.formulator'], package_dir = {'zms3.formulator': 'zms3/formulator'}, diff --git a/zms3/formulator/JSONEditor.js b/zms3/formulator/JSONEditor.js index 954550b..5daeec2 100644 --- a/zms3/formulator/JSONEditor.js +++ b/zms3/formulator/JSONEditor.js @@ -1,28 +1,7 @@ -/* - -The MIT License (MIT) - -Copyright (c) 2013 Jeremy Dorn, https://github.com/jdorn/json-editor - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -*/ - +/* ------------------------------------------------*/ +/* Python-String-Template processed by JSONEditor: */ +/* Inline-Initialization of ZMSFormulator */ +/* ------------------------------------------------*/ %s // Initialize the ZMSFormulator @@ -45,13 +24,13 @@ var ZMSFormulator = new JSONEditor(document.getElementById('editor_holder'), { var GoogleAPISitekey = '%s'; if (GoogleAPISitekey != 'no_site_key') { var onloadCallback = function() { - grecaptcha.render('reCAPTCHA', { - 'sitekey' : GoogleAPISitekey, - 'theme' : 'light', - 'callback' : function(response) { - //console.log(response); - } - }); + grecaptcha.render('reCAPTCHA', { + 'sitekey' : GoogleAPISitekey, + 'theme' : 'light', + 'callback' : function(response) { + //console.log(response); + } + }); }; } @@ -66,13 +45,13 @@ ZMSFormulator.on('ready',function() { // by storing filename at hidden field to keep it for storing/sending // and check filesize by custom validator - see lines 175 + 206 $("div[data-schemapath$='FILEDATA']").find("input[type='file']").change(function() { - var filename = $(this).val(); - var lastIndex = filename.lastIndexOf("\\"); - if (lastIndex >= 0) { - filename = filename.substring(lastIndex + 1); - } - filenamefield = $("div[data-schemapath$='FILENAME']").attr('data-schemapath'); - ZMSFormulator.getEditor(filenamefield).setValue(filename); + var filename = $(this).val(); + var lastIndex = filename.lastIndexOf("\\"); + if (lastIndex >= 0) { + filename = filename.substring(lastIndex + 1); + } + filenamefield = $("div[data-schemapath$='FILENAME']").attr('data-schemapath'); + ZMSFormulator.getEditor(filenamefield).setValue(filename); }); // Remove label and input for ZMSTextareas inserted between ZMSFormulatorItems @@ -92,28 +71,28 @@ ZMSFormulator.on('ready',function() { // Custom validators must return an array of errors or an empty array if valid // Errors must be an object with `path`, `property`, and `message` JSONEditor.defaults.custom_validators.push(function(schema, value, path) { - var errors = []; - if(schema.format==="email") { - if((value!='') && (!/^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(value))) { - errors.push({ - path: path, - property: 'format', - message: JSONEditor.defaults.translate('hint_emailsyntax') - }); - } - } - if(schema.format==="mailattachment") { + var errors = []; + if(schema.format==="email") { + if((value!='') && (!/^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(value))) { + errors.push({ + path: path, + property: 'format', + message: JSONEditor.defaults.translate('hint_emailsyntax') + }); + } + } + if(schema.format==="mailattachment") { bytes = Math.floor((value.length-value.split(',')[0].length-1)/1.33333); if(bytes > 3*1024*1024) { - errors.push({ - path: path, - property: 'format', - message: 'hint_emailtoolarge' - }); + errors.push({ + path: path, + property: 'format', + message: 'hint_emailtoolarge' + }); + } } - } - %s - return errors; + %s + return errors; }); // Custom onReady JavaScript @@ -125,7 +104,11 @@ document.getElementById('submit').addEventListener('click', function() { var errors = ZMSFormulator.validate(); - if (!errors.length) { + var indicator = document.getElementById('valid_indicator'); + var submit = document.getElementById('submit'); + + // Valid + if (errors.length===0) { // Get the value from the ZMSFormulator var data = ZMSFormulator.getValue(); @@ -173,8 +156,22 @@ document.getElementById('submit').addEventListener('click', function() { } }); } + // Not valid else { - + //submit.disabled = true; + indicator.style.color = 'red'; + indicator.textContent = JSONEditor.defaults.translate('hint_checkinput'); + $.each(errors, function() { + errordiv = $("div[data-schemapath$='"+$(this)[0].path+"']"); + errordiv.parent().addClass('has-error'); + if ($(this)[0].message==='hint_emailtoolarge') { + errormsg = errordiv.find("p[class^='help-block']"); + errortxt = errormsg.html(); + if (errortxt.lastIndexOf("Max.")<0) { + errormsg.html(errortxt + ' Max. 3MB!'); + } + } + }); } }); @@ -215,20 +212,7 @@ ZMSFormulator.on('change', function() { } // Not valid else { - submit.disabled = true; - indicator.style.color = 'red'; - indicator.textContent = JSONEditor.defaults.translate('hint_checkinput'); - $.each(errors, function() { - errordiv = $("div[data-schemapath$='"+$(this)[0].path+"']"); - errordiv.parent().addClass('has-error'); - if ($(this)[0].message==='hint_emailtoolarge') { - errormsg = errordiv.find("p[class^='help-block']"); - errortxt = errormsg.html(); - if (errortxt.lastIndexOf("Max.")<0) { - errormsg.html(errortxt + ' Max. 3MB!'); - } - } - }); + } // Translate $("p[class^='help-block'] strong").each(function() { diff --git a/zms3/formulator/JSONEditor.py b/zms3/formulator/JSONEditor.py index 33a6106..23a7f92 100644 --- a/zms3/formulator/JSONEditor.py +++ b/zms3/formulator/JSONEditor.py @@ -1,6 +1,6 @@ ################################################################################ # -# Copyright (c) 2017 HOFFMANN+LIEBENBERG in association with SNTL Publishing +# Copyright (c) 2019 HOFFMANN+LIEBENBERG in association with SNTL Publishing # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by