diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2015-04-01 22:57:15 +0200 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2015-04-01 22:57:15 +0200 |
commit | 854862e1c73bf0c521e08b8973721e8be7aeb82e (patch) | |
tree | 7f976931e7c9f121a5fe6791e61bb531ac401e72 | |
parent | Added customized-bootstrap.css file. (diff) | |
download | newspipe-854862e1c73bf0c521e08b8973721e8be7aeb82e.tar.gz newspipe-854862e1c73bf0c521e08b8973721e8be7aeb82e.tar.bz2 newspipe-854862e1c73bf0c521e08b8973721e8be7aeb82e.zip |
Bugfix.
-rwxr-xr-x | pyaggr3g470r/utils.py | 16 | ||||
-rw-r--r-- | pyaggr3g470r/views/views.py | 4 | ||||
-rwxr-xr-x | runserver.py | 10 |
3 files changed, 15 insertions, 15 deletions
diff --git a/pyaggr3g470r/utils.py b/pyaggr3g470r/utils.py index 5f2d8707..ea8a87bf 100755 --- a/pyaggr3g470r/utils.py +++ b/pyaggr3g470r/utils.py @@ -56,11 +56,21 @@ from contextlib import contextmanager import conf from flask import g +from bootstrap import application as app, db from pyaggr3g470r import controllers from pyaggr3g470r.models import User, Feed, Article logger = logging.getLogger(__name__) +ALLOWED_EXTENSIONS = set(['xml', 'opml', 'json']) + +def allowed_file(filename): + """ + Check if the uploaded file is allowed. + """ + return '.' in filename and \ + filename.rsplit('.', 1)[1] in ALLOWED_EXTENSIONS + @contextmanager def opened_w_error(filename, mode="r"): try: @@ -143,7 +153,7 @@ def import_opml(email, opml_content): nb += 1 return nb nb = read(subscriptions) - g.db.session.commit() + db.session.commit() return nb def import_json(email, json_content): @@ -167,7 +177,7 @@ def import_json(email, json_content): enabled=feed["enabled"]) user.feeds.append(new_feed) nb_feeds += 1 - g.db.session.commit() + db.session.commit() # Create articles: for feed in json_account["result"]: user_feed = Feed.query.filter(Feed.user_id == user.id, @@ -190,7 +200,7 @@ def import_json(email, json_content): feed_id=user_feed.id) user_feed.articles.append(new_article) nb_articles += 1 - g.db.session.commit() + db.session.commit() return nb_feeds, nb_articles def clean_url(url): diff --git a/pyaggr3g470r/views/views.py b/pyaggr3g470r/views/views.py index f77bdeba..3b39e9b0 100644 --- a/pyaggr3g470r/views/views.py +++ b/pyaggr3g470r/views/views.py @@ -510,7 +510,7 @@ def management(): if None != request.files.get('opmlfile', None): # Import an OPML file data = request.files.get('opmlfile', None) - if not g.allowed_file(data.filename): + if not utils.allowed_file(data.filename): flash(gettext('File not allowed.'), 'danger') else: try: @@ -523,7 +523,7 @@ def management(): elif None != request.files.get('jsonfile', None): # Import an account data = request.files.get('jsonfile', None) - if not g.allowed_file(data.filename): + if not utils.allowed_file(data.filename): flash(gettext('File not allowed.'), 'danger') else: try: diff --git a/runserver.py b/runserver.py index 156ae320..db1c4410 100755 --- a/runserver.py +++ b/runserver.py @@ -27,15 +27,6 @@ if conf.ON_HEROKU: from flask_sslify import SSLify SSLify(application) -ALLOWED_EXTENSIONS = set(['xml', 'opml', 'json']) - -def allowed_file(filename): - """ - Check if the uploaded file is allowed. - """ - return '.' in filename and \ - filename.rsplit('.', 1)[1] in ALLOWED_EXTENSIONS - babel = Babel(application) # Jinja filters @@ -54,7 +45,6 @@ with application.app_context(): populate_g() g.api = Api(application, prefix='/api/v2.0') g.babel = babel - g.allowed_file = allowed_file from pyaggr3g470r import views application.register_blueprint(views.articles_bp) |