From c2ddbddf772cfbf584ca45a9f1266502e16eb8f9 Mon Sep 17 00:00:00 2001
From: zsloan
Date: Thu, 5 May 2022 20:51:00 +0000
Subject: Add rest of JS/Python code for importing collections from files
---
wqflask/wqflask/collect.py | 10 ++++--
wqflask/wqflask/templates/collections/list.html | 41 ++++++++++++++++++++++---
2 files changed, 45 insertions(+), 6 deletions(-)
(limited to 'wqflask')
diff --git a/wqflask/wqflask/collect.py b/wqflask/wqflask/collect.py
index 9ab40a50..9874b4a4 100644
--- a/wqflask/wqflask/collect.py
+++ b/wqflask/wqflask/collect.py
@@ -73,7 +73,6 @@ def collections_add():
uc_id = g.user_session.add_collection(collection_name, set())
collections = g.user_session.user_collections
- # ZS: One of these might be unnecessary
if 'traits' in request.args:
traits = request.args['traits']
return render_template("collections/add.html",
@@ -127,7 +126,6 @@ def collections_new():
def create_new(collection_name):
params = request.args
-
if "hash" in params:
unprocessed_traits = Redis.get(params['hash'])
Redis.delete(params['hash'])
@@ -238,6 +236,14 @@ def import_collection():
if import_file.filename != '':
file_path = os.path.join(TEMPDIR, import_file.filename)
import_file.save(file_path)
+ collection_csv = open(file_path, "r")
+ traits = [row.strip() for row in collection_csv]
+ os.remove(file_path)
+
+ return json.dumps(traits)
+ else:
+ return render_template(
+ "collections/list.html")
@app.route("/collections/view")
def view_collection():
diff --git a/wqflask/wqflask/templates/collections/list.html b/wqflask/wqflask/templates/collections/list.html
index fb3946fb..6e1261d7 100644
--- a/wqflask/wqflask/templates/collections/list.html
+++ b/wqflask/wqflask/templates/collections/list.html
@@ -22,7 +22,7 @@
-