0001-admin-fix-filetypes-with-empty-fields-65457.patch
tests/admin_pages/test_settings.py | ||
---|---|---|
673 | 673 |
resp = resp.follow() |
674 | 674 |
assert 'HTML files' not in resp.text |
675 | 675 | |
676 |
resp = app.get('/backoffice/settings/filetypes/') |
|
677 |
resp = resp.forms[0].submit('submit') |
|
678 |
assert 'This field is required.' in resp |
|
679 | ||
676 | 680 | |
677 | 681 |
def test_settings_filetypes_update(pub): |
678 | 682 |
create_superuser(pub) |
... | ... | |
722 | 726 |
'label': 'Text files', |
723 | 727 |
} |
724 | 728 | |
729 |
resp = app.get('/backoffice/settings/filetypes/') |
|
730 |
resp = resp.click('Text files') |
|
731 |
resp.forms[0]['mimetypes'] = '' |
|
732 |
resp = resp.forms[0].submit('submit') |
|
733 |
assert 'This field is required.' in resp |
|
734 | ||
725 | 735 | |
726 | 736 |
def test_settings_geolocation(pub): |
727 | 737 |
create_superuser(pub) |
wcs/admin/settings.py | ||
---|---|---|
374 | 374 |
filetypes_cfg = get_cfg('filetypes', {}) |
375 | 375 | |
376 | 376 |
form = self.get_form() |
377 |
if form.get_submit() == 'submit': |
|
377 |
if form.get_submit() == 'submit' and not form.has_errors():
|
|
378 | 378 |
if filetypes_cfg: |
379 | 379 |
new_filetype_id = max(filetypes_cfg.keys()) + 1 |
380 | 380 |
else: |
... | ... | |
430 | 430 |
if form.get_widget('cancel').parse(): |
431 | 431 |
return redirect('.') |
432 | 432 | |
433 |
if form.get_submit() == 'submit': |
|
433 |
if form.get_submit() == 'submit' and not form.has_errors():
|
|
434 | 434 |
old_filetype = filetype.copy() |
435 | 435 |
filetype['label'] = form.get_widget('label').parse() |
436 | 436 |
filetype['mimetypes'] = self.parse_mimetypes(form.get_widget('mimetypes').parse()) |
437 |
- |