From a6082caf0d791a53e855e4de86319a38a37b7be2 Mon Sep 17 00:00:00 2001 From: Michiel Scholten Date: Sat, 13 Aug 2016 20:46:09 +0200 Subject: [PATCH] Undo delete bookmark. Enables unescaped rendering of message --- digimarks.py | 12 +++++++++++- templates/bookmarks.html | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/digimarks.py b/digimarks.py index a935fd4..bdbda26 100644 --- a/digimarks.py +++ b/digimarks.py @@ -406,7 +406,17 @@ def deletingbookmark(userkey, urlhash): query.execute() query = Bookmark.update(deleted_date = datetime.datetime.now()).where(Bookmark.userkey==userkey, Bookmark.url_hash==urlhash) query.execute() - message = 'Bookmark deleted' + message = 'Bookmark deleted. Undo deletion'.format(url_for('undeletebookmark', userkey=userkey, urlhash=urlhash)) + all_tags[userkey] = get_tags_for_user(userkey) + return redirect(url_for('bookmarks', userkey=userkey, message=message)) + + +@app.route('///undelete') +def undeletebookmark(userkey, urlhash): + """ Undo deletion of the bookmark identified by urlhash """ + query = Bookmark.update(status=Bookmark.VISIBLE).where(Bookmark.userkey==userkey, Bookmark.url_hash==urlhash) + query.execute() + message = 'Bookmark restored' all_tags[userkey] = get_tags_for_user(userkey) return redirect(url_for('bookmarks', userkey=userkey, message=message)) diff --git a/templates/bookmarks.html b/templates/bookmarks.html index 56464ac..9a1b43d 100644 --- a/templates/bookmarks.html +++ b/templates/bookmarks.html @@ -25,7 +25,7 @@
- {{ message }} + {{ message|safe }}