diff options
-rw-r--r-- | pyaggr3g470r/feedgetter.py | 8 | ||||
-rw-r--r-- | pyaggr3g470r/templates/home.html | 1 | ||||
-rw-r--r-- | pyaggr3g470r/views.py | 5 |
3 files changed, 10 insertions, 4 deletions
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 @@ <a href="/articles/{{ feed.oid }}"><i class="glyphicon glyphicon-th-list" title="All articles"></i></a> <a href="/feed/{{ feed.oid }}"><i class="glyphicon glyphicon-eye-open" title="Details"></i></a> <a href="/edit_feed/{{ feed.oid }}"><i class="glyphicon glyphicon-edit" title="Edit this feed"></i></a> + <a href="/fetch/{{ feed.oid }}"><i class="glyphicon glyphicon-cloud-download" title="Fetch this feed"></i></a> </div> </div> {% 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/<feed_id>', 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')) |