diff options
Diffstat (limited to 'pyaggr3g470r')
-rwxr-xr-x | pyaggr3g470r/utils.py | 6 | ||||
-rw-r--r-- | pyaggr3g470r/views.py | 6 |
2 files changed, 8 insertions, 4 deletions
diff --git a/pyaggr3g470r/utils.py b/pyaggr3g470r/utils.py index 4d65f14c..bb02c4df 100755 --- a/pyaggr3g470r/utils.py +++ b/pyaggr3g470r/utils.py @@ -81,13 +81,14 @@ def import_opml(email, opml_file): subscriptions = opml.parse(opml_file) except Exception as e: raise e + nb = 0 for subscription in subscriptions: try: title = subscription.text except: title = "" - print title + try: description = subscription.description except: @@ -109,8 +110,11 @@ def import_opml(email, opml_file): new_feed = models.Feed(title=title, description=description, link=link, site_link=site_link, email=False, enabled=True) user.feeds.append(new_feed) + + nb += 1 user.save() + return nb def open_url(url): """ diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py index 03ade91c..52ca3365 100644 --- a/pyaggr3g470r/views.py +++ b/pyaggr3g470r/views.py @@ -382,10 +382,10 @@ def management(): opml_path = os.path.join("./pyaggr3g470r/var/", data.filename) data.save(opml_path) try: - utils.import_opml(g.user.email, opml_path) - flash("New feeds imported", "success") + nb = utils.import_opml(g.user.email, opml_path) + flash(str(nb) + " feeds imported.", "success") except Exception as e: - flash("Impossible to import the new feeds."+str(e), "danger") + flash("Impossible to import the new feeds.", "danger") form = AddFeedForm() |