map: add int conversion before comparing zoom levels (#86631) #230
|
@ -132,9 +132,9 @@ class MapCellEditForm(forms.ModelForm):
|
|||
|
||||
def clean(self):
|
||||
cleaned_data = super().clean()
|
||||
initial_zoom = cleaned_data.get('initial_zoom')
|
||||
max_zoom = cleaned_data.get('max_zoom')
|
||||
min_zoom = cleaned_data.get('min_zoom')
|
||||
initial_zoom = int(cleaned_data['initial_zoom'])
|
||||
yweber marked this conversation as resolved
Outdated
|
||||
max_zoom = int(cleaned_data['max_zoom'])
|
||||
min_zoom = int(cleaned_data['min_zoom'])
|
||||
if min_zoom > max_zoom:
|
||||
raise ValidationError(
|
||||
_('Invalid zoom configuration: minimal zoom must be lower than maximal zoom')
|
||||
|
|
|
@ -367,3 +367,10 @@ def test_manager_map_edit_zoom_check(app, layer, admin_user):
|
|||
manager_submit_cell(resp.form, expect_errors=True)
|
||||
assert resp.status_int == 200
|
||||
assert 'Invalid zoom configuration: minimal zoom must be lower than maximal zoom' in resp.text
|
||||
|
||||
# String comparison problem #86631
|
||||
resp.form[f'cmaps_map-{cell.pk}-initial_zoom'] = 16
|
||||
resp.form[f'cmaps_map-{cell.pk}-min_zoom'] = 6
|
||||
resp.form[f'cmaps_map-{cell.pk}-max_zoom'] = 16
|
||||
manager_submit_cell(resp.form)
|
||||
assert resp.status_int == 200
|
||||
|
|
Loading…
Reference in New Issue
Ici on pourrait en profiter pour réécrire en
cleaned_data['initial_zoom']
, ça fait un peu tiquer d'appelerint()
sur un truc qui peut valoir None (ce n'est jamais le cas donc autant ne pas le laisser croire)