aboutsummaryrefslogtreecommitdiff
path: root/src/web/views
diff options
context:
space:
mode:
Diffstat (limited to 'src/web/views')
-rw-r--r--src/web/views/__init__.py3
-rw-r--r--src/web/views/bookmark.py80
2 files changed, 1 insertions, 82 deletions
diff --git a/src/web/views/__init__.py b/src/web/views/__init__.py
index 41bb52f3..e0e49927 100644
--- a/src/web/views/__init__.py
+++ b/src/web/views/__init__.py
@@ -6,12 +6,11 @@ from web.views.category import category_bp, categories_bp
from web.views.icon import icon_bp
from web.views.admin import admin_bp
from web.views.user import user_bp, users_bp
-from web.views.bookmark import bookmark_bp, bookmarks_bp
__all__ = ['views', 'home', 'session_mgmt', 'v2', 'v3',
'article_bp', 'articles_bp', 'feed_bp', 'feeds_bp',
'category_bp', 'categories_bp', 'icon_bp',
- 'admin_bp', 'user_bp', 'users_bp', 'bookmark_bp', 'bookmarks_bp']
+ 'admin_bp', 'user_bp', 'users_bp']
import conf
from flask import request
diff --git a/src/web/views/bookmark.py b/src/web/views/bookmark.py
deleted file mode 100644
index c2fdc597..00000000
--- a/src/web/views/bookmark.py
+++ /dev/null
@@ -1,80 +0,0 @@
-import logging
-from werkzeug.exceptions import BadRequest
-
-from flask import Blueprint, render_template, flash, \
- redirect, request, url_for
-from flask_babel import gettext
-from flask_login import login_required, current_user
-
-import conf
-from bootstrap import db
-from web.forms import BookmarkForm
-from web.controllers import BookmarkController
-from web.models.tag import BookmarkTag
-
-logger = logging.getLogger(__name__)
-bookmarks_bp = Blueprint('bookmarks', __name__, url_prefix='/bookmarks')
-bookmark_bp = Blueprint('bookmark', __name__, url_prefix='/bookmark')
-
-
-@bookmarks_bp.route('/', methods=['GET'])
-@login_required
-def list():
- "Lists the bookmarks."
- bookmark_contr = BookmarkController(current_user.id)
- return render_template('bookmarks.html',
- bookmarks=BookmarkController(current_user.id).read().order_by('time'))
-
-
-@bookmark_bp.route('/create', methods=['GET'])
-@bookmark_bp.route('/edit/<int:bookmark_id>', methods=['GET'])
-@login_required
-def form(bookmark_id=None):
- action = gettext("Add a bookmark")
- head_titles = [action]
- if bookmark_id is None:
- return render_template('edit_bookmark.html', action=action,
- head_titles=head_titles, form=BookmarkForm())
- bookmark = BookmarkController(current_user.id).get(id=bookmark_id)
- action = gettext('Edit bookmark')
- head_titles = [action]
- form = BookmarkForm(obj=bookmark)
- form.tags.data = bookmark.tags
- return render_template('edit_bookmark.html', action=action,
- head_titles=head_titles, bookmark=bookmark,
- form=form)
-
-
-@bookmark_bp.route('/create', methods=['POST'])
-@bookmark_bp.route('/edit/<int:bookmark_id>', methods=['POST'])
-@login_required
-def process_form(bookmark_id=None):
- form = BookmarkForm()
- bookmark_contr = BookmarkController(current_user.id)
-
- if not form.validate():
- return render_template('edit_bookmark.html', form=form)
-
- # Edit an existing bookmark
- bookmark_attr = {'href': form.href.data,
- 'description': form.description.data,
- 'title': form.title.data,
- 'tags': [tag.strip() for tag in form.tags.data.split(',')],
- 'shared': form.shared.data,
- 'to_read': form.to_read.data}
-
- if bookmark_id is not None:
- # bookmark = BookmarkController(current_user.id).get(id=bookmark_id)
- # form.populate_obj(bookmark)
- # bookmark.tags = [tag.strip() for tag in form.tags.data.split(',')],
- # db.session.commit()
- bookmark_contr.update({'id': bookmark_id}, bookmark_attr)
- flash(gettext('Bookmark successfully updated.'), 'success')
- return redirect(url_for('bookmark.form', bookmark_id=bookmark_id))
-
- # Create a new bookmark
- new_bookmark = bookmark_contr.create(**bookmark_attr)
-
- flash(gettext('Bookmark successfully created.'), 'success')
-
- return redirect(url_for('bookmark.form', bookmark_id=new_bookmark.id))
bgstack15