Add commit=True to frontend where necessary.
This commit is contained in:
parent
854fa4db51
commit
4a193d228c
5 changed files with 23 additions and 22 deletions
|
@ -63,7 +63,7 @@ def get_album_zip(album_id):
|
||||||
def post_album_add_child(album_id):
|
def post_album_add_child(album_id):
|
||||||
album = common.P_album(album_id)
|
album = common.P_album(album_id)
|
||||||
child = common.P_album(request.form['child_id'])
|
child = common.P_album(request.form['child_id'])
|
||||||
album.add_child(child)
|
album.add_child(child, commit=True)
|
||||||
response = etiquette.jsonify.album(child)
|
response = etiquette.jsonify.album(child)
|
||||||
return jsonify.make_json_response(response)
|
return jsonify.make_json_response(response)
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ def post_album_add_child(album_id):
|
||||||
def post_album_remove_child(album_id):
|
def post_album_remove_child(album_id):
|
||||||
album = common.P_album(album_id)
|
album = common.P_album(album_id)
|
||||||
child = common.P_album(request.form['child_id'])
|
child = common.P_album(request.form['child_id'])
|
||||||
album.remove_child(child)
|
album.remove_child(child, commit=True)
|
||||||
response = etiquette.jsonify.album(child)
|
response = etiquette.jsonify.album(child)
|
||||||
return jsonify.make_json_response(response)
|
return jsonify.make_json_response(response)
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ def post_album_add_photo(album_id):
|
||||||
|
|
||||||
photo_ids = etiquette.helpers.comma_space_split(request.form['photo_id'])
|
photo_ids = etiquette.helpers.comma_space_split(request.form['photo_id'])
|
||||||
photos = list(common.P_photos(photo_ids))
|
photos = list(common.P_photos(photo_ids))
|
||||||
album.add_photos(photos)
|
album.add_photos(photos, commit=True)
|
||||||
return jsonify.make_json_response(response)
|
return jsonify.make_json_response(response)
|
||||||
|
|
||||||
@site.route('/album/<album_id>/remove_photo', methods=['POST'])
|
@site.route('/album/<album_id>/remove_photo', methods=['POST'])
|
||||||
|
@ -117,7 +117,7 @@ def post_album_remove_photo(album_id):
|
||||||
|
|
||||||
photo_ids = etiquette.helpers.comma_space_split(request.form['photo_id'])
|
photo_ids = etiquette.helpers.comma_space_split(request.form['photo_id'])
|
||||||
photos = list(common.P_photos(photo_ids))
|
photos = list(common.P_photos(photo_ids))
|
||||||
album.remove_photos(photos)
|
album.remove_photos(photos, commit=True)
|
||||||
return jsonify.make_json_response(response)
|
return jsonify.make_json_response(response)
|
||||||
|
|
||||||
# Album tag operations #############################################################################
|
# Album tag operations #############################################################################
|
||||||
|
@ -140,7 +140,7 @@ def post_album_add_tag(album_id):
|
||||||
return jsonify.make_json_response(response, status=404)
|
return jsonify.make_json_response(response, status=404)
|
||||||
recursive = request.form.get('recursive', False)
|
recursive = request.form.get('recursive', False)
|
||||||
recursive = etiquette.helpers.truthystring(recursive)
|
recursive = etiquette.helpers.truthystring(recursive)
|
||||||
album.add_tag_to_all(tag, nested_children=recursive)
|
album.add_tag_to_all(tag, nested_children=recursive, commit=True)
|
||||||
response['action'] = 'add_tag'
|
response['action'] = 'add_tag'
|
||||||
response['tagname'] = tag.name
|
response['tagname'] = tag.name
|
||||||
return jsonify.make_json_response(response)
|
return jsonify.make_json_response(response)
|
||||||
|
@ -158,7 +158,7 @@ def post_album_edit(album_id):
|
||||||
|
|
||||||
title = request.form.get('title', None)
|
title = request.form.get('title', None)
|
||||||
description = request.form.get('description', None)
|
description = request.form.get('description', None)
|
||||||
album.edit(title=title, description=description)
|
album.edit(title=title, description=description, commit=True)
|
||||||
response = etiquette.jsonify.album(album, minimal=True)
|
response = etiquette.jsonify.album(album, minimal=True)
|
||||||
return jsonify.make_json_response(response)
|
return jsonify.make_json_response(response)
|
||||||
|
|
||||||
|
@ -205,6 +205,7 @@ def post_albums_create():
|
||||||
album = common.P.new_album(title=title, description=description, author=user)
|
album = common.P.new_album(title=title, description=description, author=user)
|
||||||
if parent_id is not None:
|
if parent_id is not None:
|
||||||
parent.add_child(album)
|
parent.add_child(album)
|
||||||
|
common.P.commit('create album endpoint')
|
||||||
|
|
||||||
response = etiquette.jsonify.album(album, minimal=False)
|
response = etiquette.jsonify.album(album, minimal=False)
|
||||||
return jsonify.make_json_response(response)
|
return jsonify.make_json_response(response)
|
||||||
|
@ -214,5 +215,5 @@ def post_albums_create():
|
||||||
@decorators.catch_etiquette_exception
|
@decorators.catch_etiquette_exception
|
||||||
def post_album_delete(album_id):
|
def post_album_delete(album_id):
|
||||||
album = common.P_album(album_id, response_type='json')
|
album = common.P_album(album_id, response_type='json')
|
||||||
album.delete()
|
album.delete(commit=True)
|
||||||
return jsonify.make_json_response({})
|
return jsonify.make_json_response({})
|
||||||
|
|
|
@ -27,7 +27,7 @@ def post_bookmark_edit(bookmark_id):
|
||||||
# Emptystring is okay for titles, but not for URL.
|
# Emptystring is okay for titles, but not for URL.
|
||||||
title = request.form.get('title', None)
|
title = request.form.get('title', None)
|
||||||
url = request.form.get('url', None) or None
|
url = request.form.get('url', None) or None
|
||||||
bookmark.edit(title=title, url=url)
|
bookmark.edit(title=title, url=url, commit=True)
|
||||||
|
|
||||||
response = etiquette.jsonify.bookmark(bookmark)
|
response = etiquette.jsonify.bookmark(bookmark)
|
||||||
response = jsonify.make_json_response(response)
|
response = jsonify.make_json_response(response)
|
||||||
|
@ -56,7 +56,7 @@ def post_bookmark_create():
|
||||||
url = request.form['url']
|
url = request.form['url']
|
||||||
title = request.form.get('title', None)
|
title = request.form.get('title', None)
|
||||||
user = session_manager.get(request).user
|
user = session_manager.get(request).user
|
||||||
bookmark = common.P.new_bookmark(url=url, title=title, author=user)
|
bookmark = common.P.new_bookmark(url=url, title=title, author=user, commit=True)
|
||||||
response = etiquette.jsonify.bookmark(bookmark)
|
response = etiquette.jsonify.bookmark(bookmark)
|
||||||
response = jsonify.make_json_response(response)
|
response = jsonify.make_json_response(response)
|
||||||
return response
|
return response
|
||||||
|
@ -65,5 +65,5 @@ def post_bookmark_create():
|
||||||
@decorators.catch_etiquette_exception
|
@decorators.catch_etiquette_exception
|
||||||
def post_bookmark_delete(bookmark_id):
|
def post_bookmark_delete(bookmark_id):
|
||||||
bookmark = common.P_bookmark(bookmark_id, response_type='json')
|
bookmark = common.P_bookmark(bookmark_id, response_type='json')
|
||||||
bookmark.delete()
|
bookmark.delete(commit=True)
|
||||||
return jsonify.make_json_response({})
|
return jsonify.make_json_response({})
|
||||||
|
|
|
@ -84,7 +84,7 @@ def post_photo_add_remove_tag_core(photo_ids, tagname, add_or_remove):
|
||||||
photo.add_tag(tag)
|
photo.add_tag(tag)
|
||||||
elif add_or_remove == 'remove':
|
elif add_or_remove == 'remove':
|
||||||
photo.remove_tag(tag)
|
photo.remove_tag(tag)
|
||||||
common.P.commit()
|
common.P.commit('photo add remove tag core')
|
||||||
|
|
||||||
response = {'action': add_or_remove, 'tagname': tag.name}
|
response = {'action': add_or_remove, 'tagname': tag.name}
|
||||||
return jsonify.make_json_response(response)
|
return jsonify.make_json_response(response)
|
||||||
|
@ -144,7 +144,7 @@ def post_photo_generate_thumbnail(photo_id):
|
||||||
special.pop('commit', None)
|
special.pop('commit', None)
|
||||||
|
|
||||||
photo = common.P_photo(photo_id, response_type='json')
|
photo = common.P_photo(photo_id, response_type='json')
|
||||||
photo.generate_thumbnail(**special)
|
photo.generate_thumbnail(commit=True, **special)
|
||||||
|
|
||||||
response = jsonify.make_json_response({})
|
response = jsonify.make_json_response({})
|
||||||
return response
|
return response
|
||||||
|
@ -166,7 +166,7 @@ def post_photo_refresh_metadata_core(photo_ids):
|
||||||
except Exception:
|
except Exception:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
common.P.commit()
|
common.P.commit('photo refresh metadata core')
|
||||||
|
|
||||||
return jsonify.make_json_response({})
|
return jsonify.make_json_response({})
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ def post_photo_searchhidden_core(photo_ids, searchhidden):
|
||||||
for photo in photos:
|
for photo in photos:
|
||||||
photo.set_searchhidden(searchhidden)
|
photo.set_searchhidden(searchhidden)
|
||||||
|
|
||||||
common.P.commit()
|
common.P.commit('photo set searchhidden core')
|
||||||
|
|
||||||
return jsonify.make_json_response({})
|
return jsonify.make_json_response({})
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ def post_tag_edit(specific_tag):
|
||||||
tag.rename(name)
|
tag.rename(name)
|
||||||
|
|
||||||
description = request.form.get('description', None)
|
description = request.form.get('description', None)
|
||||||
tag.edit(description=description)
|
tag.edit(description=description, commit=True)
|
||||||
|
|
||||||
response = etiquette.jsonify.tag(tag)
|
response = etiquette.jsonify.tag(tag)
|
||||||
response = jsonify.make_json_response(response)
|
response = jsonify.make_json_response(response)
|
||||||
|
@ -53,7 +53,7 @@ def post_tag_edit(specific_tag):
|
||||||
def post_tag_add_child(tagname):
|
def post_tag_add_child(tagname):
|
||||||
parent = common.P_tag(tagname)
|
parent = common.P_tag(tagname)
|
||||||
child = common.P_tag(request.form['child_name'])
|
child = common.P_tag(request.form['child_name'])
|
||||||
parent.add_child(child)
|
parent.add_child(child, commit=True)
|
||||||
response = {'action': 'add_child', 'tagname': f'{parent.name}.{child.name}'}
|
response = {'action': 'add_child', 'tagname': f'{parent.name}.{child.name}'}
|
||||||
return jsonify.make_json_response(response)
|
return jsonify.make_json_response(response)
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ def post_tag_add_child(tagname):
|
||||||
def post_tag_remove_child(tagname):
|
def post_tag_remove_child(tagname):
|
||||||
parent = common.P_tag(tagname)
|
parent = common.P_tag(tagname)
|
||||||
child = common.P_tag(request.form['child_name'])
|
child = common.P_tag(request.form['child_name'])
|
||||||
parent.remove_child(child)
|
parent.remove_child(child, commit=True)
|
||||||
response = {'action': 'remove_child', 'tagname': f'{parent.name}.{child.name}'}
|
response = {'action': 'remove_child', 'tagname': f'{parent.name}.{child.name}'}
|
||||||
return jsonify.make_json_response(response)
|
return jsonify.make_json_response(response)
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ def post_tag_create():
|
||||||
name = request.form['name']
|
name = request.form['name']
|
||||||
description = request.form.get('description', None)
|
description = request.form.get('description', None)
|
||||||
|
|
||||||
tag = P.new_tag(name, description, author=session_manager.get(request).user)
|
tag = P.new_tag(name, description, author=session_manager.get(request).user, commit=True)
|
||||||
response = etiquette.jsonify.tag(tag)
|
response = etiquette.jsonify.tag(tag)
|
||||||
return jsonify.make_json_response(response)
|
return jsonify.make_json_response(response)
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ def post_tag_create():
|
||||||
def post_tag_easybake():
|
def post_tag_easybake():
|
||||||
easybake_string = request.form['easybake_string']
|
easybake_string = request.form['easybake_string']
|
||||||
|
|
||||||
notes = common.P.easybake(easybake_string, author=session_manager.get(request).user)
|
notes = common.P.easybake(easybake_string, author=session_manager.get(request).user, commit=True)
|
||||||
notes = [{'action': action, 'tagname': tagname} for (action, tagname) in notes]
|
notes = [{'action': action, 'tagname': tagname} for (action, tagname) in notes]
|
||||||
return jsonify.make_json_response(notes)
|
return jsonify.make_json_response(notes)
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ def post_tag_easybake():
|
||||||
@session_manager.give_token
|
@session_manager.give_token
|
||||||
def post_tag_delete(tagname):
|
def post_tag_delete(tagname):
|
||||||
tag = common.P_tag(tagname)
|
tag = common.P_tag(tagname)
|
||||||
tag.delete()
|
tag.delete(commit=True)
|
||||||
response = {'action': 'delete_tag', 'tagname': tag.name}
|
response = {'action': 'delete_tag', 'tagname': tag.name}
|
||||||
return jsonify.make_json_response(response)
|
return jsonify.make_json_response(response)
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ def post_tag_remove_synonym(tagname):
|
||||||
syn_name = request.form['syn_name']
|
syn_name = request.form['syn_name']
|
||||||
|
|
||||||
master_tag = common.P_tag(tagname)
|
master_tag = common.P_tag(tagname)
|
||||||
master_tag.remove_synonym(syn_name)
|
master_tag.remove_synonym(syn_name, commit=True)
|
||||||
|
|
||||||
response = {'action':'delete_synonym', 'synonym': syn_name}
|
response = {'action':'delete_synonym', 'synonym': syn_name}
|
||||||
return jsonify.make_json_response(response)
|
return jsonify.make_json_response(response)
|
||||||
|
|
|
@ -117,7 +117,7 @@ def post_register():
|
||||||
}
|
}
|
||||||
return jsonify.make_json_response(response, status=422)
|
return jsonify.make_json_response(response, status=422)
|
||||||
|
|
||||||
user = common.P.new_user(username, password_1, display_name=display_name)
|
user = common.P.new_user(username, password_1, display_name=display_name, commit=True)
|
||||||
|
|
||||||
session = sessions.Session(request, user)
|
session = sessions.Session(request, user)
|
||||||
session_manager.add(session)
|
session_manager.add(session)
|
||||||
|
|
Loading…
Reference in a new issue