0001-misc-do-not-call-autosave-on-preview-pages-28309.patch
tests/form_pages/test_all.py | ||
---|---|---|
2707 | 2707 |
user.store() |
2708 | 2708 |
page = login(get_app(pub), username='foo', password='foo').get('/preview/test/') |
2709 | 2709 | |
2710 |
# check the form is marked as a preview (this disables autosave calls) |
|
2711 |
assert page.pyquery('form[data-autosave=false]').length |
|
2712 | ||
2710 | 2713 |
# check no formdata gets stored |
2711 | 2714 |
next_page = page.forms[0].submit('submit') |
2712 | 2715 |
assert 'Check values then click submit.' in next_page.text |
wcs/forms/preview.py | ||
---|---|---|
31 | 31 |
def check_disabled(self): |
32 | 32 |
return False |
33 | 33 | |
34 |
def create_form(self, *args, **kwargs): |
|
35 |
form = super().create_form(*args, **kwargs) |
|
36 |
form.attrs['data-autosave'] = 'false' |
|
37 |
return form |
|
38 | ||
34 | 39 |
def submitted(self, *args, **kwargs): |
35 | 40 |
self.html_top(self.formdef.name) |
36 | 41 |
r = TemplateIO(html=True) |
wcs/qommon/static/js/qommon.forms.js | ||
---|---|---|
123 | 123 | |
124 | 124 |
$(function() { |
125 | 125 |
var autosave_timeout_id = null; |
126 |
if ($('form[data-has-draft]').length == 1) { |
|
126 |
if ($('form[data-has-draft]:not([data-autosave=false])').length == 1) {
|
|
127 | 127 |
var last_auto_save = $('form[data-has-draft]').serialize(); |
128 | 128 |
function autosave() { |
129 | 129 |
var $form = $('form[data-has-draft]'); |
130 |
- |