From 22c0163f5b8c0bb9a98680e7b4ae983e8c6777dc Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Thu, 13 Jul 2017 23:02:57 -0700 Subject: [PATCH] Add /bookmark/id/edit and /bookmark/id.json endpoints. --- .../etiquette_flask/etiquette_flask.py | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/frontends/etiquette_flask/etiquette_flask/etiquette_flask.py b/frontends/etiquette_flask/etiquette_flask/etiquette_flask.py index 8fac449..80cafcc 100644 --- a/frontends/etiquette_flask/etiquette_flask/etiquette_flask.py +++ b/frontends/etiquette_flask/etiquette_flask/etiquette_flask.py @@ -106,6 +106,10 @@ def P_wrapper(function): def P_album(albumid): return P.get_album(albumid) +@P_wrapper +def P_bookmark(bookmarkid): + return P.get_bookmark(bookmarkid) + @P_wrapper def P_photo(photoid): return P.get_photo(photoid) @@ -535,6 +539,26 @@ def post_albums_create(): return jsonify.make_json_response(response) +@site.route('/bookmark/.json') +@session_manager.give_token +def get_bookmark_json(bookmarkid): + bookmark = P_bookmark(bookmarkid) + response = etiquette.jsonify.bookmark(bookmark) + return jsonify.make_json_response(response) + +@site.route('/bookmark//edit', methods=['POST']) +@session_manager.give_token +def post_bookmark_edit(bookmarkid): + bookmark = P_bookmark(bookmarkid) + # Emptystring is okay for titles, but not for URL. + title = request.form.get('title', None) + url = request.form.get('url', None) or None + bookmark.edit(title=title, url=url) + + response = etiquette.jsonify.bookmark(bookmark) + response = jsonify.make_json_response(response) + return response + @site.route('/bookmarks') @session_manager.give_token def get_bookmarks_html():