From f1af56fb0f5b6e42b87cb6f1145cf8773b3f46b4 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Mon, 3 Feb 2014 07:37:29 +0100 Subject: Improvement of the Flask redirection for the view mark_as_read(). --- pyaggr3g470r/views.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'pyaggr3g470r') diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py index ee163099..e44f0f28 100644 --- a/pyaggr3g470r/views.py +++ b/pyaggr3g470r/views.py @@ -89,6 +89,10 @@ def logout(): flash("Logged out successfully.", 'success') return redirect(url_for('home')) +def redirect_url(default='index'): + return request.args.get('next') or \ + request.referrer or \ + url_for(default) @@ -192,9 +196,14 @@ def mark_as_read(feed_id=None): for article in unread_articles: article.readed = True article.save() + flash('Articles of the feed "' + feed.title + '" marked as read.', 'info') + break + else: + flash("This feed do not exist.", 'warning') else: models.Article.objects(readed=False).update(set__readed=True) - return redirect(url_for('home')) + flash("All articles marked as read", 'info') + return redirect(redirect_url()) @app.route('/like/', methods=['GET']) @login_required -- cgit