aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorzsloan2016-10-04 19:39:17 +0000
committerzsloan2016-10-04 19:39:17 +0000
commitda127da677a8976675fb95d75213dd3e5326fb36 (patch)
treed6bdd95c12005635f5b85a520479d864a8df2143 /wqflask
parentdb0633155b88667e3c6ea760e0637ff1308d34e0 (diff)
downloadgenenetwork2-da127da677a8976675fb95d75213dd3e5326fb36.tar.gz
Fixed issue that caused adding to existing collections when not logged in to not work correctly.
The problem was that it would get the collection name from the "new_collection" field instead of the "existing_collections" dropdown.
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/wqflask/collect.py17
-rw-r--r--wqflask/wqflask/templates/collections/add.html2
2 files changed, 4 insertions, 15 deletions
diff --git a/wqflask/wqflask/collect.py b/wqflask/wqflask/collect.py
index 7e7aba89..81d03d6c 100644
--- a/wqflask/wqflask/collect.py
+++ b/wqflask/wqflask/collect.py
@@ -164,7 +164,7 @@ class UserCollection(object):
if not uc:
return create_new("Default")
else:
- uc = model.UserCollection.query.get(params['existing_collection'])
+ uc = model.UserCollection.query.get(params['existing_collection'].split(":")[0])
members = list(uc.members_as_set()) #set(json.loads(uc.members))
len_before = len(members)
@@ -218,7 +218,6 @@ def collections_add():
anon_collections = user_manager.AnonUser().get_collections()
collection_names = []
for collection in anon_collections:
- print("COLLECTION:", collection)
collection_names.append({'id':collection['id'], 'name':collection['name']})
return render_template("collections/add.html",
traits = traits,
@@ -229,21 +228,17 @@ def collections_add():
@app.route("/collections/new")
def collections_new():
params = request.args
- #print("request.args in collections_new are:", params)
-
- collection_name = params['new_collection']
- if "anonymous_add" in params:
- AnonCollection(name=collection_name).add_traits(params, "Default")
- return redirect(url_for('view_collection'))
if "sign_in" in params:
return redirect(url_for('login'))
if "create_new" in params:
print("in create_new")
+ collection_name = params['new_collection']
return create_new(collection_name)
elif "add_to_existing" in params:
print("in add to existing")
+ collection_name = params['existing_collection'].split(":")[1]
if g.user_session.logged_in:
return UserCollection().add_traits(params, collection_name)
else:
@@ -251,7 +246,6 @@ def collections_new():
ac.add_traits(params)
return redirect(url_for('view_collection', collection_id=ac.id))
else:
- print("ELSE")
CauseAnError
@@ -288,7 +282,6 @@ def create_new(collection_name):
ac = AnonCollection(collection_name)
ac.changed_timestamp = datetime.datetime.utcnow().strftime('%b %d %Y %I:%M%p')
ac.add_traits(params)
- print("Collection ID:", ac.id)
return redirect(url_for('view_collection', collection_id=ac.id))
@app.route("/collections/list")
@@ -367,7 +360,6 @@ def view_collection():
uc_id = params['uc_id']
uc = model.UserCollection.query.get(uc_id)
traits = json.loads(uc.members)
- print("traits are:", traits)
else:
user_collections = json.loads(Redis.get(user_manager.AnonUser().key))
this_collection = {}
@@ -384,7 +376,6 @@ def view_collection():
json_version = []
for atrait in traits:
- print("atrait is:", atrait)
name, dataset_name = atrait.split(':')
trait_ob = trait.GeneralTrait(name=name, dataset_name=dataset_name)
@@ -393,8 +384,6 @@ def view_collection():
json_version.append(trait_ob.jsonable())
- print("trait_obs:", trait_obs)
-
if "uc_id" in params:
collection_info = dict(trait_obs=trait_obs,
uc = uc)
diff --git a/wqflask/wqflask/templates/collections/add.html b/wqflask/wqflask/templates/collections/add.html
index 47b87d73..d45aa015 100644
--- a/wqflask/wqflask/templates/collections/add.html
+++ b/wqflask/wqflask/templates/collections/add.html
@@ -25,7 +25,7 @@
<select name="existing_collection" class="form-control">
{% for col in collections %}
- <option value="{{ col.id }}">{{ col.name }}</option>
+ <option value="{{ col.id }}:{{ col.name }}">{{ col.name }}</option>
{% endfor %}
</select>
<br />