diff options
author | Lei Yan | 2014-07-14 16:23:12 +0000 |
---|---|---|
committer | Lei Yan | 2014-07-14 17:02:01 +0000 |
commit | 214bf0128b8ecdda718983c5563cf34160743758 (patch) | |
tree | 917e7a5ae78dc4ff65dc08d107a0e3ae3a47c67c /wqflask/base/trait_collection.py | |
parent | 8de6fec18cd98a10c58702c448a1e01e147dc5f7 (diff) | |
parent | fbdbf4b7410185e2a978ecc8e120ae56ff6da0ce (diff) | |
download | genenetwork2-214bf0128b8ecdda718983c5563cf34160743758.tar.gz |
Merge /home/zas1024/gene
Conflicts:
wqflask/wqflask/static/new/javascript/dataset_select_menu.js
wqflask/wqflask/templates/corr_scatter_plot_old.html
Diffstat (limited to 'wqflask/base/trait_collection.py')
-rwxr-xr-x | wqflask/base/trait_collection.py | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/wqflask/base/trait_collection.py b/wqflask/base/trait_collection.py new file mode 100755 index 00000000..d388a3af --- /dev/null +++ b/wqflask/base/trait_collection.py @@ -0,0 +1,53 @@ +class TraitCollection(object):
+
+ def __init__(self, is_anon=False):
+ self.is_anon = is_anon
+
+
+ @app.route("/collections/remove", methods=('POST',))
+ def remove_traits():
+ if is_anon:
+ AnonCollection.remove_traits()
+ else:
+ UserCollection.remove_traits()
+
+ params = request.form
+ print("params are:", params)
+ uc_id = params['uc_id']
+ uc = model.UserCollection.query.get(uc_id)
+ traits_to_remove = params.getlist('traits[]')
+ print("traits_to_remove are:", traits_to_remove)
+ traits_to_remove = process_traits(traits_to_remove)
+ print("\n\n after processing, traits_to_remove:", traits_to_remove)
+ all_traits = uc.members_as_set()
+ print(" all_traits:", all_traits)
+ members_now = all_traits - traits_to_remove
+ print(" members_now:", members_now)
+ print("Went from {} to {} members in set.".format(len(all_traits), len(members_now)))
+ uc.members = json.dumps(list(members_now))
+ uc.changed_timestamp = datetime.datetime.utcnow()
+ db_session.commit()
+
+ # We need to return something so we'll return this...maybe in the future
+ # we can use it to check the results
+ return str(len(members_now))
+
+ def __init__(self, anon_id)
+ self.anon_key = anon_key
+ self.collection_members = Redis.smembers(self.anon_id)
+ print("self.collection_members is:", self.collection_members)
+ self.num_members = len(self.collection_members)
+
+
+ @app.route("/collections/remove", methods=('POST',))
+ def remove_traits(traits_to_remove):
+ print("traits_to_remove:", traits_to_remove)
+ for trait in traits_to_remove:
+ Redis.srem(self.anon_id, trait)
+ members_now = self.collection_members - traits_to_remove
+ print("members_now:", members_now)
+ print("Went from {} to {} members in set.".format(len(self.collection_members), len(members_now)))
+
+ # We need to return something so we'll return this...maybe in the future
+ # we can use it to check the results
+ return str(len(members_now))
|