From 62106a31f8a14710c114b76aebd79d6ad2345fda Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Wed, 20 Aug 2014 17:23:23 +0200 Subject: Finally delete article older and retrieved before 10 weeks. --- pyaggr3g470r/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py index 78aa174e..26a483c1 100644 --- a/pyaggr3g470r/views.py +++ b/pyaggr3g470r/views.py @@ -36,7 +36,7 @@ from flask.ext.principal import Principal, Identity, AnonymousIdentity, \ identity_changed, identity_loaded, Permission,\ RoleNeed, UserNeed from flask.ext.babel import gettext -from sqlalchemy import desc, func +from sqlalchemy import desc, func, or_ from sqlalchemy.exc import IntegrityError from werkzeug import generate_password_hash @@ -750,7 +750,7 @@ def expire_articles(): """ current_time = datetime.datetime.utcnow() weeks_ago = current_time - datetime.timedelta(weeks=int(request.args.get('weeks', 10))) - articles_to_delete = Article.query.filter(User.email == g.user.email, Article.date < weeks_ago) + articles_to_delete = Article.query.filter(User.email == g.user.email, or_(Article.date < weeks_ago, Article.retrieved_date < weeks_ago)) for article in articles_to_delete: db.session.delete(article) flash(gettext('Articles deleted.'), 'info') -- cgit