diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2017-05-24 00:02:25 +0200 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2017-05-24 00:02:25 +0200 |
commit | 3b7ff7f8c69a2658ed46ca90a6719c031866db6b (patch) | |
tree | b5717c0521bc5ecab0413d7f0eab4488a5eacaa0 | |
parent | Added a link in the main menu to the list of bookmarks. (diff) | |
download | newspipe-3b7ff7f8c69a2658ed46ca90a6719c031866db6b.tar.gz newspipe-3b7ff7f8c69a2658ed46ca90a6719c031866db6b.tar.bz2 newspipe-3b7ff7f8c69a2658ed46ca90a6719c031866db6b.zip |
It is now possible to delete a bookmark.
-rw-r--r-- | src/web/templates/bookmarks.html | 1 | ||||
-rw-r--r-- | src/web/views/bookmark.py | 16 |
2 files changed, 14 insertions, 3 deletions
diff --git a/src/web/templates/bookmarks.html b/src/web/templates/bookmarks.html index 6b727a16..699d7e62 100644 --- a/src/web/templates/bookmarks.html +++ b/src/web/templates/bookmarks.html @@ -13,6 +13,7 @@ <div class="text-muted">{{ bookmark.description }}</div> {{ " ".join(bookmark.tags_proxy) }} <a href="{{ url_for('bookmark.form', bookmark_id=bookmark.id) }}">edit</a> + <a href="{{ url_for('bookmark.delete', bookmark_id=bookmark.id) }}">delete</a> </p> </a> </li> diff --git a/src/web/views/bookmark.py b/src/web/views/bookmark.py index b5666248..70d9bf9a 100644 --- a/src/web/views/bookmark.py +++ b/src/web/views/bookmark.py @@ -7,6 +7,7 @@ from flask_babel import gettext from flask_login import login_required, current_user import conf +from lib.utils import redirect_url from bootstrap import db from web.forms import BookmarkForm from web.controllers import BookmarkController, BookmarkTagController @@ -29,6 +30,7 @@ def list(): @bookmark_bp.route('/edit/<int:bookmark_id>', methods=['GET']) @login_required def form(bookmark_id=None): + "Form to create/edit bookmarks." action = gettext("Add a bookmark") head_titles = [action] if bookmark_id is None: @@ -48,6 +50,7 @@ def form(bookmark_id=None): @bookmark_bp.route('/edit/<int:bookmark_id>', methods=['POST']) @login_required def process_form(bookmark_id=None): + "Process the creation/edition of bookmarks." form = BookmarkForm() bookmark_contr = BookmarkController(current_user.id) tag_contr = BookmarkTagController(current_user.id) @@ -81,8 +84,15 @@ def process_form(bookmark_id=None): tags.append(new_tag) bookmark_attr['tags'] = tags bookmark_contr.update({'id': new_bookmark.id}, bookmark_attr) - - flash(gettext('Bookmark successfully created.'), 'success') - return redirect(url_for('bookmark.form', bookmark_id=new_bookmark.id)) + + +@bookmark_bp.route('/delete/<int:bookmark_id>', methods=['GET']) +@login_required +def delete(bookmark_id=None): + "Delete a bookmark." + bookmark = BookmarkController(current_user.id).delete(bookmark_id) + flash(gettext("Bookmark %(bookmark_name)s successfully deleted.", + bookmark_name=bookmark.title), 'success') + return redirect(redirect_url()) |