From 275174497daa6d0dae64124addb360cb8c71c658 Mon Sep 17 00:00:00 2001 From: Sam Ockman Date: Wed, 4 Jul 2012 21:41:34 -0400 Subject: Changes around trait data editing --- wqflask/wqflask/dataSharing/SharingInfoPage.py | 13 +- .../new/javascript/trait_data_and_analysis.coffee | 48 +++++- .../new/javascript/trait_data_and_analysis.js | 54 +++++- wqflask/wqflask/templates/base.html | 4 +- wqflask/wqflask/templates/data_sharing.html | 190 +-------------------- .../wqflask/templates/trait_data_and_analysis.html | 20 ++- wqflask/wqflask/views.py | 33 +++- 7 files changed, 153 insertions(+), 209 deletions(-) diff --git a/wqflask/wqflask/dataSharing/SharingInfoPage.py b/wqflask/wqflask/dataSharing/SharingInfoPage.py index 4e07e01b..91538a07 100755 --- a/wqflask/wqflask/dataSharing/SharingInfoPage.py +++ b/wqflask/wqflask/dataSharing/SharingInfoPage.py @@ -28,6 +28,8 @@ from __future__ import print_function, division from pprint import pformat as pf +import flask + from base.templatePage import templatePage from base import webqtlConfig from dbFunction import webqtlDatabaseFunction @@ -42,8 +44,9 @@ class SharingInfoPage(templatePage): def __init__(self, fd): templatePage.__init__(self, fd) + self.redirect_url = None # Set if you want a redirect print("fd is:", pf(fd.__dict__)) - # Todo: Need a [0] in line below???? + # Todo: Need a [0] in line below????d GN_AccessionId = fd.get('GN_AccessionId') # Used under search datasharing InfoPageName = fd['database'][0] cursor = webqtlDatabaseFunction.getCursor() @@ -51,8 +54,12 @@ class SharingInfoPage(templatePage): sql = "select GN_AccesionId from InfoFiles where InfoPageName = %s" cursor.execute(sql, InfoPageName) GN_AccessionId = cursor.fetchone() - url = webqtlConfig.CGIDIR + "main.py?FormID=sharinginfo&GN_AccessionId=%s" % GN_AccessionId - self.redirection = url + self.redirect_url = "http://23.21.59.238:5001/data_sharing&GN_AccessionId=%s" % GN_AccessionId + #self.redirect_url = flask.url_for('data_sharing', GN_AccessionId=GN_AccessionId[0]) + print("set self.redirect_url") + #print("before redirect") + #return flask.redirect(url) + #print("after redirect") else: sharingInfoObject = SharingInfo.SharingInfo(GN_AccessionId, InfoPageName) self.dict['body'] = sharingInfoObject.getBody(infoupdate="") diff --git a/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.coffee b/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.coffee index 118be8ec..d3b1051d 100644 --- a/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.coffee +++ b/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.coffee @@ -1,5 +1,15 @@ console.log("start_b") +isNumber = (o) -> + return ! isNaN (o-0) && o != null + +console.log("isNumber 7:", isNumber(7)) +console.log("isNumber 13.1:", isNumber(13.1)) +console.log("isNumber x:", isNumber("x")) +console.log("isNumber '9':", isNumber('9')) +console.log("isNumber:", isNumber()) + + $ -> hide_tabs = (start) -> for x in [start..10] @@ -12,7 +22,7 @@ $ -> console.log("hidden?") - + # Changes stats table between all, bxd only and non-bxd, etc. stats_mdp_change = -> console.log("In stats_mdp_change") selected = $(this).val() @@ -24,3 +34,39 @@ $ -> console.log("tape") + + mean = (the_values)-> + total = 0 + total += value for value in the_values + console.log("yeap") + console.log(total) + the_mean = total / the_values.length + return the_mean.toFixed(2) + + + + edit_data_change = -> + console.log("In edit_data_change") + the_values = [] + #console.log($(this)) + #$(this).each (counter, element) => + # #console.log("counter is:" + counter) + # console.log("element is:") + # console.log(element) + console.log("foo") + values = $('#primary').find(".edit_strain_value") + console.log("values are:", values) + for value in values + console.log(value) + real_value = $(value).val() + #if real_value + console.log(real_value) + if isNumber(real_value) and real_value != "" + the_values.push(parseFloat(real_value)) + console.log(the_values) + the_mean = mean(the_values) + console.log(the_mean) + $("#mean_value").html(the_mean) + + $('#primary').change(edit_data_change) + console.log("loaded") diff --git a/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.js b/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.js index e59edbdb..eecc630f 100644 --- a/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.js +++ b/wqflask/wqflask/static/new/javascript/trait_data_and_analysis.js @@ -1,10 +1,25 @@ // Generated by CoffeeScript 1.3.3 (function() { + var isNumber; console.log("start_b"); + isNumber = function(o) { + return !isNaN((o - 0) && o !== null); + }; + + console.log("isNumber 7:", isNumber(7)); + + console.log("isNumber 13.1:", isNumber(13.1)); + + console.log("isNumber x:", isNumber("x")); + + console.log("isNumber '9':", isNumber('9')); + + console.log("isNumber:", isNumber()); + $(function() { - var hide_tabs, stats_mdp_change; + var edit_data_change, hide_tabs, mean, stats_mdp_change; hide_tabs = function(start) { var x, _i, _results; _results = []; @@ -26,7 +41,42 @@ return $("#stats_tabs" + selected).show(); }; $(".stats_mdp").change(stats_mdp_change); - return console.log("tape"); + console.log("tape"); + mean = function(the_values) { + var the_mean, total, value, _i, _len; + total = 0; + for (_i = 0, _len = the_values.length; _i < _len; _i++) { + value = the_values[_i]; + total += value; + } + console.log("yeap"); + console.log(total); + the_mean = total / the_values.length; + return the_mean.toFixed(2); + }; + edit_data_change = function() { + var real_value, the_mean, the_values, value, values, _i, _len; + console.log("In edit_data_change"); + the_values = []; + console.log("foo"); + values = $('#primary').find(".edit_strain_value"); + console.log("values are:", values); + for (_i = 0, _len = values.length; _i < _len; _i++) { + value = values[_i]; + console.log(value); + real_value = $(value).val(); + console.log(real_value); + if (isNumber(real_value) && real_value !== "") { + the_values.push(parseFloat(real_value)); + } + } + console.log(the_values); + the_mean = mean(the_values); + console.log(the_mean); + return $("#mean_value").html(the_mean); + }; + $('#primary').change(edit_data_change); + return console.log("loaded"); }); }).call(this); diff --git a/wqflask/wqflask/templates/base.html b/wqflask/wqflask/templates/base.html index 6776a71c..d7154a5b 100644 --- a/wqflask/wqflask/templates/base.html +++ b/wqflask/wqflask/templates/base.html @@ -18,11 +18,11 @@ - + - + diff --git a/wqflask/wqflask/templates/data_sharing.html b/wqflask/wqflask/templates/data_sharing.html index e9d082d6..e6942504 100644 --- a/wqflask/wqflask/templates/data_sharing.html +++ b/wqflask/wqflask/templates/data_sharing.html @@ -1,112 +1,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +{% extends "base.html" %} +{% block title %}Search Results{% endblock %} +{% block content %} @@ -752,80 +646,4 @@ This table lists all arrays by file order (Index), tube/sample ID, age, s - - - - - - -
  - - - - - - -
