0001-admin-fix-category-ordering-with-missing-id-71390.patch
tests/admin_pages/test_block.py | ||
---|---|---|
379 | 379 |
BlockCategory.sort_by_position(categories) |
380 | 380 |
assert [x.id for x in categories] == [str(category2.id), str(category.id)] |
381 | 381 | |
382 |
app.get('/backoffice/forms/blocks/categories/update_order?order=%s;%s;' % (category.id, category2.id)) |
|
382 |
app.get('/backoffice/forms/blocks/categories/update_order?order=%s;%s;0' % (category.id, category2.id))
|
|
383 | 383 |
categories = BlockCategory.select() |
384 | 384 |
BlockCategory.sort_by_position(categories) |
385 | 385 |
assert [x.id for x in categories] == [str(category.id), str(category2.id)] |
tests/admin_pages/test_carddefcategory.py | ||
---|---|---|
223 | 223 |
CardDefCategory.sort_by_position(categories) |
224 | 224 |
assert [x.id for x in categories] == ['1', '2', '3'] |
225 | 225 | |
226 |
app.get('/backoffice/cards/categories/update_order?order=3;1;2;') |
|
226 |
app.get('/backoffice/cards/categories/update_order?order=3;1;2;0')
|
|
227 | 227 |
categories = CardDefCategory.select() |
228 | 228 |
CardDefCategory.sort_by_position(categories) |
229 | 229 |
assert [x.id for x in categories] == ['3', '1', '2'] |
tests/admin_pages/test_category.py | ||
---|---|---|
208 | 208 |
Category.sort_by_position(categories) |
209 | 209 |
assert [x.id for x in categories] == ['1', '2', '3'] |
210 | 210 | |
211 |
app.get('/backoffice/forms/categories/update_order?order=3;1;2;') |
|
211 |
app.get('/backoffice/forms/categories/update_order?order=3;1;2;0')
|
|
212 | 212 |
categories = Category.select() |
213 | 213 |
Category.sort_by_position(categories) |
214 | 214 |
assert [x.id for x in categories] == ['3', '1', '2'] |
tests/admin_pages/test_datasource.py | ||
---|---|---|
403 | 403 |
assert [x.id for x in categories] == [str(category2.id), str(category.id)] |
404 | 404 | |
405 | 405 |
app.get( |
406 |
'/backoffice/settings/data-sources/categories/update_order?order=%s;%s;' % (category.id, category2.id) |
|
406 |
'/backoffice/settings/data-sources/categories/update_order?order=%s;%s;0' |
|
407 |
% (category.id, category2.id) |
|
407 | 408 |
) |
408 | 409 |
categories = DataSourceCategory.select() |
409 | 410 |
DataSourceCategory.sort_by_position(categories) |
tests/test_mail_templates.py | ||
---|---|---|
276 | 276 |
assert [x.id for x in categories] == [str(category2.id), str(category.id)] |
277 | 277 | |
278 | 278 |
app.get( |
279 |
'/backoffice/workflows/mail-templates/categories/update_order?order=%s;%s;' |
|
279 |
'/backoffice/workflows/mail-templates/categories/update_order?order=%s;%s;0'
|
|
280 | 280 |
% (category.id, category2.id) |
281 | 281 |
) |
282 | 282 |
categories = MailTemplateCategory.select() |
wcs/admin/categories.py | ||
---|---|---|
380 | 380 |
request = get_request() |
381 | 381 |
new_order = request.form['order'].strip(';').split(';') |
382 | 382 |
categories = self.category_class.select() |
383 |
dict = {} |
|
384 |
for l in categories: |
|
385 |
dict[str(l.id)] = l |
|
383 |
categories_by_id = {} |
|
384 |
for cat in categories: |
|
385 |
categories_by_id[str(cat.id)] = cat |
|
386 |
new_order = [o for o in new_order if o in categories_by_id.keys()] |
|
386 | 387 |
for i, o in enumerate(new_order): |
387 |
dict[o].position = i + 1
|
|
388 |
dict[o].store()
|
|
388 |
categories_by_id[o].position = i + 1
|
|
389 |
categories_by_id[o].store()
|
|
389 | 390 |
return 'ok' |
390 | 391 | |
391 | 392 |
def new(self): |
392 |
- |