0001-backoffice-don-t-let-new-forms-be-created-when-welco.patch
tests/conftest.py | ||
---|---|---|
11 | 11 |
if 'postgresql' in item.keywords and item.config.option.without_postgresql_tests is True: |
12 | 12 |
pytest.skip('skipped (PostgreSQL are disabled on command line)') |
13 | 13 | |
14 |
@pytest.fixture |
|
15 |
def fargo_url(request, pub): |
|
14 |
def variable_url(request, pub, variable, url): |
|
16 | 15 |
config = ConfigParser.ConfigParser() |
17 | 16 |
path = os.path.join(pub.app_dir, 'site-options.cfg') |
18 |
url = 'http://fargo.example.net/' |
|
19 | 17 |
if os.path.exists(path): |
20 | 18 |
config.read([path]) |
21 | 19 |
if not config.has_section('options'): |
22 | 20 |
config.add_section('options') |
23 |
config.set('options', 'fargo_url', url)
|
|
21 |
config.set('options', variable, url)
|
|
24 | 22 |
with file(path, 'w') as site_option: |
25 | 23 |
config.write(site_option) |
26 | 24 | |
... | ... | |
28 | 26 |
config = ConfigParser.ConfigParser() |
29 | 27 |
if os.path.exists(path): |
30 | 28 |
config.read([path]) |
31 |
config.remove_option('options', 'fargo_url')
|
|
29 |
config.remove_option('options', variable)
|
|
32 | 30 |
with file(path, 'w') as site_option: |
33 | 31 |
config.write(site_option) |
34 | 32 |
request.addfinalizer(fin) |
35 | 33 |
return url |
34 | ||
35 |
@pytest.fixture |
|
36 |
def fargo_url(request, pub): |
|
37 |
return variable_url(request, pub, 'fargo_url', 'http://fargo.example.net') |
|
38 | ||
39 |
@pytest.fixture |
|
40 |
def welco_url(request, pub): |
|
41 |
return variable_url(request, pub, 'welco_url', 'http://welco.example.net') |
tests/test_backoffice_pages.py | ||
---|---|---|
756 | 756 |
resp = resp.form.submit('cancel') |
757 | 757 |
assert resp.location == 'http://example.net/backoffice/submission/' |
758 | 758 | |
759 |
def test_backoffice_submission_welco(pub, welco_url): |
|
760 |
user = create_user(pub) |
|
761 |
create_environment(pub) |
|
762 | ||
763 |
app = login(get_app(pub)) |
|
764 |
resp = app.get('/backoffice/') |
|
765 |
assert not 'Submission' in resp.body |
|
766 |
app.get('/backoffice/submission/', status=403) |
|
767 | ||
768 |
formdef = FormDef.get_by_urlname('form-title') |
|
769 |
formdef.backoffice_submission_roles = user.roles[:] |
|
770 |
formdef.store() |
|
771 | ||
772 |
# if it's empty, redirect to welco |
|
773 |
resp = app.get('/backoffice/') |
|
774 |
assert 'Submission' in resp.body |
|
775 |
resp = app.get('/backoffice/submission/') |
|
776 |
assert resp.location == 'http://welco.example.net' |
|
777 | ||
778 |
# if there are pending submissions, display them |
|
779 |
formdata = formdef.data_class()() |
|
780 |
formdata.data = {} |
|
781 |
formdata.status = 'draft' |
|
782 |
formdata.backoffice_submission = True |
|
783 |
formdata.store() |
|
784 | ||
785 |
resp = app.get('/backoffice/') |
|
786 |
assert 'Submission' in resp.body |
|
787 |
resp = app.get('/backoffice/submission/') |
|
788 |
assert 'Submission to complete' in resp.body |
|
789 | ||
759 | 790 |
def test_backoffice_submission_dispatch(pub): |
760 | 791 |
user = create_user(pub) |
761 | 792 |
create_environment(pub) |
wcs/backoffice/submission.py | ||
---|---|---|
195 | 195 |
misc_cat.formdefs = [x for x in list_forms if not x.category] |
196 | 196 |
cats.append(misc_cat) |
197 | 197 | |
198 |
welco_url = get_publisher().get_site_option('welco_url', 'options') |
|
199 | ||
198 | 200 |
r = TemplateIO(html=True) |
199 |
for mode in ['empty', 'create', 'existing']: |
|
201 |
modes = ['empty', 'create', 'existing'] |
|
202 |
if welco_url: |
|
203 |
modes.remove('create') |
|
204 |
empty = True |
|
205 |
for mode in modes: |
|
200 | 206 |
list_content = TemplateIO() |
201 | 207 |
for cat in cats: |
202 | 208 |
if not cat.formdefs: |
... | ... | |
204 | 210 |
list_content += self.form_list(cat.formdefs, title=cat.name, mode=mode) |
205 | 211 |
if not list_content.getvalue().strip(): |
206 | 212 |
continue |
213 |
empty = False |
|
207 | 214 |
r += htmltext('<div class="bo-block">') |
208 | 215 |
r += htmltext('<h2>%s</h2>') % { |
209 | 216 |
'create': _('Submission'), |
... | ... | |
215 | 222 |
r += htmltext('</ul>') |
216 | 223 |
r += htmltext('</div>') |
217 | 224 | |
225 |
if empty and welco_url: |
|
226 |
return redirect(welco_url) |
|
227 | ||
218 | 228 |
return r.getvalue() |
219 | 229 | |
220 | 230 |
def form_list(self, formdefs, title=None, mode='create'): |
wcs/ctl/check_hobos.py | ||
---|---|---|
304 | 304 | |
305 | 305 |
if 'options' not in config.sections(): |
306 | 306 |
config.add_section('options') |
307 | ||
308 |
# add known services |
|
307 | 309 |
for service in self.all_services.get('services', []): |
308 |
if service.get('service-id') != 'fargo': |
|
309 |
continue |
|
310 |
config.set('options', 'fargo_url', service.get('base_url')) |
|
311 |
# Use the first fargo found and stop |
|
312 |
break |
|
310 |
if service.get('service-id') == 'fargo': |
|
311 |
config.set('options', 'fargo_url', service.get('base_url')) |
|
312 |
if service.get('service-id') == 'welco': |
|
313 |
config.set('options', 'welco_url', service.get('base_url')) |
|
313 | 314 | |
314 | 315 |
try: |
315 | 316 |
portal_agent_url = config.get('variables', 'portal_agent_url') |
316 |
- |