backoffice: prevent conflicts between custom and system view names (#53575)
This commit is contained in:
parent
1cbef4e79a
commit
21dd05b670
|
@ -364,6 +364,16 @@ def test_backoffice_custom_view_reserved_slug(pub):
|
|||
assert resp.location.endswith('/user-userx-custom-test-view/')
|
||||
resp = resp.follow()
|
||||
|
||||
# check slug not created with view name
|
||||
resp = app.get('/backoffice/management/form-title/')
|
||||
resp.forms['listing-settings']['user-label'].checked = False
|
||||
resp = resp.forms['listing-settings'].submit()
|
||||
resp.forms['save-custom-view']['title'] = 'Export'
|
||||
resp.forms['save-custom-view']['visibility'] = 'any'
|
||||
resp = resp.forms['save-custom-view'].submit()
|
||||
assert resp.location.endswith('/x-export/')
|
||||
resp = resp.follow()
|
||||
|
||||
|
||||
def test_backoffice_custom_view_visibility(pub):
|
||||
create_superuser(pub)
|
||||
|
|
|
@ -113,6 +113,13 @@ class CustomView(StorableObject):
|
|||
if base_slug.startswith('user-'):
|
||||
# prevent a slug starting with user- as it's used in URLs
|
||||
base_slug = 'userx-' + base_slug[5:]
|
||||
|
||||
# prevent conflicts with system view names
|
||||
from wcs.backoffice.management import FormPage
|
||||
|
||||
if base_slug in [x if isinstance(x, str) else x[0] for x in FormPage._q_exports]:
|
||||
base_slug = 'x-' + base_slug
|
||||
|
||||
self.slug = base_slug
|
||||
i = 2
|
||||
while self.slug in existing_slugs:
|
||||
|
|
Loading…
Reference in New Issue