dataviz: don't crash on missing width value (#43726)

This commit is contained in:
Frédéric Péters 2020-06-07 18:08:17 +02:00
parent dfd35288fa
commit f36306ceea
2 changed files with 5 additions and 2 deletions

View File

@ -41,8 +41,8 @@ def dataviz_graph(request, *args, **kwargs):
error_text = None
try:
chart = cell.get_chart(
width=int(request.GET.get('width', 0)) or None,
height=int(request.GET.get('height', 0)) or int(cell.height)
width=int(request.GET['width']) if request.GET.get('width') else None,
height=int(request.GET['height']) if request.GET.get('height') else int(cell.height)
)
except UnsupportedDataSet as e:
error_text = _('Unsupported dataset.')

View File

@ -380,6 +380,9 @@ def test_chartng_cell_view(app, normal_user):
resp = app.get('/api/dataviz/graph/1/?width=400')
assert resp.content_type == 'image/svg+xml'
resp = app.get('/api/dataviz/graph/1/?width=') # no crash
assert resp.content_type == 'image/svg+xml'
page.public = False
page.save()
resp = app.get('/api/dataviz/graph/1/?width=400', status=403)