From ceee9a32841b0909e027c6550a25bc7ef5948a26 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Sun, 17 Nov 2013 23:17:24 +0100 Subject: List of inavtive feeds. --- pyaggr3g470r/templates/layout.html | 1 + pyaggr3g470r/views.py | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/pyaggr3g470r/templates/layout.html b/pyaggr3g470r/templates/layout.html index f649f2ca..541c0ad8 100644 --- a/pyaggr3g470r/templates/layout.html +++ b/pyaggr3g470r/templates/layout.html @@ -50,6 +50,7 @@ diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py index 7b156b9f..62f5ae5e 100644 --- a/pyaggr3g470r/views.py +++ b/pyaggr3g470r/views.py @@ -26,12 +26,11 @@ __revision__ = "$Date: 2013/11/10 $" __copyright__ = "Copyright (c) Cedric Bonhomme" __license__ = "GPLv3" +import datetime from flask import render_template, request, flash, session, url_for, redirect, g from wtforms import TextField, PasswordField, SubmitField, validators - from flask.ext.login import LoginManager, login_user, logout_user, login_required, current_user, AnonymousUserMixin - from collections import defaultdict from forms import SigninForm, AddFeedForm @@ -205,6 +204,23 @@ def unread(): result.append(feed) return render_template('unread.html', feeds=result) +@app.route('/inactives/', methods=['GET']) +@login_required +def inactives(): + """ + List of inactive feeds. + """ + nb_days = int(request.args.get('nb_days', 365)) + user = models.User.objects(email=g.user.email).first() + today = datetime.datetime.now() + inactives = [] + for feed in user.feeds: + last_post = feed.articles[0].date + elapsed = today - last_post + if elapsed > datetime.timedelta(days=nb_days): + inactives.append((feed, elapsed)) + return render_template('inactives.html', inactives=inactives, nb_days=nb_days) + @app.route('/search/', methods=['GET']) @login_required def search(): -- cgit