Return 400 instead of 500 for /albums/create_album errors.
This commit is contained in:
parent
fcd507e337
commit
e58c50c94f
1 changed files with 6 additions and 2 deletions
|
@ -517,14 +517,18 @@ def get_albums_json():
|
||||||
|
|
||||||
@site.route('/albums/create_album', methods=['POST'])
|
@site.route('/albums/create_album', methods=['POST'])
|
||||||
def post_albums_create():
|
def post_albums_create():
|
||||||
print(dict(request.form))
|
|
||||||
title = request.form.get('title', None)
|
title = request.form.get('title', None)
|
||||||
description = request.form.get('description', None)
|
description = request.form.get('description', None)
|
||||||
parent = request.form.get('parent', None)
|
parent = request.form.get('parent', None)
|
||||||
if parent is not None:
|
if parent is not None:
|
||||||
parent = P_album(parent)
|
parent = P_album(parent)
|
||||||
|
|
||||||
album = P.new_album(title=title, description=description)
|
try:
|
||||||
|
album = P.new_album(title=title, description=description)
|
||||||
|
except etiquette.exceptions.EtiquetteException as e:
|
||||||
|
response = etiquette.jsonify.exception(e)
|
||||||
|
response = jsonify.make_json_response(response, status=400)
|
||||||
|
flask.abort(response)
|
||||||
if parent is not None:
|
if parent is not None:
|
||||||
parent.add(album)
|
parent.add(album)
|
||||||
response = etiquette.jsonify.album(album, minimal=False)
|
response = etiquette.jsonify.album(album, minimal=False)
|
||||||
|
|
Loading…
Reference in a new issue