Added logging and a TODO
This commit is contained in:
@@ -96,6 +96,7 @@ def benchmark_submit_view(request):
|
||||
return JsonResponse({'message': 'The submitted data is not valid.'}, status=422)
|
||||
|
||||
url = opendata.url('api/benchmarks/')
|
||||
my_log.debug('Sending benchmark to %s', url)
|
||||
try:
|
||||
r = requests.post(url, json=benchmark_data, verify=True, headers=headers)
|
||||
except requests.exceptions.ConnectionError as ex:
|
||||
@@ -104,6 +105,7 @@ def benchmark_submit_view(request):
|
||||
status=503)
|
||||
|
||||
if r.status_code != 201:
|
||||
my_log.info('Response code %d received from %s: %s', r.status_code, url, r.text)
|
||||
# TODO provide meaningful error message
|
||||
return JsonResponse({'message': 'The submitted data is not valid'}, status=r.status_code)
|
||||
|
||||
@@ -121,6 +123,8 @@ def benchmark_submit_view(request):
|
||||
|
||||
log.info('Stored benchmark %s' % response['benchmark_id'])
|
||||
|
||||
# TODO(Sybren): include Location header indicating where the
|
||||
# submitted benchmark can be viewed.
|
||||
return JsonResponse({'message': 'All was well.',
|
||||
'benchmark_id': response['benchmark_id']},
|
||||
status=201)
|
||||
|
||||
Reference in New Issue
Block a user