aboutsummaryrefslogtreecommitdiff
path: root/wqflask/wqflask/collect.py
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask/wqflask/collect.py')
-rw-r--r--wqflask/wqflask/collect.py30
1 files changed, 24 insertions, 6 deletions
diff --git a/wqflask/wqflask/collect.py b/wqflask/wqflask/collect.py
index ef7b37df..48b4b4da 100644
--- a/wqflask/wqflask/collect.py
+++ b/wqflask/wqflask/collect.py
@@ -23,7 +23,7 @@ Redis = redis.StrictRedis()
from flask import (Flask, g, render_template, url_for, request, make_response,
- redirect, flash)
+ redirect, flash, jsonify)
from wqflask import app
@@ -122,16 +122,18 @@ def create_new():
@app.route("/collections/list")
def list_collections():
+ params = request.args
user_collections = g.user_session.user_ob.user_collections
return render_template("collections/list.html",
+ params = params,
user_collections = user_collections,
)
-
@app.route("/collections/view")
def view_collection():
params = request.args
+ print("params in view collection:", params)
uc_id = params['uc_id']
uc = model.UserCollection.query.get(uc_id)
traits = json.loads(uc.members)
@@ -139,6 +141,7 @@ def view_collection():
print("in view_collection traits are:", traits)
trait_obs = []
+ json_version = []
for atrait in traits:
name, dataset_name = atrait.split(':')
@@ -146,8 +149,23 @@ def view_collection():
trait_ob = trait.GeneralTrait(name=name, dataset_name=dataset_name)
trait_ob.get_info()
trait_obs.append(trait_ob)
-
- return render_template("collections/view.html",
- trait_obs=trait_obs,
- uc = uc,
+
+ json_version.append(trait_ob.jsonable())
+ #json_version.append(dict(name=trait_ob.name,
+ # description=trait_ob.description_display,
+ # location=trait_ob.location_repr,
+ # mean=trait_ob.mean,
+ # lrs_score=trait_ob.LRS_score_repr,
+ # lrs_location=trait_ob.LRS_location_repr))
+ # dis=trait_ob.description))
+ #json_version.append(trait_ob.__dict__th)
+
+ collection_info = dict(trait_obs=trait_obs,
+ uc = uc)
+ if "json" in params:
+ print("json_version:", json_version)
+ return json.dumps(json_version)
+ else:
+ return render_template("collections/view.html",
+ **collection_info
)