From fd23b563cf3fd5dd282bfbbf9d9bd823fdd6bfe8 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sun, 29 Jul 2018 00:36:50 -0700 Subject: [PATCH] Implement bookmark delete on frontend. --- .../endpoints/bookmark_endpoints.py | 7 +++++++ .../etiquette_flask/templates/bookmarks.html | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/frontends/etiquette_flask/etiquette_flask/endpoints/bookmark_endpoints.py b/frontends/etiquette_flask/etiquette_flask/endpoints/bookmark_endpoints.py index b21af79..4ec40c7 100644 --- a/frontends/etiquette_flask/etiquette_flask/endpoints/bookmark_endpoints.py +++ b/frontends/etiquette_flask/etiquette_flask/endpoints/bookmark_endpoints.py @@ -63,3 +63,10 @@ def post_bookmarks_create(): response = etiquette.jsonify.bookmark(bookmark) response = jsonify.make_json_response(response) return response + +@site.route('/bookmark//delete', methods=['POST']) +@decorators.catch_etiquette_exception +def post_bookmark_delete(bookmark_id): + bookmark = common.P_bookmark(bookmark_id, response_type='json') + bookmark.delete() + return jsonify.make_json_response({}) diff --git a/frontends/etiquette_flask/templates/bookmarks.html b/frontends/etiquette_flask/templates/bookmarks.html index e6d785e..b5b9517 100644 --- a/frontends/etiquette_flask/templates/bookmarks.html +++ b/frontends/etiquette_flask/templates/bookmarks.html @@ -70,8 +70,19 @@ > {{-bookmark.url-}} + + {% endfor %} +
@@ -107,6 +118,13 @@ function create_bookmark(url, title) common.post(api_url, data, callback); } +function delete_bookmark(bookmark_id) +{ + var url = `/bookmark/${bookmark_id}/delete` + var callback = function(){location.reload();}; + common.post(url, null, callback); +} + function on_open(ed, edit_element_map) {