aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xpyaggr3g470r/utils.py7
-rw-r--r--pyaggr3g470r/views.py4
2 files changed, 3 insertions, 8 deletions
diff --git a/pyaggr3g470r/utils.py b/pyaggr3g470r/utils.py
index 50549587..336ec804 100755
--- a/pyaggr3g470r/utils.py
+++ b/pyaggr3g470r/utils.py
@@ -133,15 +133,12 @@ def import_opml(email, opml_content):
db.session.commit()
return nb
-def import_json(email, json_file):
+def import_json(email, json_content):
"""
Import an account from a JSON file.
"""
user = User.query.filter(User.email == email).first()
- json_string = ""
- with open(json_file, "r") as account:
- json_string = account.read()
- json_account = json.loads(json_string)
+ json_account = json.loads(json_content)
nb_feeds, nb_articles = 0, 0
# Create feeds
diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py
index 1dd651e5..cfd60206 100644
--- a/pyaggr3g470r/views.py
+++ b/pyaggr3g470r/views.py
@@ -570,10 +570,8 @@ def management():
if not allowed_file(data.filename):
flash(gettext('File not allowed.'), 'danger')
else:
- json_path = os.path.join("./pyaggr3g470r/var/", data.filename)
- data.save(json_path)
try:
- nb = utils.import_json(g.user.email, json_path)
+ nb = utils.import_json(g.user.email, data.read())
flash(gettext('Account imported.'), "success")
except:
flash(gettext("Impossible to import the account."), "danger")
bgstack15