diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2014-02-09 16:10:49 +0100 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2014-02-09 16:10:49 +0100 |
commit | 64d46ffda837e88596fae19c20d1d55467932668 (patch) | |
tree | 49ae5775095d368c8b81f57277d213b34a2e1958 /pyaggr3g470r/views.py | |
parent | Merge branch 'master' of bitbucket.org:cedricbonhomme/pyaggr3g470r (diff) | |
download | newspipe-64d46ffda837e88596fae19c20d1d55467932668.tar.gz newspipe-64d46ffda837e88596fae19c20d1d55467932668.tar.bz2 newspipe-64d46ffda837e88596fae19c20d1d55467932668.zip |
It is now possible to import OPML files.
Diffstat (limited to 'pyaggr3g470r/views.py')
-rw-r--r-- | pyaggr3g470r/views.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py index 47a95d0f..c8616d60 100644 --- a/pyaggr3g470r/views.py +++ b/pyaggr3g470r/views.py @@ -26,6 +26,7 @@ __revision__ = "$Date: 2014/02/09 $" __copyright__ = "Copyright (c) Cedric Bonhomme" __license__ = "GPLv3" +import os import datetime from flask import render_template, request, make_response, flash, session, url_for, redirect, g from flask.ext.login import LoginManager, login_user, logout_user, login_required, current_user, AnonymousUserMixin @@ -329,7 +330,7 @@ def index_database(): fastsearch.create_index(user.feeds) flash('Database indexed.', 'success') return redirect(url_for('home')) - + @app.route('/export/', methods=['GET']) @login_required def export_articles(): @@ -369,12 +370,24 @@ def search(): result.append(feed) return render_template('search.html', feeds=result, nb_articles=nb_articles, query=query) -@app.route('/management/', methods=['GET']) +@app.route('/management/', methods=['GET', 'POST']) @login_required def management(): """ Display the management page. """ + if request.method == 'POST': + # Import an OPML file + data = request.files['opmlfile'] + 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") + except: + flash("Impossible to import the new feeds.", "danger") + + form = AddFeedForm() user = models.User.objects(email=g.user.email).first() nb_feeds = len(user.feeds) |