From 6058ac1fc751fcdacd87096d2e491f5437b3265c Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Sun, 12 Jan 2014 10:59:35 +0100 Subject: It is now possible to feth only one feed. --- pyaggr3g470r/feedgetter.py | 8 ++++++-- pyaggr3g470r/templates/home.html | 1 + pyaggr3g470r/views.py | 5 +++-- 3 files changed, 10 insertions(+), 4 deletions(-) (limited to 'pyaggr3g470r') diff --git a/pyaggr3g470r/feedgetter.py b/pyaggr3g470r/feedgetter.py index abfa7994..8e1a2e58 100644 --- a/pyaggr3g470r/feedgetter.py +++ b/pyaggr3g470r/feedgetter.py @@ -69,11 +69,15 @@ class FeedGetter(object): feedparser.USER_AGENT = conf.USER_AGENT self.user = models.User.objects(email=email).first() - def retrieve_feed(self): + def retrieve_feed(self, feed_id=None): """ Parse the file 'feeds.lst' and launch a thread for each RSS feed. """ - for current_feed in [feed for feed in self.user.feeds if feed.enabled]: + feeds = [feed for feed in self.user.feeds if feed.enabled] + if feed_id != None: + feeds = [feed for feed in feeds if str(feed.oid) == feed_id] + print len(feeds) + for current_feed in feeds: try: # launch a new thread for the RSS feed thread = threading.Thread(None, self.process, \ diff --git a/pyaggr3g470r/templates/home.html b/pyaggr3g470r/templates/home.html index c3548e79..72ea1abc 100644 --- a/pyaggr3g470r/templates/home.html +++ b/pyaggr3g470r/templates/home.html @@ -11,6 +11,7 @@ + {% for number in range(0, feed.articles|length-(feed.articles|length % 3), 3) %} diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py index b0977c65..e44da631 100644 --- a/pyaggr3g470r/views.py +++ b/pyaggr3g470r/views.py @@ -104,13 +104,14 @@ def home(): return render_template('home.html', user=user, feeds=feeds) @app.route('/fetch/', methods=['GET']) +@app.route('/fetch/', methods=['GET']) @login_required -def fetch(): +def fetch(feed_id=None): """ Triggers the download of news. """ feed_getter = feedgetter.FeedGetter(g.user.email) - feed_getter.retrieve_feed() + feed_getter.retrieve_feed(feed_id) flash("New articles retrieved.", 'success') return redirect(url_for('home')) -- cgit