0001-backoffice-prevent-custom-views-and-ics-CardPage-vie.patch
tests/backoffice_pages/test_custom_view.py | ||
---|---|---|
454 | 454 |
assert resp.location.endswith('/user-userx-custom-test-view/') |
455 | 455 |
resp = resp.follow() |
456 | 456 | |
457 |
# check slug not created with view name |
|
458 |
resp = app.get('/backoffice/management/form-title/') |
|
459 |
resp.forms['listing-settings']['user-label'].checked = False |
|
460 |
resp = resp.forms['listing-settings'].submit() |
|
461 |
resp.forms['save-custom-view']['title'] = 'Export' |
|
462 |
resp.forms['save-custom-view']['visibility'] = 'any' |
|
463 |
resp = resp.forms['save-custom-view'].submit() |
|
464 |
assert resp.location.endswith('/x-export/') |
|
465 |
resp = resp.follow() |
|
457 |
for view_slug in ('Export', 'Geojson', 'ics'): |
|
458 |
# check slug not created with view name |
|
459 |
resp = app.get('/backoffice/management/form-title/') |
|
460 |
resp.forms['listing-settings']['user-label'].checked = False |
|
461 |
resp = resp.forms['listing-settings'].submit() |
|
462 |
resp.forms['save-custom-view']['title'] = view_slug |
|
463 |
resp.forms['save-custom-view']['visibility'] = 'any' |
|
464 |
resp = resp.forms['save-custom-view'].submit() |
|
465 |
assert resp.location.endswith('/x-%s/' % view_slug.lower()) |
|
466 |
resp = resp.follow() |
|
466 | 467 | |
467 | 468 | |
468 | 469 |
def test_backoffice_custom_view_visibility(pub): |
wcs/custom_views.py | ||
---|---|---|
20 | 20 |
from django.utils.encoding import force_text |
21 | 21 |
from quixote import get_publisher |
22 | 22 | |
23 |
from wcs.backoffice.data_management import CardPage |
|
23 | 24 |
from wcs.carddef import CardDef |
24 | 25 |
from wcs.formdef import FormDef |
25 | 26 |
from wcs.qommon.misc import simplify |
... | ... | |
117 | 118 |
# prevent conflicts with system view names |
118 | 119 |
from wcs.backoffice.management import FormPage |
119 | 120 | |
120 |
if base_slug in [x if isinstance(x, str) else x[0] for x in FormPage._q_exports]: |
|
121 |
reserved_slugs = [ |
|
122 |
x if isinstance(x, str) else x[0] for x in FormPage._q_exports + CardPage._q_exports |
|
123 |
] + ['ics'] |
|
124 | ||
125 |
if base_slug in reserved_slugs: |
|
121 | 126 |
base_slug = 'x-' + base_slug |
122 | 127 | |
123 | 128 |
self.slug = base_slug |
124 |
- |