Add /bookmark/id/edit and /bookmark/id.json endpoints.

This commit is contained in:
voussoir 2017-07-13 23:02:57 -07:00
parent 1784e584e2
commit 22c0163f5b

View file

@ -106,6 +106,10 @@ def P_wrapper(function):
def P_album(albumid): def P_album(albumid):
return P.get_album(albumid) return P.get_album(albumid)
@P_wrapper
def P_bookmark(bookmarkid):
return P.get_bookmark(bookmarkid)
@P_wrapper @P_wrapper
def P_photo(photoid): def P_photo(photoid):
return P.get_photo(photoid) return P.get_photo(photoid)
@ -535,6 +539,26 @@ def post_albums_create():
return jsonify.make_json_response(response) return jsonify.make_json_response(response)
@site.route('/bookmark/<bookmarkid>.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/<bookmarkid>/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') @site.route('/bookmarks')
@session_manager.give_token @session_manager.give_token
def get_bookmarks_html(): def get_bookmarks_html():