diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2014-08-20 15:12:51 +0200 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2014-08-20 15:12:51 +0200 |
commit | 4c8bb70e705e3dd5e2bacdd49c97e40bc5396949 (patch) | |
tree | c352151708cfeac788f16f7a846d19a810622c5c | |
parent | Added 'NOTIFICATION_EMAIL' env variable to the app.json file. (diff) | |
download | newspipe-4c8bb70e705e3dd5e2bacdd49c97e40bc5396949.tar.gz newspipe-4c8bb70e705e3dd5e2bacdd49c97e40bc5396949.tar.bz2 newspipe-4c8bb70e705e3dd5e2bacdd49c97e40bc5396949.zip |
It is now possible to delete articles older than a given number of weeks.
-rw-r--r-- | pyaggr3g470r/templates/management.html | 1 | ||||
-rw-r--r-- | pyaggr3g470r/views.py | 13 |
2 files changed, 14 insertions, 0 deletions
diff --git a/pyaggr3g470r/templates/management.html b/pyaggr3g470r/templates/management.html index 4375ebdd..f8b7b8a0 100644 --- a/pyaggr3g470r/templates/management.html +++ b/pyaggr3g470r/templates/management.html @@ -8,6 +8,7 @@ {% if not_on_heroku %} <a href="/index_database" class="btn btn-default">{{ _('Index database') }}</a> {% endif %} + <a href="/expire_articles?weeks=10" class="btn btn-default">{{ _('Delete articles older than 10 weeks') }}</a> </div> <div class="jumbotron"> <h1>{{ _('Your Profile') }}</h1> 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): """ |