aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Bonhomme <kimble.mandel@gmail.com>2013-11-23 19:27:30 +0100
committerCédric Bonhomme <kimble.mandel@gmail.com>2013-11-23 19:27:30 +0100
commitb2c2b35f8f1321a8becc49a1c8e61a6123ed616f (patch)
tree1de5892d7f8911e0456e069b19b3b59922e89079
parentTest if a feed already exists before creating a new one. (diff)
downloadnewspipe-b2c2b35f8f1321a8becc49a1c8e61a6123ed616f.tar.gz
newspipe-b2c2b35f8f1321a8becc49a1c8e61a6123ed616f.tar.bz2
newspipe-b2c2b35f8f1321a8becc49a1c8e61a6123ed616f.zip
It is now possible to enable or disable (stop checking for updates) a feed.
-rw-r--r--pyaggr3g470r/feedgetter.py4
-rw-r--r--pyaggr3g470r/forms.py1
-rw-r--r--pyaggr3g470r/models.py1
-rw-r--r--pyaggr3g470r/templates/edit_feed.html3
-rw-r--r--pyaggr3g470r/views.py3
5 files changed, 9 insertions, 3 deletions
diff --git a/pyaggr3g470r/feedgetter.py b/pyaggr3g470r/feedgetter.py
index 21cc841d..673b5a20 100644
--- a/pyaggr3g470r/feedgetter.py
+++ b/pyaggr3g470r/feedgetter.py
@@ -63,11 +63,11 @@ class FeedGetter(object):
"""
Parse the file 'feeds.lst' and launch a thread for each RSS feed.
"""
- for feed in self.user.feeds:
+ for current_feed in [feed for feed in self.user.feeds if feed.enabled]:
try:
# launch a new thread for the RSS feed
thread = threading.Thread(None, self.process, \
- None, (feed, ))
+ None, (current_feed, ))
thread.start()
list_of_threads.append(thread)
except:
diff --git a/pyaggr3g470r/forms.py b/pyaggr3g470r/forms.py
index deebea3a..0aed7da6 100644
--- a/pyaggr3g470r/forms.py
+++ b/pyaggr3g470r/forms.py
@@ -55,6 +55,7 @@ class AddFeedForm(Form):
link = TextField("Feed link", [validators.Required("Please enter a link for the feed.")])
site_link = TextField("Site link", [validators.Required("Please enter a site URL.")])
email_notification = BooleanField("Email notification", default=False)
+ enabled = BooleanField("Check for updates", default=True)
submit = SubmitField("Save")
def __init__(self, *args, **kwargs):
diff --git a/pyaggr3g470r/models.py b/pyaggr3g470r/models.py
index 3ec0e6fe..718ff19a 100644
--- a/pyaggr3g470r/models.py
+++ b/pyaggr3g470r/models.py
@@ -67,6 +67,7 @@ class Feed(EmbeddedDocument):
link = StringField(required=True, unique=True)
site_link = StringField(required=True)
email_notification = BooleanField(default=False)
+ enabled = BooleanField(default=True)
articles = ListField(ReferenceField('Article', dbref = False))
created_date = DateTimeField(required=True, default=datetime.now)
diff --git a/pyaggr3g470r/templates/edit_feed.html b/pyaggr3g470r/templates/edit_feed.html
index 2aff40c8..1ea774b6 100644
--- a/pyaggr3g470r/templates/edit_feed.html
+++ b/pyaggr3g470r/templates/edit_feed.html
@@ -18,6 +18,9 @@
{{ form.email_notification.label }}
{{ form.email_notification(class_="checkbox") }}
+ {{ form.enabled.label }}
+ {{ form.enabled(class_="checkbox") }}
+
{{ form.submit(class_="btn") }}
</form>
</div>
diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py
index bc08697c..7a4eb310 100644
--- a/pyaggr3g470r/views.py
+++ b/pyaggr3g470r/views.py
@@ -291,7 +291,8 @@ def edit_feed(feed_id=None):
# Create a new feed
if len([feed for feed in user.feeds if feed.link == form.link.data]) == 0:
new_feed = models.Feed(title=form.title.data, link=form.link.data, \
- site_link=form.site_link.data, email=form.email_notification.data)
+ site_link=form.site_link.data, email=form.email_notification.data, \
+ enabled=form.enabled.data)
user.feeds.append(new_feed)
user.feeds = sorted(user.feeds, key=lambda t: t.title.lower())
user.save()
bgstack15