0001-categories-avoid-creating-forbidden-slugs-38269.patch
tests/test_categories.py | ||
---|---|---|
65 | 65 |
assert test2.url_name == 'test-2' |
66 | 66 | |
67 | 67 | |
68 |
@pytest.mark.parametrize('category_class', [Category, CardDefCategory]) |
|
69 |
def test_name_giving_a_forbidden_slug(category_class): |
|
70 |
category_class.wipe() |
|
71 |
test = category_class() |
|
72 |
test.name = 'API' |
|
73 |
test.store() |
|
74 |
test = category_class.get(1) |
|
75 |
assert test.url_name == 'cat-api' |
|
76 | ||
77 | ||
68 | 78 |
@pytest.mark.parametrize('category_class', [Category, CardDefCategory]) |
69 | 79 |
def test_sort_positions(category_class): |
70 | 80 |
category_class.wipe() |
wcs/categories.py | ||
---|---|---|
95 | 95 |
x.url_name: True for x in self.select(ignore_migration=True, ignore_errors=True) |
96 | 96 |
} |
97 | 97 |
base_slug = simplify(self.name) |
98 |
if base_slug in get_publisher().root_directory_class._q_exports: |
|
99 |
base_slug = 'cat-%s' % base_slug |
|
98 | 100 |
self.url_name = base_slug |
99 | 101 |
i = 2 |
100 | 102 |
while self.url_name in existing_slugs: |
101 |
- |