From 74151c9cfdc4dfe52f54fedc8de070adaaf6880d Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Sun, 27 Jan 2013 16:51:01 +0100 Subject: Test if success when changing the URL of a feed. --- source/pyAggr3g470r.py | 11 ++++++++--- source/utils.py | 3 ++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/source/pyAggr3g470r.py b/source/pyAggr3g470r.py index 2e8f4c8a..db67d384 100755 --- a/source/pyAggr3g470r.py +++ b/source/pyAggr3g470r.py @@ -493,9 +493,14 @@ class pyAggr3g470r(object): Enables to change the URL of a feed already present in the database. """ self.mongo.update_feed(feed_id, {"feed_link":new_feed_url}) - utils.change_feed_url(old_feed_url, new_feed_url) - tmpl = lookup.get_template("confirmation.html") - return tmpl.render(message="

The URL of the feed has been changed.

") + result = utils.change_feed_url(old_feed_url, new_feed_url) + if result: + tmpl = lookup.get_template("confirmation.html") + message = "

The URL of the feed has been changed.

" + else: + tmpl = lookup.get_template("error.html") + message = "

Error when changing the URL of the feed.

" + return tmpl.render(message=message) change_feed_url.exposed = True diff --git a/source/utils.py b/source/utils.py index 75ba6b07..e6baa124 100755 --- a/source/utils.py +++ b/source/utils.py @@ -204,9 +204,10 @@ def change_feed_url(old_feed_url, new_feed_url): try: lines[lines.index(old_feed_url)] = new_feed_url except: - return + return False with open(conf.FEED_LIST, "w") as f: f.write("\n".join(lines)) + return True def remove_feed(feed_url): """ -- cgit