Skip to content

Commit

Permalink
Fix decorator
Browse files Browse the repository at this point in the history
  • Loading branch information
kaapstorm committed Feb 24, 2024
1 parent b375cb5 commit e7d921e
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions hq_superset/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __init__(self):

@expose('/change/', methods=('POST',))
@handle_api_exception
@require_oauth
@require_oauth()
def post_dataset_change(self) -> FlaskResponse:
if request.content_length > self.MAX_REQUEST_LENGTH:
return json_error_response(
Expand All @@ -61,20 +61,9 @@ def post_dataset_change(self) -> FlaskResponse:
request_json = json.loads(request.get_data(as_text=True))
change = DataSetChange(**request_json)
change.update_dataset()
return json_success(
'Request accepted; updating dataset',
status=HTTPStatus.ACCEPTED.value,
)
return json_success('Dataset updated')
except json.JSONDecodeError:
return json_error_response(
'Invalid JSON syntax',
status=HTTPStatus.BAD_REQUEST.value,
)
except (TypeError, ValueError) as err:
return json_error_response(
str(err),
status=HTTPStatus.BAD_REQUEST.value,
)
# `@handle_api_exception` will return other exceptions as JSON
# with status code 500, e.g.
# {"error": "CommCare HQ database missing"}

0 comments on commit e7d921e

Please sign in to comment.