Reorganize bookmark create and delete endpoints.
This commit is contained in:
parent
8a1d5d9eae
commit
c927653222
1 changed files with 21 additions and 20 deletions
|
@ -12,18 +12,6 @@ session_manager = common.session_manager
|
||||||
|
|
||||||
# Individual bookmarks #############################################################################
|
# Individual bookmarks #############################################################################
|
||||||
|
|
||||||
@site.route('/bookmarks/create_bookmark', methods=['POST'])
|
|
||||||
@decorators.catch_etiquette_exception
|
|
||||||
@decorators.required_fields(['url'], forbid_whitespace=True)
|
|
||||||
def post_bookmark_create():
|
|
||||||
url = request.form['url']
|
|
||||||
title = request.form.get('title', None)
|
|
||||||
user = session_manager.get(request).user
|
|
||||||
bookmark = common.P.new_bookmark(url=url, title=title, author=user)
|
|
||||||
response = etiquette.jsonify.bookmark(bookmark)
|
|
||||||
response = jsonify.make_json_response(response)
|
|
||||||
return response
|
|
||||||
|
|
||||||
@site.route('/bookmark/<bookmark_id>.json')
|
@site.route('/bookmark/<bookmark_id>.json')
|
||||||
@session_manager.give_token
|
@session_manager.give_token
|
||||||
def get_bookmark_json(bookmark_id):
|
def get_bookmark_json(bookmark_id):
|
||||||
|
@ -45,14 +33,6 @@ def post_bookmark_edit(bookmark_id):
|
||||||
response = jsonify.make_json_response(response)
|
response = jsonify.make_json_response(response)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
@site.route('/bookmark/<bookmark_id>/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({})
|
|
||||||
|
|
||||||
|
|
||||||
# Bookmark listings ################################################################################
|
# Bookmark listings ################################################################################
|
||||||
|
|
||||||
@site.route('/bookmarks')
|
@site.route('/bookmarks')
|
||||||
|
@ -67,3 +47,24 @@ def get_bookmarks_html():
|
||||||
def get_bookmarks_json():
|
def get_bookmarks_json():
|
||||||
bookmarks = [etiquette.jsonify.bookmark(b) for b in common.P.get_bookmarks()]
|
bookmarks = [etiquette.jsonify.bookmark(b) for b in common.P.get_bookmarks()]
|
||||||
return jsonify.make_json_response(bookmarks)
|
return jsonify.make_json_response(bookmarks)
|
||||||
|
|
||||||
|
# Bookmark create and delete #######################################################################
|
||||||
|
|
||||||
|
@site.route('/bookmarks/create_bookmark', methods=['POST'])
|
||||||
|
@decorators.catch_etiquette_exception
|
||||||
|
@decorators.required_fields(['url'], forbid_whitespace=True)
|
||||||
|
def post_bookmark_create():
|
||||||
|
url = request.form['url']
|
||||||
|
title = request.form.get('title', None)
|
||||||
|
user = session_manager.get(request).user
|
||||||
|
bookmark = common.P.new_bookmark(url=url, title=title, author=user)
|
||||||
|
response = etiquette.jsonify.bookmark(bookmark)
|
||||||
|
response = jsonify.make_json_response(response)
|
||||||
|
return response
|
||||||
|
|
||||||
|
@site.route('/bookmark/<bookmark_id>/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({})
|
||||||
|
|
Loading…
Reference in a new issue