Add endpoint /photo/photo_id/delete.

This commit is contained in:
voussoir 2020-02-26 18:57:29 -08:00
parent a88fcc2092
commit 45cb96cc5c
2 changed files with 35 additions and 0 deletions

View file

@ -68,6 +68,19 @@ def get_thumbnail(photo_id):
flask.abort(404, 'That file doesnt have a thumbnail')
return common.send_file(path)
# Photo create and delete ##########################################################################
@site.route('/photo/<photo_id>/delete', methods=['POST'])
@decorators.catch_etiquette_exception
@session_manager.give_token
def post_photo_delete(photo_id):
print(photo_id)
photo = common.P_photo(photo_id, response_type='json')
delete_file = request.form.get('delete_file', False)
delete_file = etiquette.helpers.truthystring(delete_file)
photo.delete(delete_file=delete_file, commit=True)
return jsonify.make_json_response({})
# Photo tag operations #############################################################################
@decorators.catch_etiquette_exception

View file

@ -165,6 +165,15 @@ function add_tag(photo_id, tagname, callback)
common.post(url, data, callback);
}
api.photos.delete =
function _delete(photo_id, delete_file, callback)
{
var url = `/photo/${photo_id}/delete`;
var data = new FormData();
data.append("delete_file", delete_file);
common.post(url, data, callback);
}
api.photos.generate_thumbnail =
function generate_thumbnail(photo_id, special, callback)
{
@ -193,6 +202,19 @@ function remove_tag(photo_id, tagname, callback)
common.post(url, data, callback);
}
api.photos.callback_go_to_search =
function callback_go_to_albums(response)
{
if (response["meta"]["status"] == 200)
{
window.location.href = "/search";
}
else
{
console.log(response);
}
}
/**************************************************************************************************/
api.tags = {};