aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r
diff options
context:
space:
mode:
Diffstat (limited to 'pyaggr3g470r')
-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.py12
5 files changed, 14 insertions, 7 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 d31ba3cd..0390cbdc 100644
--- a/pyaggr3g470r/views.py
+++ b/pyaggr3g470r/views.py
@@ -313,11 +313,13 @@ def edit_feed(feed_id=None):
return redirect('/feed/'+feed_id)
else:
# Create a new feed
- new_feed = models.Feed(title=form.title.data, link=form.link.data, \
- site_link=form.site_link.data, email=form.email_notification.data)
- user.feeds.append(new_feed)
- user.feeds = sorted(user.feeds, key=lambda t: t.title.lower())
- user.save()
+ 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, \
+ enabled=form.enabled.data)
+ user.feeds.append(new_feed)
+ user.feeds = sorted(user.feeds, key=lambda t: t.title.lower())
+ user.save()
return redirect(url_for('home'))
if request.method == 'GET':
bgstack15