Commits

Cédric Bonhomme committed ce259fd

It is now possible to enable or disable (stop checking for updates) a feed.

Comments (0)

Files changed (5)

pyaggr3g470r/feedgetter.py

         """
         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:

pyaggr3g470r/forms.py

     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):

pyaggr3g470r/models.py

     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)
 

pyaggr3g470r/templates/edit_feed.html

             {{ form.email_notification.label }}
             {{ form.email_notification(class_="checkbox") }}
 
+            {{ form.enabled.label }}
+            {{ form.enabled(class_="checkbox") }}
+
             {{ form.submit(class_="btn") }}
         </form>
     </div>

pyaggr3g470r/views.py

             # 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()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.