misc: do not call autosave on preview pages (#28309)
This commit is contained in:
parent
e224522ecc
commit
69b72ae6d5
|
@ -2707,6 +2707,9 @@ def test_preview_form(pub):
|
|||
user.store()
|
||||
page = login(get_app(pub), username='foo', password='foo').get('/preview/test/')
|
||||
|
||||
# check the form is marked as a preview (this disables autosave calls)
|
||||
assert page.pyquery('form[data-autosave=false]').length
|
||||
|
||||
# check no formdata gets stored
|
||||
next_page = page.forms[0].submit('submit')
|
||||
assert 'Check values then click submit.' in next_page.text
|
||||
|
|
|
@ -31,6 +31,11 @@ class PreviewFormPage(FormPage):
|
|||
def check_disabled(self):
|
||||
return False
|
||||
|
||||
def create_form(self, *args, **kwargs):
|
||||
form = super().create_form(*args, **kwargs)
|
||||
form.attrs['data-autosave'] = 'false'
|
||||
return form
|
||||
|
||||
def submitted(self, *args, **kwargs):
|
||||
self.html_top(self.formdef.name)
|
||||
r = TemplateIO(html=True)
|
||||
|
|
|
@ -123,7 +123,7 @@ Responsive_table_widget.prototype.init = function () {
|
|||
|
||||
$(function() {
|
||||
var autosave_timeout_id = null;
|
||||
if ($('form[data-has-draft]').length == 1) {
|
||||
if ($('form[data-has-draft]:not([data-autosave=false])').length == 1) {
|
||||
var last_auto_save = $('form[data-has-draft]').serialize();
|
||||
function autosave() {
|
||||
var $form = $('form[data-has-draft]');
|
||||
|
|
Loading…
Reference in New Issue