aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Bonhomme <kimble.mandel@gmail.com>2013-11-23 19:11:51 +0100
committerCédric Bonhomme <kimble.mandel@gmail.com>2013-11-23 19:11:51 +0100
commit1a85f119cffe1b9beb149a1e6461d0fbcc648fd9 (patch)
treefe2c2a2b29e96d92905a4143734b4c3a6a504825
parentAdded an option to index all the database. (diff)
downloadnewspipe-1a85f119cffe1b9beb149a1e6461d0fbcc648fd9.tar.gz
newspipe-1a85f119cffe1b9beb149a1e6461d0fbcc648fd9.tar.bz2
newspipe-1a85f119cffe1b9beb149a1e6461d0fbcc648fd9.zip
Test if a feed already exists before creating a new one.
-rw-r--r--pyaggr3g470r/views.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py
index 1990633a..bc08697c 100644
--- a/pyaggr3g470r/views.py
+++ b/pyaggr3g470r/views.py
@@ -289,11 +289,12 @@ 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)
+ 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