From 21da20f5d592aabcb60096768dcac76baa626315 Mon Sep 17 00:00:00 2001 From: François Schmidts Date: Sat, 11 Apr 2015 16:14:19 +0200 Subject: first take on redoing the menu --- pyaggr3g470r/views/feed.py | 15 ++++++++------- pyaggr3g470r/views/views.py | 10 +++++++--- 2 files changed, 15 insertions(+), 10 deletions(-) (limited to 'pyaggr3g470r/views') diff --git a/pyaggr3g470r/views/feed.py b/pyaggr3g470r/views/feed.py index f0e35e4b..e4c0dc9a 100644 --- a/pyaggr3g470r/views/feed.py +++ b/pyaggr3g470r/views/feed.py @@ -112,15 +112,16 @@ def read(feed_id): return redirect(request.referrer or url_for('home')) -@feed_bp.route('/update//', methods=['GET', 'POST']) +@feed_bp.route('/update//', methods=['GET', 'POST']) +@feeds_bp.route('/update/', methods=['GET', 'POST']) @login_required -def update(feed_id, action): +def update(action, feed_id=None): readed = action == 'read' - ArticleController(g.user.id).update({'readed__ne': readed, - 'feed_id': feed_id}, - {'readed': readed}) - flash(gettext('Feed successfully updated.', - feed_title=feed.title), 'success') + filters = {'readed__ne': readed} + if feed_id: + filters['feed_id'] = feed_id + ArticleController(g.user.id).update(filters, {'readed': readed}) + flash(gettext('Feed successfully updated.'), 'success') return redirect(request.referrer or url_for('home')) diff --git a/pyaggr3g470r/views/views.py b/pyaggr3g470r/views/views.py index 623cf5d4..3d3c47f6 100644 --- a/pyaggr3g470r/views/views.py +++ b/pyaggr3g470r/views/views.py @@ -224,13 +224,11 @@ def signup(): return render_template('signup.html', form=form) @app.route('/') -@app.route('/favorites') @login_required -def home(): +def home(favorites=False): """ Home page for connected users. Displays by default unread articles. """ - favorites = request.path.startswith('/favorites') head_title = gettext('Favorites') if favorites else '' feed_contr = FeedController(g.user.id) arti_contr = ArticleController(g.user.id) @@ -271,6 +269,12 @@ def home(): default_max_error = conf.DEFAULT_MAX_ERROR) +@app.route('/favorites') +@login_required +def favorties(): + return home(favorites=True) + + @app.route('/fetch', methods=['GET']) @app.route('/fetch/', methods=['GET']) @login_required -- cgit