backoffice: store the phone in submission context (#48354)
This commit is contained in:
parent
daa3e23f61
commit
a371c57f4b
|
@ -365,6 +365,35 @@ def test_backoffice_submission_with_return_url(pub):
|
|||
assert resp.location == 'https://example.org'
|
||||
|
||||
|
||||
def test_backoffice_submission_with_caller(pub):
|
||||
user = create_user(pub)
|
||||
|
||||
FormDef.wipe()
|
||||
formdef = FormDef()
|
||||
formdef.name = 'form title'
|
||||
formdef.fields = [
|
||||
fields.StringField(
|
||||
id='1', label='1st field', type='string',
|
||||
display_locations=['validation', 'summary', 'listings']),
|
||||
]
|
||||
formdef.backoffice_submission_roles = user.roles[:]
|
||||
formdef.store()
|
||||
formdef.data_class().wipe()
|
||||
|
||||
app = login(get_app(pub))
|
||||
resp = app.get('/backoffice/submission/form-title/?caller=0601020304')
|
||||
resp = resp.follow().follow()
|
||||
assert '<h3>Phone: 0601020304</h3>' not in resp.text
|
||||
assert formdef.data_class().get(1).submission_channel == ''
|
||||
assert not formdef.data_class().get(1).submission_context
|
||||
|
||||
resp = app.get('/backoffice/submission/form-title/?channel=phone&caller=0601020304')
|
||||
resp = resp.follow().follow()
|
||||
assert '<h3>Phone: 0601020304</h3>' in resp.text
|
||||
assert formdef.data_class().get(2).submission_channel == 'phone'
|
||||
assert formdef.data_class().get(2).submission_context == {'caller': '0601020304'}
|
||||
|
||||
|
||||
def test_backoffice_parallel_submission(pub):
|
||||
user = create_user(pub)
|
||||
|
||||
|
|
|
@ -2796,6 +2796,8 @@ class FormBackOfficeStatusPage(FormStatusPage):
|
|||
if formdata.submission_channel:
|
||||
r += htmltext('<h3>%s</h3>') % '%s: %s' % (
|
||||
_('Channel'), formdata.get_submission_channel_label())
|
||||
if extra_context.get('caller'):
|
||||
r += htmltext('<h3>%s: %s</h3>') % (_('Phone'), extra_context['caller'])
|
||||
if extra_context.get('thumbnail_url'):
|
||||
r += htmltext('<p class="thumbnail"><img src="%s" alt=""/></p>'
|
||||
) % extra_context.get('thumbnail_url')
|
||||
|
|
|
@ -114,7 +114,8 @@ class FormFillPage(PublicFormFillPage):
|
|||
submission_channel = get_request().form.get('channel')
|
||||
name_id = get_request().form.get('NameID')
|
||||
return_url = get_request().form.get('ReturnURL')
|
||||
if name_id or submission_channel or return_url:
|
||||
caller = get_request().form.get('caller')
|
||||
if name_id or submission_channel or return_url or caller:
|
||||
formdata = self.formdef.data_class()()
|
||||
formdata.data = {}
|
||||
formdata.backoffice_submission = True
|
||||
|
@ -129,6 +130,8 @@ class FormFillPage(PublicFormFillPage):
|
|||
formdata.user_id = users[0].id
|
||||
if return_url:
|
||||
formdata.submission_context['return_url'] = return_url
|
||||
if submission_channel == 'phone' and caller:
|
||||
formdata.submission_context['caller'] = caller
|
||||
formdata.store()
|
||||
self.set_tracking_code(formdata)
|
||||
return redirect('%s/' % formdata.id)
|
||||
|
|
Loading…
Reference in New Issue