backoffice: remove redirection to welco (#23898) #1012
|
@ -2,13 +2,11 @@ import datetime
|
|||
import os
|
||||
import re
|
||||
import time
|
||||
import urllib.parse
|
||||
|
||||
import pytest
|
||||
import responses
|
||||
|
||||
from wcs import fields
|
||||
from wcs.api_utils import sign_url
|
||||
from wcs.carddef import CardDef
|
||||
from wcs.formdef import FormDef
|
||||
from wcs.qommon.http_request import HTTPRequest
|
||||
|
@ -221,101 +219,6 @@ def test_backoffice_submission_with_tracking_code(pub):
|
|||
assert formdata.tracking_code not in resp.text
|
||||
|
||||
|
||||
def test_backoffice_submission_welco(pub, welco_url):
|
||||
user = create_user(pub)
|
||||
|
||||
FormDef.wipe()
|
||||
formdef = FormDef()
|
||||
formdef.name = 'form title'
|
||||
formdef.fields = []
|
||||
formdef.backoffice_submission_roles = user.roles[:]
|
||||
formdef.store()
|
||||
|
||||
# if it's empty, redirect to welco
|
||||
app = login(get_app(pub))
|
||||
resp = app.get('/backoffice/submission/')
|
||||
assert resp.location == 'http://welco.example.net'
|
||||
|
||||
# if there are pending submissions, display them
|
||||
formdata = formdef.data_class()()
|
||||
formdata.data = {}
|
||||
formdata.status = 'draft'
|
||||
formdata.backoffice_submission = True
|
||||
formdata.submission_agent_id = str(user.id)
|
||||
formdata.store()
|
||||
|
||||
resp = app.get('/backoffice/submission/')
|
||||
assert 'Submission to complete' in resp.text
|
||||
# check agent name is displayed next to pending submission
|
||||
assert '(%s)' % user.display_name in resp.text
|
||||
|
||||
|
||||
def test_backoffice_submission_initiated_from_welco(pub, welco_url):
|
||||
user = create_user(pub)
|
||||
|
||||
FormDef.wipe()
|
||||
formdef = FormDef()
|
||||
formdef.name = 'form title'
|
||||
formdef.fields = [
|
||||
fields.PageField(
|
||||
id='0',
|
||||
label='1st PAGE',
|
||||
condition={
|
||||
'type': 'python',
|
||||
'value': 'form_submission_channel != "counter" and is_in_backoffice',
|
||||
},
|
||||
),
|
||||
fields.StringField(id='1', label='Field on 1st page'),
|
||||
fields.PageField(id='2', label='2nd PAGE'),
|
||||
fields.StringField(id='3', label='Field on 2nd page'),
|
||||
]
|
||||
formdef.backoffice_submission_roles = user.roles[:]
|
||||
formdef.store()
|
||||
|
||||
app = login(get_app(pub))
|
||||
|
||||
def post_formdata():
|
||||
signed_url = sign_url(
|
||||
'http://example.net/api/formdefs/form-title/submit'
|
||||
'?format=json&orig=coucou&email=%s' % urllib.parse.quote(user.email),
|
||||
'1234',
|
||||
)
|
||||
url = signed_url[len('http://example.net') :]
|
||||
resp = get_app(pub).post_json(
|
||||
url,
|
||||
{
|
||||
'meta': {
|
||||
'draft': True,
|
||||
'backoffice-submission': True,
|
||||
},
|
||||
'data': {},
|
||||
'context': {'channel': 'counter'},
|
||||
},
|
||||
)
|
||||
return resp.json['data']['id']
|
||||
|
||||
resp = app.get('/backoffice/management/form-title/%s/' % post_formdata())
|
||||
resp = resp.follow() # -> /backoffice/submission/form-title/XXX/
|
||||
resp = resp.follow() # -> /backoffice/submission/form-title/?mt=XYZ
|
||||
|
||||
# second page should be shown
|
||||
pq = resp.pyquery.remove_namespaces()
|
||||
assert pq('#steps li.current .label').text() == '2nd PAGE'
|
||||
assert 'Field on 2nd page' in resp.text # and in fields
|
||||
|
||||
# reverse condition
|
||||
formdef.fields[0].condition['value'] = 'form_submission_channel == "counter" and is_in_backoffice'
|
||||
formdef.store()
|
||||
|
||||
resp = app.get('/backoffice/management/form-title/%s/' % post_formdata())
|
||||
resp = resp.follow() # -> /backoffice/submission/form-title/XXX/
|
||||
resp = resp.follow() # -> /backoffice/submission/form-title/?mt=XYZ
|
||||
|
||||
pq = resp.pyquery.remove_namespaces()
|
||||
assert pq('#steps li.current .label').text() == '1st PAGE'
|
||||
assert 'Field on 1st page' in resp.text # and in fields
|
||||
|
||||
|
||||
def test_backoffice_submission_with_return_url(pub):
|
||||
user = create_user(pub)
|
||||
|
||||
|
@ -1327,21 +1230,6 @@ def test_backoffice_submission_manual_channel_with_return_url(pub):
|
|||
assert resp.location == 'http://example.net'
|
||||
|
||||
|
||||
def test_backoffice_submission_no_manual_channel_with_welco(pub, welco_url):
|
||||
user = create_user(pub)
|
||||
|
||||
FormDef.wipe()
|
||||
formdef = FormDef()
|
||||
formdef.name = 'form title'
|
||||
formdef.fields = []
|
||||
formdef.backoffice_submission_roles = user.roles[:]
|
||||
formdef.store()
|
||||
|
||||
app = login(get_app(pub))
|
||||
resp = app.get('/backoffice/submission/%s/' % formdef.url_name)
|
||||
assert 'submission_channel' not in resp.form.fields
|
||||
|
||||
|
||||
def test_backoffice_submission_with_nameid_and_channel(pub, local_user):
|
||||
user = create_user(pub)
|
||||
|
||||
|
|
|
@ -49,11 +49,6 @@ def fargo_secret(request, pub):
|
|||
return site_options(request, pub, 'wscall-secrets', 'fargo.example.net', 'xxx')
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def welco_url(request, pub):
|
||||
return site_options(request, pub, 'options', 'welco_url', 'http://welco.example.net')
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def emails():
|
||||
with EmailsMocking() as mock:
|
||||
|
|
|
@ -116,10 +116,6 @@ class FormFillPage(PublicFormFillPage):
|
|||
self.selected_submission_channel = None
|
||||
self.selected_user_id = None
|
||||
self.remove_draft = RemoveDraftDirectory(self)
|
||||
if get_publisher().get_site_option('welco_url', 'options'):
|
||||
# when welco is deployed, do not let agent manually change the
|
||||
# submission channel
|
||||
self.has_channel_support = False
|
||||
|
||||
def _q_index(self, *args, **kwargs):
|
||||
# if NameID, return URL or submission channel are in query string,
|
||||
|
@ -458,14 +454,9 @@ class SubmissionDirectory(Directory):
|
|||
misc_cat.formdefs = [x for x in list_forms if not x.category]
|
||||
cats.append(misc_cat)
|
||||
|
||||
welco_url = get_publisher().get_site_option('welco_url', 'options')
|
||||
|
||||
r = TemplateIO(html=True)
|
||||
r += get_session().display_message()
|
||||
modes = ['empty', 'create', 'existing']
|
||||
if welco_url:
|
||||
modes.remove('create')
|
||||
empty = True
|
||||
for mode in modes:
|
||||
list_content = TemplateIO()
|
||||
for cat in cats:
|
||||
|
@ -474,7 +465,6 @@ class SubmissionDirectory(Directory):
|
|||
list_content += self.form_list(cat.formdefs, title=cat.name, mode=mode)
|
||||
if not list_content.getvalue().strip():
|
||||
continue
|
||||
empty = False
|
||||
r += htmltext('<h2>%s</h2>') % {
|
||||
'create': _('New submission'),
|
||||
'existing': _('Running submission'),
|
||||
|
@ -484,9 +474,6 @@ class SubmissionDirectory(Directory):
|
|||
r += htmltext(list_content.getvalue())
|
||||
r += htmltext('</ul>')
|
||||
|
||||
if empty and welco_url:
|
||||
return redirect(welco_url)
|
||||
|
||||
return r.getvalue()
|
||||
|
||||
def form_list(self, formdefs, title=None, mode='create'):
|
||||
|
|
Loading…
Reference in New Issue