- - - - - - - - - WebQTL -
-
 
- - - - - -
-   |    - -Home -   |    - -Search -   |    - -Help -   |    - - -News -   |    - - -References -   |    - -Policies -   |    - - -Links -   |    - -Welcome! Login    -
-
- - - - - - - - - - - - - - -
- - CITG - -WWW service initiated January, 1994 as The Portable Dictionary of the Mouse Genome and June 15, 2001 as WebQTL. - -This site is currently operated by - Rob Williams, - Lei Yan, - Zachary Sloan, - Arthur Centeno. Design and code by Sam Ockman, Xiaodong Zhou, Christian Fernandez, Ning Liu, Rudi Alberts, Elissa Chesler, Jintao Wang, Kenneth Manly, Robert W. Williams, and colleagues. - - - - - Python Powered - - - Registered with Nif -
- GeneNetwork support from: - -
-     It took 0.011 second(s) for spring211.uthsc.edu to generate this page -
-
- - - - - - - - - - +{% endblock %} diff --git a/wqflask/wqflask/templates/trait_data_and_analysis.html b/wqflask/wqflask/templates/trait_data_and_analysis.html index efd87acc..c27ab092 100644 --- a/wqflask/wqflask/templates/trait_data_and_analysis.html +++ b/wqflask/wqflask/templates/trait_data_and_analysis.html @@ -295,7 +295,7 @@ Mean - {{ "%2.3f" % sd.traitmean }} + {{ "%2.3f" % sd.traitmean }} @@ -3047,7 +3047,7 @@ {% for strain_type in (primary_strains, other_strains) %}
{# Slightly tortuous, but best way to get the id we need #} - @@ -3063,18 +3063,19 @@ {% for strain in strain_type %} - + - @@ -3083,8 +3084,9 @@ ± - diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index a2c68f13..55d6ffe2 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -1,5 +1,7 @@ from __future__ import absolute_import, division, print_function +import flask + from wqflask import app from flask import render_template, request @@ -13,6 +15,8 @@ from base import webqtlFormData from pprint import pformat as pf +print("latest blue") + @app.route("/") def index_page(): return render_template("index_page.html") @@ -21,12 +25,26 @@ def index_page(): @app.route("/search") def search(): if 'info_database' in request.args: - print("Going to data_sharing") - data_sharing() + print("Going to sharing_info_page") + template_vars = sharing_info_page() + if template_vars.redirect_url: + return flask.redirect(template_vars.redirect_url) + else: + return render_template("data_sharing.html", **template_vars.__dict__) else: the_search = search_results.SearchResultPage(request.args) return render_template("search_result_page.html", **the_search.__dict__) +@app.route("/data_sharing") +def data_sharing(): + print("In data_sharing") + fd = webqtlFormData.webqtlFormData(request.args) + print("Have fd") + template_vars = SharingInfoPage.SharingInfoPage(fd) + print("Made it to rendering") + return template_vars + + @app.route("/showDatabaseBXD") def showDatabaseBXD(): # Here it's currently too complicated not to use an fd that is a webqtlFormData @@ -35,11 +53,14 @@ def showDatabaseBXD(): print("showDatabaseBXD template_vars:", pf(template_vars.__dict__)) return render_template("trait_data_and_analysis.html", **template_vars.__dict__) -#@app.route("/data_sharing") -def data_sharing(): - print("In data_sharing") + + +# Todo: Can we simplify this? -Sam +def sharing_info_page(): + print("In sharing_info_page") fd = webqtlFormData.webqtlFormData(request.args) print("Have fd") + print("SharingInfoPage is:", SharingInfoPage) template_vars = SharingInfoPage.SharingInfoPage(fd) print("Made it to rendering") - return render_template("data_sharing.html", **template_vars.__dict__) + return template_vars -- cgit v1.2.3
{{ loop.index }} - + - {{ strain.strain_name }} + {{ strain.strain_name }} - + - +