diff --git a/frontends/etiquette_flask/backend/endpoints/photo_endpoints.py b/frontends/etiquette_flask/backend/endpoints/photo_endpoints.py index 3d921d2..046b305 100644 --- a/frontends/etiquette_flask/backend/endpoints/photo_endpoints.py +++ b/frontends/etiquette_flask/backend/endpoints/photo_endpoints.py @@ -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//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 diff --git a/frontends/etiquette_flask/static/js/api.js b/frontends/etiquette_flask/static/js/api.js index aa8fa8a..8d06f49 100644 --- a/frontends/etiquette_flask/static/js/api.js +++ b/frontends/etiquette_flask/static/js/api.js @@ -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 = {};