aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2015-06-02 09:05:22 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2015-06-02 09:05:22 +0200
commit15fa861f4bac34c887e4780a94ba9e6dda202fde (patch)
tree7d14895090a440840b69c1eb18fd10e23a6b5882
parentIt is now possible to sort the list of articles on the second column (title o... (diff)
downloadnewspipe-15fa861f4bac34c887e4780a94ba9e6dda202fde.tar.gz
newspipe-15fa861f4bac34c887e4780a94ba9e6dda202fde.tar.bz2
newspipe-15fa861f4bac34c887e4780a94ba9e6dda202fde.zip
Bug fix: the 'expire_articles' function was deleting articles of all users!
-rw-r--r--pyaggr3g470r/views/views.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/pyaggr3g470r/views/views.py b/pyaggr3g470r/views/views.py
index f064236a..d83a9d35 100644
--- a/pyaggr3g470r/views/views.py
+++ b/pyaggr3g470r/views/views.py
@@ -41,7 +41,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 or_
+from sqlalchemy import or_, and_
from sqlalchemy.exc import IntegrityError
from werkzeug import generate_password_hash
@@ -603,7 +603,10 @@ 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, or_(Article.date < weeks_ago, Article.retrieved_date < weeks_ago))
+ articles_to_delete = Article.query.filter(
+ and_(Article.user_id == g.user.id,
+ 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')
bgstack15