From 8d2af3255b342e02243a547565a0e34987f3d4e8 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Wed, 9 Sep 2020 20:51:15 -0700 Subject: [PATCH] Add endpoints set_searchhidden, unset_searchhidden and checkbox. --- .../backend/endpoints/photo_endpoints.py | 14 ++++++++++++++ frontends/etiquette_flask/static/js/api.js | 14 ++++++++++++++ .../etiquette_flask/templates/photo.html | 19 +++++++++++++++++++ 3 files changed, 47 insertions(+) diff --git a/frontends/etiquette_flask/backend/endpoints/photo_endpoints.py b/frontends/etiquette_flask/backend/endpoints/photo_endpoints.py index f3da4a4..38eba42 100644 --- a/frontends/etiquette_flask/backend/endpoints/photo_endpoints.py +++ b/frontends/etiquette_flask/backend/endpoints/photo_endpoints.py @@ -193,6 +193,20 @@ def post_batch_photos_refresh_metadata(): response = post_photo_refresh_metadata_core(photo_ids=request.form['photo_ids']) return response +@decorators.catch_etiquette_exception +@site.route('/photo//set_searchhidden', methods=['POST']) +def post_photo_set_searchhidden(photo_id): + photo = common.P_photo(photo_id, response_type='json') + photo.set_searchhidden(True) + return jsonify.make_json_response({}) + +@decorators.catch_etiquette_exception +@site.route('/photo//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 jsonify.make_json_response({}) + @decorators.catch_etiquette_exception def post_batch_photos_searchhidden_core(photo_ids, searchhidden): if isinstance(photo_ids, str): diff --git a/frontends/etiquette_flask/static/js/api.js b/frontends/etiquette_flask/static/js/api.js index ecad1ca..33018fb 100644 --- a/frontends/etiquette_flask/static/js/api.js +++ b/frontends/etiquette_flask/static/js/api.js @@ -272,6 +272,20 @@ function remove_tag(photo_id, tagname, callback) common.post(url, data, callback); } +api.photos.set_searchhidden = +function set_searchhidden(photo_id, callback) +{ + const url = `/photo/${photo_id}/set_searchhidden`; + common.post(url, null, callback); +} + +api.photos.unset_searchhidden = +function unset_searchhidden(photo_id, callback) +{ + const url = `/photo/${photo_id}/unset_searchhidden`; + common.post(url, null, callback); +} + api.photos.callback_go_to_search = function callback_go_to_albums(response) { diff --git a/frontends/etiquette_flask/templates/photo.html b/frontends/etiquette_flask/templates/photo.html index 3662eba..8330fd7 100644 --- a/frontends/etiquette_flask/templates/photo.html +++ b/frontends/etiquette_flask/templates/photo.html @@ -195,6 +195,12 @@
  • Download as original filename
  • Download as {{photo.id}}.{{photo.extension}}
  • +
  • + +