Match renamed flasktools.json_response.
This commit is contained in:
parent
f510bb88c0
commit
91cf08efde
8 changed files with 63 additions and 63 deletions
|
@ -106,7 +106,7 @@ def P_wrapper(function):
|
|||
flask.abort(status, exc.error_message)
|
||||
else:
|
||||
response = exc.jsonify()
|
||||
response = flasktools.make_json_response(response, status=status)
|
||||
response = flasktools.json_response(response, status=status)
|
||||
flask.abort(response)
|
||||
|
||||
except Exception as exc:
|
||||
|
@ -114,7 +114,7 @@ def P_wrapper(function):
|
|||
if response_type == 'html':
|
||||
flask.abort(500)
|
||||
else:
|
||||
flask.abort(flasktools.make_json_response({}, status=500))
|
||||
flask.abort(flasktools.json_response({}, status=500))
|
||||
|
||||
return P_wrapped
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ def catch_etiquette_exception(function):
|
|||
else:
|
||||
status = 400
|
||||
response = exc.jsonify()
|
||||
response = flasktools.make_json_response(response, status=status)
|
||||
response = flasktools.json_response(response, status=status)
|
||||
flask.abort(response)
|
||||
return wrapped
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ def get_admin():
|
|||
@site.route('/admin/reload_config', methods=['POST'])
|
||||
def post_reload_config():
|
||||
if not request.is_localhost:
|
||||
return flasktools.make_json_response({}, status=403)
|
||||
return flasktools.json_response({}, status=403)
|
||||
|
||||
common.P.load_config()
|
||||
return flasktools.make_json_response({})
|
||||
return flasktools.json_response({})
|
||||
|
|
|
@ -30,7 +30,7 @@ def get_album_html(album_id):
|
|||
def get_album_json(album_id):
|
||||
album = common.P_album(album_id, response_type='json')
|
||||
album = album.jsonify()
|
||||
return flasktools.make_json_response(album)
|
||||
return flasktools.json_response(album)
|
||||
|
||||
@site.route('/album/<album_id>.zip')
|
||||
def get_album_zip(album_id):
|
||||
|
@ -65,7 +65,7 @@ def post_album_add_child(album_id):
|
|||
print(children)
|
||||
album.add_children(children, commit=True)
|
||||
response = album.jsonify()
|
||||
return flasktools.make_json_response(response)
|
||||
return flasktools.json_response(response)
|
||||
|
||||
@site.route('/album/<album_id>/remove_child', methods=['POST'])
|
||||
@flasktools.required_fields(['child_id'], forbid_whitespace=True)
|
||||
|
@ -76,14 +76,14 @@ def post_album_remove_child(album_id):
|
|||
children = list(common.P_albums(child_ids, response_type='json'))
|
||||
album.remove_children(children, commit=True)
|
||||
response = album.jsonify()
|
||||
return flasktools.make_json_response(response)
|
||||
return flasktools.json_response(response)
|
||||
|
||||
@site.route('/album/<album_id>/remove_thumbnail_photo', methods=['POST'])
|
||||
def post_album_remove_thumbnail_photo(album_id):
|
||||
album = common.P_album(album_id, response_type='json')
|
||||
album.set_thumbnail_photo(None)
|
||||
common.P.commit(message='album remove thumbnail photo endpoint')
|
||||
return flasktools.make_json_response(album.jsonify())
|
||||
return flasktools.json_response(album.jsonify())
|
||||
|
||||
@site.route('/album/<album_id>/refresh_directories', methods=['POST'])
|
||||
def post_album_refresh_directories(album_id):
|
||||
|
@ -94,7 +94,7 @@ def post_album_refresh_directories(album_id):
|
|||
digest = common.P.digest_directory(directory, new_photo_ratelimit=0.1)
|
||||
gentools.run(digest)
|
||||
common.P.commit(message='refresh album directories endpoint')
|
||||
return flasktools.make_json_response({})
|
||||
return flasktools.json_response({})
|
||||
|
||||
@site.route('/album/<album_id>/set_thumbnail_photo', methods=['POST'])
|
||||
@flasktools.required_fields(['photo_id'], forbid_whitespace=True)
|
||||
|
@ -103,7 +103,7 @@ def post_album_set_thumbnail_photo(album_id):
|
|||
photo = common.P_photo(request.form['photo_id'], response_type='json')
|
||||
album.set_thumbnail_photo(photo)
|
||||
common.P.commit(message='album set thumbnail photo endpoint')
|
||||
return flasktools.make_json_response(album.jsonify())
|
||||
return flasktools.json_response(album.jsonify())
|
||||
|
||||
# Album photo operations ###########################################################################
|
||||
|
||||
|
@ -119,7 +119,7 @@ def post_album_add_photo(album_id):
|
|||
photos = list(common.P_photos(photo_ids, response_type='json'))
|
||||
album.add_photos(photos, commit=True)
|
||||
response = album.jsonify()
|
||||
return flasktools.make_json_response(response)
|
||||
return flasktools.json_response(response)
|
||||
|
||||
@site.route('/album/<album_id>/remove_photo', methods=['POST'])
|
||||
@flasktools.required_fields(['photo_id'], forbid_whitespace=True)
|
||||
|
@ -133,7 +133,7 @@ def post_album_remove_photo(album_id):
|
|||
photos = list(common.P_photos(photo_ids, response_type='json'))
|
||||
album.remove_photos(photos, commit=True)
|
||||
response = album.jsonify()
|
||||
return flasktools.make_json_response(response)
|
||||
return flasktools.json_response(response)
|
||||
|
||||
# Album tag operations #############################################################################
|
||||
|
||||
|
@ -150,13 +150,13 @@ def post_album_add_tag(album_id):
|
|||
tag = common.P_tag(tag, response_type='json')
|
||||
except etiquette.exceptions.NoSuchTag as exc:
|
||||
response = exc.jsonify()
|
||||
return flasktools.make_json_response(response, status=404)
|
||||
return flasktools.json_response(response, status=404)
|
||||
recursive = request.form.get('recursive', False)
|
||||
recursive = stringtools.truthystring(recursive)
|
||||
album.add_tag_to_all(tag, nested_children=recursive, commit=True)
|
||||
response['action'] = 'add_tag'
|
||||
response['tagname'] = tag.name
|
||||
return flasktools.make_json_response(response)
|
||||
return flasktools.json_response(response)
|
||||
|
||||
# Album metadata operations ########################################################################
|
||||
|
||||
|
@ -171,7 +171,7 @@ def post_album_edit(album_id):
|
|||
description = request.form.get('description', None)
|
||||
album.edit(title=title, description=description, commit=True)
|
||||
response = album.jsonify(minimal=True)
|
||||
return flasktools.make_json_response(response)
|
||||
return flasktools.json_response(response)
|
||||
|
||||
@site.route('/album/<album_id>/show_in_folder', methods=['POST'])
|
||||
def post_album_show_in_folder(album_id):
|
||||
|
@ -187,7 +187,7 @@ def post_album_show_in_folder(album_id):
|
|||
if os.name == 'nt':
|
||||
command = f'start explorer.exe "{directory.absolute_path}"'
|
||||
os.system(command)
|
||||
return flasktools.make_json_response({})
|
||||
return flasktools.json_response({})
|
||||
|
||||
flask.abort(501)
|
||||
|
||||
|
@ -198,7 +198,7 @@ def post_album_show_in_folder(album_id):
|
|||
def get_all_album_names():
|
||||
all_albums = {album.id: album.display_name for album in common.P.get_albums()}
|
||||
response = {'albums': all_albums}
|
||||
return flasktools.make_json_response(response)
|
||||
return flasktools.json_response(response)
|
||||
|
||||
def get_albums_core():
|
||||
albums = list(common.P.get_root_albums())
|
||||
|
@ -220,7 +220,7 @@ def get_albums_html():
|
|||
def get_albums_json():
|
||||
albums = get_albums_core()
|
||||
albums = [album.jsonify(minimal=True) for album in albums]
|
||||
return flasktools.make_json_response(albums)
|
||||
return flasktools.json_response(albums)
|
||||
|
||||
# Album create and delete ##########################################################################
|
||||
|
||||
|
@ -240,10 +240,10 @@ def post_albums_create():
|
|||
common.P.commit('create album endpoint')
|
||||
|
||||
response = album.jsonify(minimal=False)
|
||||
return flasktools.make_json_response(response)
|
||||
return flasktools.json_response(response)
|
||||
|
||||
@site.route('/album/<album_id>/delete', methods=['POST'])
|
||||
def post_album_delete(album_id):
|
||||
album = common.P_album(album_id, response_type='json')
|
||||
album.delete(commit=True)
|
||||
return flasktools.make_json_response({})
|
||||
return flasktools.json_response({})
|
||||
|
|
|
@ -15,7 +15,7 @@ session_manager = common.session_manager
|
|||
def get_bookmark_json(bookmark_id):
|
||||
bookmark = common.P_bookmark(bookmark_id, response_type='json')
|
||||
response = bookmark.jsonify()
|
||||
return flasktools.make_json_response(response)
|
||||
return flasktools.json_response(response)
|
||||
|
||||
@site.route('/bookmark/<bookmark_id>/edit', methods=['POST'])
|
||||
def post_bookmark_edit(bookmark_id):
|
||||
|
@ -26,7 +26,7 @@ def post_bookmark_edit(bookmark_id):
|
|||
bookmark.edit(title=title, url=url, commit=True)
|
||||
|
||||
response = bookmark.jsonify()
|
||||
response = flasktools.make_json_response(response)
|
||||
response = flasktools.json_response(response)
|
||||
return response
|
||||
|
||||
# Bookmark listings ################################################################################
|
||||
|
@ -39,7 +39,7 @@ def get_bookmarks_html():
|
|||
@site.route('/bookmarks.json')
|
||||
def get_bookmarks_json():
|
||||
bookmarks = [b.jsonify() for b in common.P.get_bookmarks()]
|
||||
return flasktools.make_json_response(bookmarks)
|
||||
return flasktools.json_response(bookmarks)
|
||||
|
||||
# Bookmark create and delete #######################################################################
|
||||
|
||||
|
@ -51,11 +51,11 @@ def post_bookmark_create():
|
|||
user = session_manager.get(request).user
|
||||
bookmark = common.P.new_bookmark(url=url, title=title, author=user, commit=True)
|
||||
response = bookmark.jsonify()
|
||||
response = flasktools.make_json_response(response)
|
||||
response = flasktools.json_response(response)
|
||||
return response
|
||||
|
||||
@site.route('/bookmark/<bookmark_id>/delete', methods=['POST'])
|
||||
def post_bookmark_delete(bookmark_id):
|
||||
bookmark = common.P_bookmark(bookmark_id, response_type='json')
|
||||
bookmark.delete(commit=True)
|
||||
return flasktools.make_json_response({})
|
||||
return flasktools.json_response({})
|
||||
|
|
|
@ -27,7 +27,7 @@ def get_photo_html(photo_id):
|
|||
def get_photo_json(photo_id):
|
||||
photo = common.P_photo(photo_id, response_type='json')
|
||||
photo = photo.jsonify()
|
||||
photo = flasktools.make_json_response(photo)
|
||||
photo = flasktools.json_response(photo)
|
||||
return photo
|
||||
|
||||
@site.route('/file/<photo_id>')
|
||||
|
@ -75,7 +75,7 @@ def post_photo_delete(photo_id):
|
|||
delete_file = request.form.get('delete_file', False)
|
||||
delete_file = stringtools.truthystring(delete_file)
|
||||
photo.delete(delete_file=delete_file, commit=True)
|
||||
return flasktools.make_json_response({})
|
||||
return flasktools.json_response({})
|
||||
|
||||
# Photo tag operations #############################################################################
|
||||
|
||||
|
@ -94,7 +94,7 @@ def post_photo_add_remove_tag_core(photo_ids, tagname, add_or_remove):
|
|||
common.P.commit('photo add remove tag core')
|
||||
|
||||
response = {'action': add_or_remove, 'tagname': tag.name}
|
||||
return flasktools.make_json_response(response)
|
||||
return flasktools.json_response(response)
|
||||
|
||||
@site.route('/photo/<photo_id>/add_tag', methods=['POST'])
|
||||
@flasktools.required_fields(['tagname'], forbid_whitespace=True)
|
||||
|
@ -119,7 +119,7 @@ def post_photo_copy_tags(photo_id):
|
|||
other = common.P_photo(request.form['other_photo'], response_type='json')
|
||||
photo.copy_tags(other)
|
||||
common.P.commit('photo copy tags')
|
||||
return flasktools.make_json_response([tag.jsonify(minimal=True) for tag in photo.get_tags()])
|
||||
return flasktools.json_response([tag.jsonify(minimal=True) for tag in photo.get_tags()])
|
||||
|
||||
@site.route('/photo/<photo_id>/remove_tag', methods=['POST'])
|
||||
@flasktools.required_fields(['tagname'], forbid_whitespace=True)
|
||||
|
@ -164,7 +164,7 @@ def post_photo_generate_thumbnail(photo_id):
|
|||
photo = common.P_photo(photo_id, response_type='json')
|
||||
photo.generate_thumbnail(commit=True, **special)
|
||||
|
||||
response = flasktools.make_json_response({})
|
||||
response = flasktools.json_response({})
|
||||
return response
|
||||
|
||||
def post_photo_refresh_metadata_core(photo_ids):
|
||||
|
@ -185,7 +185,7 @@ def post_photo_refresh_metadata_core(photo_ids):
|
|||
|
||||
common.P.commit('photo refresh metadata core')
|
||||
|
||||
return flasktools.make_json_response({})
|
||||
return flasktools.json_response({})
|
||||
|
||||
@site.route('/photo/<photo_id>/refresh_metadata', methods=['POST'])
|
||||
def post_photo_refresh_metadata(photo_id):
|
||||
|
@ -202,13 +202,13 @@ def post_batch_photos_refresh_metadata():
|
|||
def post_photo_set_searchhidden(photo_id):
|
||||
photo = common.P_photo(photo_id, response_type='json')
|
||||
photo.set_searchhidden(True)
|
||||
return flasktools.make_json_response({})
|
||||
return flasktools.json_response({})
|
||||
|
||||
@site.route('/photo/<photo_id>/unset_searchhidden', methods=['POST'])
|
||||
def post_photo_unset_searchhidden(photo_id):
|
||||
photo = common.P_photo(photo_id, response_type='json')
|
||||
photo.set_searchhidden(False)
|
||||
return flasktools.make_json_response({})
|
||||
return flasktools.json_response({})
|
||||
|
||||
def post_batch_photos_searchhidden_core(photo_ids, searchhidden):
|
||||
if isinstance(photo_ids, str):
|
||||
|
@ -221,7 +221,7 @@ def post_batch_photos_searchhidden_core(photo_ids, searchhidden):
|
|||
|
||||
common.P.commit('photo set searchhidden core')
|
||||
|
||||
return flasktools.make_json_response({})
|
||||
return flasktools.json_response({})
|
||||
|
||||
@site.route('/photo/<photo_id>/show_in_folder', methods=['POST'])
|
||||
def post_photo_show_in_folder(photo_id):
|
||||
|
@ -232,7 +232,7 @@ def post_photo_show_in_folder(photo_id):
|
|||
if os.name == 'nt':
|
||||
command = f'start explorer.exe /select,"{photo.real_path.absolute_path}"'
|
||||
os.system(command)
|
||||
return flasktools.make_json_response({})
|
||||
return flasktools.json_response({})
|
||||
|
||||
flask.abort(501)
|
||||
|
||||
|
@ -268,7 +268,7 @@ def post_batch_photos():
|
|||
photos = list(common.P_photos(photo_ids, response_type='json'))
|
||||
|
||||
photos = [photo.jsonify() for photo in photos]
|
||||
response = flasktools.make_json_response(photos)
|
||||
response = flasktools.json_response(photos)
|
||||
return response
|
||||
|
||||
@site.route('/batch/photos/photo_card', methods=['POST'])
|
||||
|
@ -294,7 +294,7 @@ def post_batch_photos_photo_cards():
|
|||
divs = [div for div in divs if div]
|
||||
divs = [div.split(':', 1) for div in divs]
|
||||
divs = {photo_id.strip(): photo_card.strip() for (photo_id, photo_card) in divs}
|
||||
response = flasktools.make_json_response(divs)
|
||||
response = flasktools.json_response(divs)
|
||||
return response
|
||||
|
||||
# Zipping ##########################################################################################
|
||||
|
@ -347,7 +347,7 @@ def post_batch_photos_download_zip():
|
|||
photo_download_zip_tokens[zip_token] = photo_ids
|
||||
|
||||
response = {'zip_token': zip_token}
|
||||
response = flasktools.make_json_response(response)
|
||||
response = flasktools.json_response(response)
|
||||
return response
|
||||
|
||||
# Search ###########################################################################################
|
||||
|
@ -547,7 +547,7 @@ def get_search_json():
|
|||
search_results['total_tags'] = [
|
||||
tag.jsonify(minimal=True) for tag in search_results['total_tags']
|
||||
]
|
||||
return flasktools.make_json_response(search_results)
|
||||
return flasktools.json_response(search_results)
|
||||
|
||||
# Swipe ############################################################################################
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ def get_tag_json(specific_tag_name):
|
|||
include_synonyms = include_synonyms is None or stringtools.truthystring(include_synonyms)
|
||||
|
||||
response = specific_tag.jsonify(include_synonyms=include_synonyms)
|
||||
return flasktools.make_json_response(response)
|
||||
return flasktools.json_response(response)
|
||||
|
||||
@site.route('/tag/<tagname>/edit', methods=['POST'])
|
||||
def post_tag_edit(tagname):
|
||||
|
@ -53,7 +53,7 @@ def post_tag_edit(tagname):
|
|||
tag.edit(description=description, commit=True)
|
||||
|
||||
response = tag.jsonify()
|
||||
response = flasktools.make_json_response(response)
|
||||
response = flasktools.json_response(response)
|
||||
return response
|
||||
|
||||
@site.route('/tag/<tagname>/add_child', methods=['POST'])
|
||||
|
@ -63,7 +63,7 @@ def post_tag_add_child(tagname):
|
|||
child = common.P_tag(request.form['child_name'], response_type='json')
|
||||
parent.add_child(child, commit=True)
|
||||
response = {'action': 'add_child', 'tagname': f'{parent.name}.{child.name}'}
|
||||
return flasktools.make_json_response(response)
|
||||
return flasktools.json_response(response)
|
||||
|
||||
@site.route('/tag/<tagname>/add_synonym', methods=['POST'])
|
||||
@flasktools.required_fields(['syn_name'], forbid_whitespace=True)
|
||||
|
@ -74,7 +74,7 @@ def post_tag_add_synonym(tagname):
|
|||
syn_name = master_tag.add_synonym(syn_name, commit=True)
|
||||
|
||||
response = {'action': 'add_synonym', 'synonym': syn_name}
|
||||
return flasktools.make_json_response(response)
|
||||
return flasktools.json_response(response)
|
||||
|
||||
@site.route('/tag/<tagname>/remove_child', methods=['POST'])
|
||||
@flasktools.required_fields(['child_name'], forbid_whitespace=True)
|
||||
|
@ -83,7 +83,7 @@ def post_tag_remove_child(tagname):
|
|||
child = common.P_tag(request.form['child_name'], response_type='json')
|
||||
parent.remove_child(child, commit=True)
|
||||
response = {'action': 'remove_child', 'tagname': f'{parent.name}.{child.name}'}
|
||||
return flasktools.make_json_response(response)
|
||||
return flasktools.json_response(response)
|
||||
|
||||
@site.route('/tag/<tagname>/remove_synonym', methods=['POST'])
|
||||
@flasktools.required_fields(['syn_name'], forbid_whitespace=True)
|
||||
|
@ -94,7 +94,7 @@ def post_tag_remove_synonym(tagname):
|
|||
syn_name = master_tag.remove_synonym(syn_name, commit=True)
|
||||
|
||||
response = {'action': 'delete_synonym', 'synonym': syn_name}
|
||||
return flasktools.make_json_response(response)
|
||||
return flasktools.json_response(response)
|
||||
|
||||
# Tag listings #####################################################################################
|
||||
|
||||
|
@ -104,7 +104,7 @@ def get_all_tag_names():
|
|||
all_tags = list(common.P.get_all_tag_names())
|
||||
all_synonyms = common.P.get_all_synonyms()
|
||||
response = {'tags': all_tags, 'synonyms': all_synonyms}
|
||||
return flasktools.make_json_response(response)
|
||||
return flasktools.json_response(response)
|
||||
|
||||
@site.route('/tag/<specific_tag_name>')
|
||||
@site.route('/tags')
|
||||
|
@ -153,7 +153,7 @@ def get_tags_json():
|
|||
tags = list(common.P.get_tags())
|
||||
response = [tag.jsonify(include_synonyms=include_synonyms) for tag in tags]
|
||||
|
||||
return flasktools.make_json_response(response)
|
||||
return flasktools.json_response(response)
|
||||
|
||||
# Tag create and delete ############################################################################
|
||||
|
||||
|
@ -165,7 +165,7 @@ def post_tag_create():
|
|||
|
||||
tag = common.P.new_tag(name, description, author=session_manager.get(request).user, commit=True)
|
||||
response = tag.jsonify()
|
||||
return flasktools.make_json_response(response)
|
||||
return flasktools.json_response(response)
|
||||
|
||||
@site.route('/tags/easybake', methods=['POST'])
|
||||
@flasktools.required_fields(['easybake_string'], forbid_whitespace=True)
|
||||
|
@ -174,11 +174,11 @@ def post_tag_easybake():
|
|||
|
||||
notes = common.P.easybake(easybake_string, author=session_manager.get(request).user, commit=True)
|
||||
notes = [{'action': action, 'tagname': tagname} for (action, tagname) in notes]
|
||||
return flasktools.make_json_response(notes)
|
||||
return flasktools.json_response(notes)
|
||||
|
||||
@site.route('/tag/<tagname>/delete', methods=['POST'])
|
||||
def post_tag_delete(tagname):
|
||||
tag = common.P_tag(tagname, response_type='json')
|
||||
tag.delete(commit=True)
|
||||
response = {'action': 'delete_tag', 'tagname': tag.name}
|
||||
return flasktools.make_json_response(response)
|
||||
return flasktools.json_response(response)
|
||||
|
|
|
@ -21,7 +21,7 @@ def get_user_html(username):
|
|||
def get_user_json(username):
|
||||
user = common.P_user(username, response_type='json')
|
||||
user = user.jsonify()
|
||||
return flasktools.make_json_response(user)
|
||||
return flasktools.json_response(user)
|
||||
|
||||
@site.route('/userid/<user_id>')
|
||||
@site.route('/userid/<user_id>.json')
|
||||
|
@ -40,10 +40,10 @@ def post_user_edit(username):
|
|||
session = session_manager.get(request)
|
||||
|
||||
if not session:
|
||||
return flasktools.make_json_response(etiquette.exceptions.Unauthorized().jsonify(), status=403)
|
||||
return flasktools.json_response(etiquette.exceptions.Unauthorized().jsonify(), status=403)
|
||||
user = common.P_user(username, response_type='json')
|
||||
if session.user != user:
|
||||
return flasktools.make_json_response(etiquette.exceptions.Unauthorized().jsonify(), status=403)
|
||||
return flasktools.json_response(etiquette.exceptions.Unauthorized().jsonify(), status=403)
|
||||
|
||||
display_name = request.form.get('display_name')
|
||||
if display_name is not None:
|
||||
|
@ -51,7 +51,7 @@ def post_user_edit(username):
|
|||
|
||||
common.P.commit()
|
||||
|
||||
return flasktools.make_json_response(user.jsonify())
|
||||
return flasktools.json_response(user.jsonify())
|
||||
|
||||
# Login and logout #################################################################################
|
||||
|
||||
|
@ -72,7 +72,7 @@ def post_login():
|
|||
if session.user:
|
||||
exc = etiquette.exceptions.AlreadySignedIn()
|
||||
response = exc.jsonify()
|
||||
return flasktools.make_json_response(response, status=403)
|
||||
return flasktools.json_response(response, status=403)
|
||||
|
||||
username = request.form['username']
|
||||
password = request.form['password']
|
||||
|
@ -85,18 +85,18 @@ def post_login():
|
|||
except (etiquette.exceptions.NoSuchUser, etiquette.exceptions.WrongLogin):
|
||||
exc = etiquette.exceptions.WrongLogin()
|
||||
response = exc.jsonify()
|
||||
return flasktools.make_json_response(response, status=422)
|
||||
return flasktools.json_response(response, status=422)
|
||||
except etiquette.exceptions.FeatureDisabled as exc:
|
||||
response = exc.jsonify()
|
||||
return flasktools.make_json_response(response, status=400)
|
||||
return flasktools.json_response(response, status=400)
|
||||
session = sessions.Session(request, user)
|
||||
session_manager.add(session)
|
||||
return flasktools.make_json_response({})
|
||||
return flasktools.json_response({})
|
||||
|
||||
@site.route('/logout', methods=['POST'])
|
||||
def logout():
|
||||
session_manager.remove(request)
|
||||
response = flasktools.make_json_response({})
|
||||
response = flasktools.json_response({})
|
||||
return response
|
||||
|
||||
# User registration ################################################################################
|
||||
|
@ -112,7 +112,7 @@ def post_register():
|
|||
if session.user:
|
||||
exc = etiquette.exceptions.AlreadySignedIn()
|
||||
response = exc.jsonify()
|
||||
return flasktools.make_json_response(response, status=403)
|
||||
return flasktools.json_response(response, status=403)
|
||||
|
||||
username = request.form['username']
|
||||
display_name = request.form.get('display_name', None)
|
||||
|
@ -124,10 +124,10 @@ def post_register():
|
|||
'error_type': 'PASSWORDS_DONT_MATCH',
|
||||
'error_message': 'Passwords do not match.',
|
||||
}
|
||||
return flasktools.make_json_response(response, status=422)
|
||||
return flasktools.json_response(response, status=422)
|
||||
|
||||
user = common.P.new_user(username, password_1, display_name=display_name, commit=True)
|
||||
|
||||
session = sessions.Session(request, user)
|
||||
session_manager.add(session)
|
||||
return flasktools.make_json_response({})
|
||||
return flasktools.json_response({})
|
||||
|
|
Loading…
Reference in a new issue