From da8dff6f855816400023a02455e51508400527e2 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Wed, 20 Jan 2021 17:03:52 -0800 Subject: [PATCH] Add /album/set_thumbnail_photo endpoint. --- .../etiquette_flask/backend/endpoints/album_endpoints.py | 9 +++++++++ frontends/etiquette_flask/static/js/api.js | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/frontends/etiquette_flask/backend/endpoints/album_endpoints.py b/frontends/etiquette_flask/backend/endpoints/album_endpoints.py index 3181ffb..3b5c6ea 100644 --- a/frontends/etiquette_flask/backend/endpoints/album_endpoints.py +++ b/frontends/etiquette_flask/backend/endpoints/album_endpoints.py @@ -89,6 +89,15 @@ def post_album_refresh_directories(album_id): common.P.commit(message='refresh album directories endpoint') return jsonify.make_json_response({}) +@site.route('/album//set_thumbnail_photo', methods=['POST']) +@decorators.required_fields(['photo_id'], forbid_whitespace=True) +def post_album_set_thumbnail_photo(album_id): + album = common.P_album(album_id, response_type='json') + 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 jsonify.make_json_response(album.jsonify()) + # Album photo operations ########################################################################### @site.route('/album//add_photo', methods=['POST']) diff --git a/frontends/etiquette_flask/static/js/api.js b/frontends/etiquette_flask/static/js/api.js index 9497a1e..67fb213 100644 --- a/frontends/etiquette_flask/static/js/api.js +++ b/frontends/etiquette_flask/static/js/api.js @@ -100,6 +100,15 @@ function remove_photos(album_id, photo_ids, callback) api.albums._add_remove_photos(album_id, photo_ids, "remove", callback); } +api.albums.set_thumbnail_photo = +function set_thumbnail_photo(album_id, photo_id, callback) +{ + const url = `/album/${album_id}/set_thumbnail_photo`; + const data = new FormData(); + data.append("photo_id", photo_id); + common.post(url, data, callback); +} + api.albums.callback_follow = function callback_follow(response) {