add bookmarks view
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from flask import Blueprint, render_template, request, url_for
|
||||
from ..auth import get_active_user, is_logged_in, hard_login_required
|
||||
from ..models import BookmarkCollections, BookmarkedPosts, BookmarkedThreads
|
||||
from ..models import BookmarkCollections, BookmarkedPosts, BookmarkedThreads, Threads, Posts
|
||||
from functools import wraps
|
||||
|
||||
bp = Blueprint('hyperapi', __name__, url_prefix='/hyperapi/')
|
||||
@@ -24,6 +24,14 @@ def get_bookmark_dropdown():
|
||||
except ValueError:
|
||||
return 'error', 400
|
||||
is_thread = concept_kind == 'thread'
|
||||
if is_thread:
|
||||
target_thread = Threads.find({'id': concept_id})
|
||||
if not target_thread:
|
||||
return 'This thread no longer exists. Please refresh the page.', 404
|
||||
else:
|
||||
target_post = Posts.find({'id': concept_id})
|
||||
if not target_post:
|
||||
return 'This post no longer exists. Please refresh the page.', 404
|
||||
collections = BookmarkCollections.get_for_user(user.id)
|
||||
in_collection = None
|
||||
note = ''
|
||||
@@ -54,6 +62,9 @@ def bookmark_thread():
|
||||
bt.delete()
|
||||
return '', 204
|
||||
|
||||
if not Threads.find({'id': thread_id}):
|
||||
return 'error', 404
|
||||
|
||||
target_collection = BookmarkCollections.find({'id': target_collection_id})
|
||||
note = request.form.get('note', '')
|
||||
if not target_collection:
|
||||
@@ -91,6 +102,9 @@ def bookmark_post():
|
||||
bp.delete()
|
||||
return '', 204
|
||||
|
||||
if not Posts.find({'id': post_id}):
|
||||
return 'error', 404
|
||||
|
||||
target_collection = BookmarkCollections.find({'id': target_collection_id})
|
||||
note = request.form.get('note', '')
|
||||
if not target_collection:
|
||||
|
||||
Reference in New Issue
Block a user