7105 |
7105 |
|
7106 |
7106 |
resp = resp.form.submit('button_x2').follow()
|
7107 |
7107 |
assert '<span class="status">Status2' in resp.text
|
|
7108 |
|
|
7109 |
def test_form_recall_logged_in_draft_using_tracking_code(pub):
|
|
7110 |
user = create_user(pub)
|
|
7111 |
formdef = create_formdef()
|
|
7112 |
formdef.fields = [
|
|
7113 |
fields.StringField(id='0', label='string',
|
|
7114 |
prefill={'type': 'string',
|
|
7115 |
'value': 'here_1:{{form_user_email}}'}),
|
|
7116 |
fields.CommentField(id='1', type='comment',
|
|
7117 |
label='here_2:{{form_user_email}}'),
|
|
7118 |
]
|
|
7119 |
formdef.enable_tracking_codes = True
|
|
7120 |
formdef.store()
|
|
7121 |
|
|
7122 |
resp = login(get_app(pub), username='foo', password='foo').get('/test/')
|
|
7123 |
formdef.data_class().wipe()
|
|
7124 |
assert '<h3>Tracking code</h3>' in resp.text
|
|
7125 |
tracking_code = get_displayed_tracking_code(resp)
|
|
7126 |
assert tracking_code is not None
|
|
7127 |
assert 'here_1:foo@localhost' in resp.text
|
|
7128 |
assert 'here_2:foo@localhost' in resp.text
|
|
7129 |
resp = resp.forms[0].submit('submit')
|
|
7130 |
assert formdef.data_class().count() == 1
|
|
7131 |
formdata_id = formdef.data_class().select()[0].id
|
|
7132 |
|
|
7133 |
# anonymous user must authenticate to restore user related drafts
|
|
7134 |
pub.session_manager.session_class.wipe()
|
|
7135 |
resp = get_app(pub).get('/')
|
|
7136 |
resp.forms[0]['code'] = tracking_code
|
|
7137 |
resp = resp.forms[0].submit()
|
|
7138 |
assert resp.location == 'http://example.net/code/%s/load' % tracking_code
|
|
7139 |
resp = resp.follow()
|
|
7140 |
assert resp.location == 'http://example.net/test/%s' % formdata_id
|
|
7141 |
resp = resp.follow()
|
|
7142 |
assert resp.location.startswith('http://example.net/login/?next=')
|
|
7143 |
|
|
7144 |
# authenticated user retrieve form_user variables valuated
|
|
7145 |
resp = login(get_app(pub), username='foo', password='foo').get('/')
|
|
7146 |
resp.forms[0]['code'] = tracking_code
|
|
7147 |
resp = resp.forms[0].submit()
|
|
7148 |
assert resp.location == 'http://example.net/code/%s/load' % tracking_code
|
|
7149 |
resp = resp.follow()
|
|
7150 |
assert resp.location == 'http://example.net/test/%s' % formdata_id
|
|
7151 |
resp = resp.follow()
|
|
7152 |
assert resp.location.startswith('http://example.net/test/?mt=')
|
|
7153 |
resp = resp.follow()
|
|
7154 |
resp = resp.forms[1].submit('previous')
|
|
7155 |
assert 'here_1:foo@localhost' in resp.text
|
|
7156 |
assert 'here_2:foo@localhost' in resp.text
|