aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r/views.py
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2014-08-20 15:12:51 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2014-08-20 15:12:51 +0200
commit4c8bb70e705e3dd5e2bacdd49c97e40bc5396949 (patch)
treec352151708cfeac788f16f7a846d19a810622c5c /pyaggr3g470r/views.py
parentAdded 'NOTIFICATION_EMAIL' env variable to the app.json file. (diff)
downloadnewspipe-4c8bb70e705e3dd5e2bacdd49c97e40bc5396949.tar.gz
newspipe-4c8bb70e705e3dd5e2bacdd49c97e40bc5396949.tar.bz2
newspipe-4c8bb70e705e3dd5e2bacdd49c97e40bc5396949.zip
It is now possible to delete articles older than a given number of weeks.
Diffstat (limited to 'pyaggr3g470r/views.py')
-rw-r--r--pyaggr3g470r/views.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py
index c8a7c7c6..3033f4c0 100644
--- a/pyaggr3g470r/views.py
+++ b/pyaggr3g470r/views.py
@@ -742,6 +742,19 @@ def delete_account():
flash(gettext('This user does not exist.'), 'danger')
return redirect(url_for('login'))
+@app.route('/expire_articles', methods=['GET'])
+@login_required
+def expire_articles():
+ """
+ Delete articles older than the given number of weeks.
+ """
+ current_time = datetime.datetime.utcnow()
+ weeks_ago = current_time - datetime.timedelta(weeks=int(request.args.get('weeks', 10)))
+ for article in Article.query.filter(User.email == g.user.email, Article.date < weeks_ago).all():
+ db.session.delete(article)
+ db.session.commit()
+ return redirect(redirect_url())
+
@app.route('/confirm_account/<string:activation_key>', methods=['GET'])
def confirm_account(activation_key=None):
"""
bgstack15