backoffice: disable autosave for backoffice submission (#58217)
This commit is contained in:
parent
5b0a943366
commit
fbe9dcca69
|
@ -45,6 +45,15 @@ def pub(request, emails):
|
|||
return pub
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def autosave(pub):
|
||||
if not pub.site_options.has_section('options'):
|
||||
pub.site_options.add_section('options')
|
||||
pub.site_options.set('options', 'backoffice-autosave', 'true')
|
||||
with open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w') as fd:
|
||||
pub.site_options.write(fd)
|
||||
|
||||
|
||||
def teardown_module(module):
|
||||
clean_temporary_pub()
|
||||
|
||||
|
@ -86,6 +95,7 @@ def test_backoffice_submission(pub):
|
|||
assert formdef.url_name in resp.text
|
||||
|
||||
resp = resp.click(formdef.name)
|
||||
assert resp.pyquery('form[data-autosave=false]').length
|
||||
resp.form['f1'] = 'test submission'
|
||||
resp.form['f2'] = 'baz'
|
||||
resp.form['f3'] = 'C'
|
||||
|
@ -399,7 +409,7 @@ def test_backoffice_submission_with_caller(pub):
|
|||
assert formdef.data_class().get(2).submission_context == {'caller': '0601020304'}
|
||||
|
||||
|
||||
def test_backoffice_parallel_submission(pub):
|
||||
def test_backoffice_parallel_submission(pub, autosave):
|
||||
user = create_user(pub)
|
||||
|
||||
FormDef.wipe()
|
||||
|
@ -431,6 +441,7 @@ def test_backoffice_parallel_submission(pub):
|
|||
resp3 = app.get('/backoffice/submission/form-title/%s/' % formdata.id)
|
||||
resp3 = resp3.follow()
|
||||
|
||||
assert not resp.pyquery('form[data-autosave=false]').length
|
||||
resp1.form['f1'] = 'foo'
|
||||
resp1 = resp1.form.submit('submit') # to validation page
|
||||
|
||||
|
@ -466,7 +477,7 @@ def test_backoffice_parallel_submission(pub):
|
|||
assert 'This form has already been submitted.' in resp4.text
|
||||
|
||||
|
||||
def test_backoffice_submission_autosave_tracking_code(pub):
|
||||
def test_backoffice_submission_autosave_tracking_code(pub, autosave):
|
||||
user = create_user(pub)
|
||||
|
||||
FormDef.wipe()
|
||||
|
@ -991,7 +1002,7 @@ def test_backoffice_submission_prefill_user_via_formula(pub):
|
|||
|
||||
|
||||
@pytest.mark.parametrize('enable_tracking_code', [True, False])
|
||||
def test_backoffice_submission_prefill_user_multiple_pages(pub, enable_tracking_code):
|
||||
def test_backoffice_submission_prefill_user_multiple_pages(pub, autosave, enable_tracking_code):
|
||||
user = create_user(pub)
|
||||
other_user = pub.user_class(name='other user')
|
||||
other_user.email = 'other@example.net'
|
||||
|
|
|
@ -305,6 +305,8 @@ class FormFillPage(PublicFormFillPage):
|
|||
def create_form(self, *args, **kwargs):
|
||||
form = super().create_form(*args, **kwargs)
|
||||
form.attrs['data-live-url'] = self.formdef.get_backoffice_submission_url() + 'live'
|
||||
if not get_publisher().has_site_option('backoffice-autosave'):
|
||||
form.attrs['data-autosave'] = 'false'
|
||||
if self.has_channel_support:
|
||||
form.add_hidden('submission_channel', self.selected_submission_channel)
|
||||
if self.has_user_support:
|
||||
|
|
Loading…
Reference in New Issue