0001-dashboard-return-bad-request-on-invalid-key-given-to.patch
combo/apps/dashboard/views.py | ||
---|---|---|
133 | 133 |
dashboard = DashboardCell.objects.filter(page__snapshot__isnull=True)[0] |
134 | 134 |
cell = ConfigJsonCell(key=kwargs.get('key'), order=1, page_id=dashboard.page_id, placeholder='_auto_tile') |
135 | 135 | |
136 |
if cell.key not in settings.JSON_CELL_TYPES: |
|
137 |
return HttpResponseBadRequest('bad request, invalid cell type: "%s"' % cell.key) |
|
138 | ||
136 | 139 |
# only keep parameters that are actually defined for this cell type. |
137 | 140 |
cell.parameters = {} |
138 | 141 |
for field in settings.JSON_CELL_TYPES[cell.key].get('form') or []: |
tests/test_dashboard.py | ||
---|---|---|
247 | 247 |
) |
248 | 248 |
assert resp.text.strip() == '/var1=one/var2=/' |
249 | 249 | |
250 |
# with invalid cell key |
|
251 |
resp = app.post( |
|
252 |
reverse('combo-dashboard-auto-tile', kwargs={'key': 'missing'}), |
|
253 |
params=json.dumps({'var1': 'one', 'var2': 'two'}), |
|
254 |
content_type='application/json', |
|
255 |
status=400, |
|
256 |
) |
|
257 | ||
250 | 258 |
# with missing data |
251 | 259 |
resp = app.post( |
252 | 260 |
reverse('combo-dashboard-auto-tile', kwargs={'key': 'test-config-json-cell'}), |
253 |
- |