diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2016-03-01 22:47:53 +0100 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2016-03-01 22:47:53 +0100 |
commit | 83081ad7e488c44757e43ff40e83458a2e1451ed (patch) | |
tree | 176b04327df88b899aa4172aa30d042a0e43b32a /src/web/views/article.py | |
parent | Useless if no category set. (diff) | |
download | newspipe-83081ad7e488c44757e43ff40e83458a2e1451ed.tar.gz newspipe-83081ad7e488c44757e43ff40e83458a2e1451ed.tar.bz2 newspipe-83081ad7e488c44757e43ff40e83458a2e1451ed.zip |
begin integration of the new architecture
Diffstat (limited to 'src/web/views/article.py')
-rw-r--r-- | src/web/views/article.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/web/views/article.py b/src/web/views/article.py index 5b04fe7a..416bb96c 100644 --- a/src/web/views/article.py +++ b/src/web/views/article.py @@ -4,7 +4,7 @@ from datetime import datetime, timedelta from flask import (Blueprint, g, render_template, redirect, flash, url_for, request) from flask.ext.babel import gettext -from flask.ext.login import login_required +from flask.ext.login import login_required, current_user from web.lib.utils import clear_string, redirect_url from web.controllers import ArticleController @@ -17,7 +17,7 @@ article_bp = Blueprint('article', __name__, url_prefix='/article') @article_bp.route('/redirect/<int:article_id>', methods=['GET']) @login_required def redirect_to_article(article_id): - contr = ArticleController(g.user.id) + contr = ArticleController(current_user.id) article = contr.get(id=article_id) if not article.readed: contr.update({'id': article.id}, {'readed': True}) @@ -31,7 +31,7 @@ def article(article_id=None): """ Presents the content of an article. """ - article = ArticleController(g.user.id).get(id=article_id) + article = ArticleController(current_user.id).get(id=article_id) previous_article = article.previous_article() if previous_article is None: previous_article = article.source.articles[0] @@ -52,7 +52,7 @@ def like(article_id=None): """ Mark or unmark an article as favorites. """ - art_contr = ArticleController(g.user.id) + art_contr = ArticleController(current_user.id) article = art_contr.get(id=article_id) art_contr = art_contr.update({'id': article_id}, {'like': not article.like}) @@ -65,7 +65,7 @@ def delete(article_id=None): """ Delete an article from the database. """ - article = ArticleController(g.user.id).delete(article_id) + article = ArticleController(current_user.id).delete(article_id) flash(gettext('Article %(article_title)s deleted', article_title=article.title), 'success') return redirect(url_for('home')) @@ -76,7 +76,7 @@ def delete(article_id=None): @articles_bp.route('/history/<int:year>/<int:month>', methods=['GET']) @login_required def history(year=None, month=None): - counter, articles = ArticleController(g.user.id).get_history(year, month) + counter, articles = ArticleController(current_user.id).get_history(year, month) return render_template('history.html', articles_counter=counter, articles=articles, year=year, month=month) @@ -90,7 +90,7 @@ def mark_as(new_value='read', feed_id=None, article_id=None): Mark all unreaded articles as read. """ readed = new_value == 'read' - art_contr = ArticleController(g.user.id) + art_contr = ArticleController(current_user.id) filters = {'readed': not readed} if feed_id is not None: filters['feed_id'] = feed_id @@ -116,7 +116,7 @@ def expire(): """ current_time = datetime.utcnow() weeks_ago = current_time - timedelta(int(request.args.get('weeks', 10))) - art_contr = ArticleController(g.user.id) + art_contr = ArticleController(current_user.id) query = art_contr.read(__or__={'date__lt': weeks_ago, 'retrieved_date__lt': weeks_ago}) |