From a5d7bf7c1dbde546dda676067147690f31d3f931 Mon Sep 17 00:00:00 2001 From: Eric Marzec Date: Sat, 26 May 2018 14:30:06 -0400 Subject: [PATCH 01/22] WIP get started on standard run interface --- minard/standard_runs.py | 16 ++++++++++++++++ minard/views.py | 5 +++++ 2 files changed, 21 insertions(+) create mode 100644 minard/standard_runs.py diff --git a/minard/standard_runs.py b/minard/standard_runs.py new file mode 100644 index 00000000..9a1e0141 --- /dev/null +++ b/minard/standard_runs.py @@ -0,0 +1,16 @@ +import couchdb +from itertools import groupby +from .views import app + +def get_standard_runs(): + couch = couchdb.Server("http://snoplus:"+app.config["COUCHDB_PASSWORD"]+"@"+app.config["COUCHDB_HOSTNAME"]) + orca_db = couch['orca'] + sr_view = orca_db.view("standardRuns/getStandardRunsWithVersion") + # standard run keys are [doc-version, run name, run version, timestamp] + # I want to groupby by run name then within that group all run versions sorted + # by timestamp + groups = groupby(sr_view.rows, lambda x: x.key[1] + x.key[2]) + groups = [(x, list(y)) for x, y in groups] + runs = [max(group, key=lambda x: x.key[3]) for _, group in groups] + runs = [(x, list(y)) for x,y in groupby(runs, lambda x: x.key[1])] + return runs diff --git a/minard/views.py b/minard/views.py index 798ba0db..d4dcc982 100644 --- a/minard/views.py +++ b/minard/views.py @@ -33,6 +33,7 @@ import dropout import pmtnoisedb import gain_monitor +import standard_runs as sr from run_list import golden_run_list from .polling import polling_runs, polling_info, polling_info_card, polling_check, polling_history, polling_summary from .channeldb import ChannelStatusForm, upload_channel_status, get_channels, get_channel_status, get_channel_status_form, get_channel_history, get_pmt_info, get_nominal_settings, get_most_recent_polling_info, get_discriminator_threshold, get_all_thresholds, get_maxed_thresholds, get_gtvalid_lengths, get_pmt_types, pmt_type_description, get_fec_db_history @@ -1576,3 +1577,7 @@ def _dropout_detail_n100(run_number): @app.route("/dropout/_dropout_detail/N20/") def _dropout_detail_n20(run_number): return dropout.get_details(run_number, 2) + +@app.route("/standard_runs") +def standard_runs(): + return render_template('standard_runs.html', values=sr.get_standard_runs()) From e7d20eb556c37aa4c01a624e14f28036626e9c42 Mon Sep 17 00:00:00 2001 From: Eric Marzec Date: Sat, 26 May 2018 15:32:18 -0400 Subject: [PATCH 02/22] get overview page for standard runs working okay --- minard/standard_runs.py | 4 +++- minard/views.py | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/minard/standard_runs.py b/minard/standard_runs.py index 9a1e0141..4bfe3acd 100644 --- a/minard/standard_runs.py +++ b/minard/standard_runs.py @@ -9,8 +9,10 @@ def get_standard_runs(): # standard run keys are [doc-version, run name, run version, timestamp] # I want to groupby by run name then within that group all run versions sorted # by timestamp - groups = groupby(sr_view.rows, lambda x: x.key[1] + x.key[2]) + rows = sorted(sr_view.rows, key=lambda x: x.key[1] + x.key[2]) + groups = groupby(rows, lambda x: x.key[1] + x.key[2]) groups = [(x, list(y)) for x, y in groups] runs = [max(group, key=lambda x: x.key[3]) for _, group in groups] + runs = sorted(runs, key=lambda x: x.key[1]) runs = [(x, list(y)) for x,y in groupby(runs, lambda x: x.key[1])] return runs diff --git a/minard/views.py b/minard/views.py index d4dcc982..de059bb5 100644 --- a/minard/views.py +++ b/minard/views.py @@ -1578,6 +1578,11 @@ def _dropout_detail_n100(run_number): def _dropout_detail_n20(run_number): return dropout.get_details(run_number, 2) +@app.route('/standard_runs/') +@app.route("/standard_runs/") @app.route("/standard_runs") -def standard_runs(): - return render_template('standard_runs.html', values=sr.get_standard_runs()) +def standard_runs(uuid=None): + if uuid is None: + return render_template('standard_runs.html', values=sr.get_standard_runs()) + print(uuid) + return "ZING" From 53bd774ed078f254a6f473d1bde57e3e77f53334 Mon Sep 17 00:00:00 2001 From: Eric Marzec Date: Sun, 27 May 2018 16:44:06 -0400 Subject: [PATCH 03/22] add detail view for standard run --- minard/standard_runs.py | 5 ++++ minard/templates/standard_run.html | 37 ++++++++++++++++++++++++++++++ minard/views.py | 16 +++++++++++-- 3 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 minard/templates/standard_run.html diff --git a/minard/standard_runs.py b/minard/standard_runs.py index 4bfe3acd..ffef203f 100644 --- a/minard/standard_runs.py +++ b/minard/standard_runs.py @@ -16,3 +16,8 @@ def get_standard_runs(): runs = sorted(runs, key=lambda x: x.key[1]) runs = [(x, list(y)) for x,y in groupby(runs, lambda x: x.key[1])] return runs + +def get_standard_run(uuid): + couch = couchdb.Server("http://snoplus:"+app.config["COUCHDB_PASSWORD"]+"@"+app.config["COUCHDB_HOSTNAME"]) + orca_db = couch['orca'] + return orca_db.get(uuid) diff --git a/minard/templates/standard_run.html b/minard/templates/standard_run.html new file mode 100644 index 00000000..259b2276 --- /dev/null +++ b/minard/templates/standard_run.html @@ -0,0 +1,37 @@ +{% extends "layout.html" %} +{% block title %}Standard Runs{% endblock %} +{% block head %} + {{ super() }} +{% endblock %} +{% block body %} + {{ super() }} +
+ {% if error %} +

{{error}}

+ {% else %} +
+ + + + + + + + {% for k,v in sr_info %} + + + + + + {% endfor %} +
Key Value New Value Replace?
{{ k }} {{ v }} +
+
+ +
+ {% endif %} +
+{% endblock %} +{% block script %} +{% endblock %} + diff --git a/minard/views.py b/minard/views.py index de059bb5..42fd1b30 100644 --- a/minard/views.py +++ b/minard/views.py @@ -1584,5 +1584,17 @@ def _dropout_detail_n20(run_number): def standard_runs(uuid=None): if uuid is None: return render_template('standard_runs.html', values=sr.get_standard_runs()) - print(uuid) - return "ZING" + sr_info = sr.get_standard_run(uuid) + if sr_info is None: + return render_template("standard_run.html", error="Requested standard run does not exist") + # Remove values that shouldn't be changed + sr_info.pop("version", None) + sr_info.pop("timestamp", None) + sr_info.pop("time_stamp", None) + sr_info.pop("_rev", None) + sr_info.pop("_id", None) + sr_info.pop("XilinxFilePath", None) + + sr_info = sorted(sr_info.iteritems()) + return render_template("standard_run.html", sr_info=sr_info) + From a9ac6aa051dd6abdb9e91bf699c9e18f234027aa Mon Sep 17 00:00:00 2001 From: Eric Marzec Date: Mon, 28 May 2018 12:44:19 -0400 Subject: [PATCH 04/22] implement updating standard runs --- minard/standard_runs.py | 9 +++++ minard/templates/standard_run.html | 58 ++++++++++++++++++++---------- minard/views.py | 21 ++++++++--- 3 files changed, 66 insertions(+), 22 deletions(-) diff --git a/minard/standard_runs.py b/minard/standard_runs.py index ffef203f..b0b91134 100644 --- a/minard/standard_runs.py +++ b/minard/standard_runs.py @@ -21,3 +21,12 @@ def get_standard_run(uuid): couch = couchdb.Server("http://snoplus:"+app.config["COUCHDB_PASSWORD"]+"@"+app.config["COUCHDB_HOSTNAME"]) orca_db = couch['orca'] return orca_db.get(uuid) + +def update_standard_run(uuid, new_values): + couch = couchdb.Server("http://snoplus:"+app.config["COUCHDB_PASSWORD"]+"@"+app.config["COUCHDB_HOSTNAME"]) + orca_db = couch['orca'] + doc = orca_db.get(uuid) + for k, v in new_values.iteritems(): + doc[k] = v + new_uuid, _ = orca_db.save(doc) + return new_uuid diff --git a/minard/templates/standard_run.html b/minard/templates/standard_run.html index 259b2276..5da5829a 100644 --- a/minard/templates/standard_run.html +++ b/minard/templates/standard_run.html @@ -9,25 +9,47 @@ {% if error %}

{{error}}

{% else %} -
- - - - - - - - {% for k,v in sr_info %} - - - - - +
+
+ Name +
+ +
+ Current Value +
+
+ New Value +
+
+ Replace? +
+
+

+ + +
+ {% for k, v in sr_info %} +
+
+ +
+
+

+ {{v}} +

+
+
+ +
+
+ +
+
{% endfor %} -
Key Value New Value Replace?
{{ k }} {{ v }} -
-
- +
+ +
+
{% endif %} diff --git a/minard/views.py b/minard/views.py index 42fd1b30..6c1bd202 100644 --- a/minard/views.py +++ b/minard/views.py @@ -1578,23 +1578,36 @@ def _dropout_detail_n100(run_number): def _dropout_detail_n20(run_number): return dropout.get_details(run_number, 2) -@app.route('/standard_runs/') +@app.route('/standard_runs/', methods=['GET', 'POST']) @app.route("/standard_runs/") @app.route("/standard_runs") def standard_runs(uuid=None): + error = None if uuid is None: return render_template('standard_runs.html', values=sr.get_standard_runs()) + if request.method =='POST': + new_values = [x[:-8] for x in request.form.keys() if x[-8:] == "_replace"] + new_values = {x:request.form[x+"_value"] for x in new_values} + new_values = {k:v for k,v in new_values.iteritems() if v} + if not new_values: + error = "No new values given. No update performed" + else: + new_uuid = sr.update_standard_run(uuid, new_values) + uuid = new_uuid + sr_info = sr.get_standard_run(uuid) if sr_info is None: return render_template("standard_run.html", error="Requested standard run does not exist") + # Remove values that shouldn't be changed sr_info.pop("version", None) + sr_info.pop("MTC,tub", None) sr_info.pop("timestamp", None) sr_info.pop("time_stamp", None) sr_info.pop("_rev", None) sr_info.pop("_id", None) sr_info.pop("XilinxFilePath", None) + sr_info.pop("type", None) - sr_info = sorted(sr_info.iteritems()) - return render_template("standard_run.html", sr_info=sr_info) - + sr_info = sorted(sr_info.iteritems(), key=lambda x: x[0]) + return render_template("standard_run.html", sr_info=sr_info, uuid=uuid, error=error) From 51f12c41ad20782933b772484bb0d6920d8bb21a Mon Sep 17 00:00:00 2001 From: Eric Marzec Date: Mon, 28 May 2018 12:46:07 -0400 Subject: [PATCH 05/22] allow for trailing slash in some urls --- minard/views.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/minard/views.py b/minard/views.py index 6c1bd202..77f28290 100644 --- a/minard/views.py +++ b/minard/views.py @@ -192,6 +192,7 @@ def calculate_resistors(): return render_template('calculate_resistors.html', crate=crate, slot=slot, resistors=resistors) @app.route('/detector-state-check') +@app.route('/detector-state-check/') @app.route('/detector-state-check/') def detector_state_check(run=None): if run is None: @@ -434,6 +435,7 @@ def detector_state_diff(): detector_state2=detector_state2) @app.route('/state') +@app.route('/state/') @app.route('/state/') def state(run=None): try: From a885cbcdbe208c3287e4c8ce225087cc7715a87b Mon Sep 17 00:00:00 2001 From: Eric Marzec Date: Mon, 28 May 2018 16:29:45 -0400 Subject: [PATCH 06/22] redo form layout and add meta-info inputs --- minard/templates/standard_run.html | 82 +++++++++++++++++------------- minard/views.py | 23 ++++++--- 2 files changed, 64 insertions(+), 41 deletions(-) diff --git a/minard/templates/standard_run.html b/minard/templates/standard_run.html index 5da5829a..1f26326e 100644 --- a/minard/templates/standard_run.html +++ b/minard/templates/standard_run.html @@ -7,50 +7,62 @@ {{ super() }}
{% if error %} -

{{error}}

- {% else %} +

{{error}}

+ {% endif %} + {% if sr_info %} +
+

+ {{sr_info.get('run_type')}} - {{sr_info.get('run_version')}} +

+ {% if updater %} +

+ Last Updated By: {{ updater }} +

+ {% endif %} + {% if comments %} +

+ Notes: {{ comments }} +

+ {% endif %} +
-
- Name -
+
+ + + + + + + + {% for k, v in sr_info.iteritems()|sort %} + + + + + + + {% endfor %} +
Name Current Value New Value Replace?
{{ v }}
-
- Current Value +
+ +
-
- New Value -
-
- Replace? -
-
-

- -
- {% for k, v in sr_info %} -
-
- -
-
-

- {{v}} -

+
+ +
-
- -
-
- + +
+ +
-
- {% endfor %}
- +
-
+
{% endif %}
{% endblock %} diff --git a/minard/views.py b/minard/views.py index 77f28290..3eefebfb 100644 --- a/minard/views.py +++ b/minard/views.py @@ -1584,22 +1584,30 @@ def _dropout_detail_n20(run_number): @app.route("/standard_runs/") @app.route("/standard_runs") def standard_runs(uuid=None): - error = None if uuid is None: return render_template('standard_runs.html', values=sr.get_standard_runs()) if request.method =='POST': + updater = request.form.get("name") + info = request.form.get("info") + passw = request.form.get("password") + print(updater, info, passw) new_values = [x[:-8] for x in request.form.keys() if x[-8:] == "_replace"] new_values = {x:request.form[x+"_value"] for x in new_values} new_values = {k:v for k,v in new_values.iteritems() if v} if not new_values: - error = "No new values given. No update performed" + flash("No new values given. Update not performed", "danger") + elif(passw != app.config["SECRET_KEY"]): + flash("Incorrect password", "danger") else: + new_values["updated_by"] = updater + new_values["comments"] = info new_uuid = sr.update_standard_run(uuid, new_values) uuid = new_uuid - + flash("Updated standard run", "success") sr_info = sr.get_standard_run(uuid) if sr_info is None: - return render_template("standard_run.html", error="Requested standard run does not exist") + flash("Requested standard run does not exist", "danger") + return render_template("standard_run.html") # Remove values that shouldn't be changed sr_info.pop("version", None) @@ -1610,6 +1618,9 @@ def standard_runs(uuid=None): sr_info.pop("_id", None) sr_info.pop("XilinxFilePath", None) sr_info.pop("type", None) + comments = sr_info.pop("comments", None) + updater = sr_info.pop("updated_by", None) + sr_info.pop("Comments", None) - sr_info = sorted(sr_info.iteritems(), key=lambda x: x[0]) - return render_template("standard_run.html", sr_info=sr_info, uuid=uuid, error=error) + return render_template("standard_run.html", sr_info=sr_info, uuid=uuid, + comments=comments, updater=updater) From ab6bf4318db7a3684645c0b322e5c3815be5f263 Mon Sep 17 00:00:00 2001 From: Eric Marzec Date: Mon, 28 May 2018 16:33:14 -0400 Subject: [PATCH 07/22] change comment --- minard/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/minard/views.py b/minard/views.py index 3eefebfb..2a8b0913 100644 --- a/minard/views.py +++ b/minard/views.py @@ -1609,7 +1609,7 @@ def standard_runs(uuid=None): flash("Requested standard run does not exist", "danger") return render_template("standard_run.html") - # Remove values that shouldn't be changed + # Remove values that shouldn't be changed or are just noise sr_info.pop("version", None) sr_info.pop("MTC,tub", None) sr_info.pop("timestamp", None) From b56a205911e12b76ed331e54c624502949172930 Mon Sep 17 00:00:00 2001 From: Eric Marzec Date: Mon, 28 May 2018 16:52:10 -0400 Subject: [PATCH 08/22] add back button if standard run detail view --- minard/templates/standard_run.html | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/minard/templates/standard_run.html b/minard/templates/standard_run.html index 1f26326e..7207b76b 100644 --- a/minard/templates/standard_run.html +++ b/minard/templates/standard_run.html @@ -12,19 +12,24 @@ {% if sr_info %}

+ + + {{sr_info.get('run_type')}} - {{sr_info.get('run_version')}}

- {% if updater %} +
+ {% if updater %} +

Last Updated By: {{ updater }}

- {% endif %} - {% if comments %} -

- Notes: {{ comments }} -

- {% endif %}
+ {% endif %} + {% if comments %} +
+

Notes: {{ comments }}

+
+ {% endif %}
From 017dc0769d2704bbe8f99c33c7e037e738d86062 Mon Sep 17 00:00:00 2001 From: Eric Marzec Date: Mon, 28 May 2018 17:33:24 -0400 Subject: [PATCH 09/22] minor changes --- minard/templates/standard_run.html | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/minard/templates/standard_run.html b/minard/templates/standard_run.html index 7207b76b..a6a0c093 100644 --- a/minard/templates/standard_run.html +++ b/minard/templates/standard_run.html @@ -30,11 +30,12 @@

Notes: {{ comments }}

{% endif %} +

- + @@ -70,7 +71,5 @@

{% endif %} +
{% endblock %} -{% block script %} -{% endblock %} - From 4696ffa9d746d8e90ce659490586bc387053c2d5 Mon Sep 17 00:00:00 2001 From: Eric Marzec Date: Mon, 28 May 2018 17:59:41 -0400 Subject: [PATCH 10/22] add link for standard runs to nav bar --- minard/templates/layout.html | 1 + 1 file changed, 1 insertion(+) diff --git a/minard/templates/layout.html b/minard/templates/layout.html index 61136241..3dc133a0 100644 --- a/minard/templates/layout.html +++ b/minard/templates/layout.html @@ -55,6 +55,7 @@ {{ nav_link('ecal_state_diff', 'ECAL State Diff') }} {{ nav_link('check_rates', 'Check Rates') }} {{ nav_link('update_mtca_crate_mapping', 'Update MTCA+ Mapping') }} + {{ nav_link('standard_runs', 'Standard Runs') }} {{ nav_link('alarms', 'Alarms') }}
  • DAQ Logs
  • {{ nav_link('cavity_temp', 'Cavity Temperature') }} From b61d71ccd170bb98f01ddb73e3087c1cce2be1a5 Mon Sep 17 00:00:00 2001 From: Eric Marzec Date: Mon, 28 May 2018 18:00:20 -0400 Subject: [PATCH 11/22] add template for SR overview (which I forgot to add to git) --- minard/templates/standard_runs.html | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 minard/templates/standard_runs.html diff --git a/minard/templates/standard_runs.html b/minard/templates/standard_runs.html new file mode 100644 index 00000000..900fce04 --- /dev/null +++ b/minard/templates/standard_runs.html @@ -0,0 +1,25 @@ +{% extends "layout.html" %} +{% block title %}Standard Runs{% endblock %} +{% block head %} +{{ super() }} +{% endblock %} +{% block body %} +{{ super() }} +
    +

    Standard Runs

    +
      + {% for k, v in values %} +
    • +

      {{ k }}

      +
      + {% for x in v %} + {{ x.key[2] }} + {% endfor %} +
      +
    • + {% endfor %} +
    +
    +{% endblock %} +{% block script %} +{% endblock %} From 4c48d4633d7b3cc0b4fd7d099b211bb91b3c5a33 Mon Sep 17 00:00:00 2001 From: Eric Marzec Date: Mon, 28 May 2018 18:12:20 -0400 Subject: [PATCH 12/22] Change page title --- minard/templates/standard_run.html | 2 +- minard/templates/standard_runs.html | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/minard/templates/standard_run.html b/minard/templates/standard_run.html index a6a0c093..4987d8d2 100644 --- a/minard/templates/standard_run.html +++ b/minard/templates/standard_run.html @@ -1,5 +1,5 @@ {% extends "layout.html" %} -{% block title %}Standard Runs{% endblock %} +{% block title %}Standard Run{% endblock %} {% block head %} {{ super() }} {% endblock %} diff --git a/minard/templates/standard_runs.html b/minard/templates/standard_runs.html index 900fce04..e0eba606 100644 --- a/minard/templates/standard_runs.html +++ b/minard/templates/standard_runs.html @@ -21,5 +21,3 @@

    {{ k }}

    {% endblock %} -{% block script %} -{% endblock %} From 4e0e5d46e3907fdfba540cc2a3bdc5d5c3215afc Mon Sep 17 00:00:00 2001 From: Eric Marzec Date: Wed, 30 May 2018 15:10:05 -0400 Subject: [PATCH 13/22] create new documents rather then new versions of existing ones --- minard/standard_runs.py | 11 +++++++---- minard/views.py | 1 - 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/minard/standard_runs.py b/minard/standard_runs.py index b0b91134..6bedb4dd 100644 --- a/minard/standard_runs.py +++ b/minard/standard_runs.py @@ -1,9 +1,10 @@ import couchdb from itertools import groupby from .views import app +from uuid import uuid4 def get_standard_runs(): - couch = couchdb.Server("http://snoplus:"+app.config["COUCHDB_PASSWORD"]+"@"+app.config["COUCHDB_HOSTNAME"]) + couch = couchdb.Server("https://snoplus:"+app.config["COUCHDB_PASSWORD"]+"@"+app.config["COUCHDB_HOSTNAME"]) orca_db = couch['orca'] sr_view = orca_db.view("standardRuns/getStandardRunsWithVersion") # standard run keys are [doc-version, run name, run version, timestamp] @@ -18,15 +19,17 @@ def get_standard_runs(): return runs def get_standard_run(uuid): - couch = couchdb.Server("http://snoplus:"+app.config["COUCHDB_PASSWORD"]+"@"+app.config["COUCHDB_HOSTNAME"]) + couch = couchdb.Server("https://snoplus:"+app.config["COUCHDB_PASSWORD"]+"@"+app.config["COUCHDB_HOSTNAME"]) orca_db = couch['orca'] return orca_db.get(uuid) def update_standard_run(uuid, new_values): - couch = couchdb.Server("http://snoplus:"+app.config["COUCHDB_PASSWORD"]+"@"+app.config["COUCHDB_HOSTNAME"]) + couch = couchdb.Server("https://snoplus:"+app.config["COUCHDB_PASSWORD"]+"@"+app.config["COUCHDB_HOSTNAME"]) orca_db = couch['orca'] - doc = orca_db.get(uuid) + doc = dict(orca_db.get(uuid)) for k, v in new_values.iteritems(): doc[k] = v + doc["_id"] = uuid4().hex + del doc["_rev"] new_uuid, _ = orca_db.save(doc) return new_uuid diff --git a/minard/views.py b/minard/views.py index 2a8b0913..387ab42d 100644 --- a/minard/views.py +++ b/minard/views.py @@ -1590,7 +1590,6 @@ def standard_runs(uuid=None): updater = request.form.get("name") info = request.form.get("info") passw = request.form.get("password") - print(updater, info, passw) new_values = [x[:-8] for x in request.form.keys() if x[-8:] == "_replace"] new_values = {x:request.form[x+"_value"] for x in new_values} new_values = {k:v for k,v in new_values.iteritems() if v} From 7d5d4e8be58eef832838702bdfc0f88669b5154d Mon Sep 17 00:00:00 2001 From: Eric Marzec Date: Thu, 31 May 2018 17:27:18 -0400 Subject: [PATCH 14/22] update timestamp for new documents --- minard/standard_runs.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/minard/standard_runs.py b/minard/standard_runs.py index 6bedb4dd..3264690c 100644 --- a/minard/standard_runs.py +++ b/minard/standard_runs.py @@ -1,6 +1,7 @@ import couchdb from itertools import groupby from .views import app +from time import time from uuid import uuid4 def get_standard_runs(): @@ -30,6 +31,11 @@ def update_standard_run(uuid, new_values): for k, v in new_values.iteritems(): doc[k] = v doc["_id"] = uuid4().hex - del doc["_rev"] + doc["time_stamp"] = time() + try: + del doc["_rev"] + except KeyError: + pass + new_uuid, _ = orca_db.save(doc) return new_uuid From 236555e0a8184ff6cf1e2285e580981cd64e98ae Mon Sep 17 00:00:00 2001 From: Eric Marzec Date: Thu, 31 May 2018 17:35:33 -0400 Subject: [PATCH 15/22] redirect to new standard run upon creation of one --- minard/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/minard/views.py b/minard/views.py index 387ab42d..e2eddc0b 100644 --- a/minard/views.py +++ b/minard/views.py @@ -1601,8 +1601,8 @@ def standard_runs(uuid=None): new_values["updated_by"] = updater new_values["comments"] = info new_uuid = sr.update_standard_run(uuid, new_values) - uuid = new_uuid flash("Updated standard run", "success") + return redirect(url_for("standard_runs",uuid=new_uuid)) sr_info = sr.get_standard_run(uuid) if sr_info is None: flash("Requested standard run does not exist", "danger") @@ -1617,9 +1617,9 @@ def standard_runs(uuid=None): sr_info.pop("_id", None) sr_info.pop("XilinxFilePath", None) sr_info.pop("type", None) + sr_info.pop("Comments", None) comments = sr_info.pop("comments", None) updater = sr_info.pop("updated_by", None) - sr_info.pop("Comments", None) return render_template("standard_run.html", sr_info=sr_info, uuid=uuid, comments=comments, updater=updater) From 25a0fe1856c3aa54a216987e82d5c16053b41c26 Mon Sep 17 00:00:00 2001 From: Eric Marzec Date: Thu, 31 May 2018 18:01:14 -0400 Subject: [PATCH 16/22] Add error checking for couchdb interactions --- minard/templates/standard_run.html | 3 --- minard/templates/standard_runs.html | 2 ++ minard/views.py | 29 +++++++++++++++++++++++------ 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/minard/templates/standard_run.html b/minard/templates/standard_run.html index 4987d8d2..fc911394 100644 --- a/minard/templates/standard_run.html +++ b/minard/templates/standard_run.html @@ -6,9 +6,6 @@ {% block body %} {{ super() }}
    - {% if error %} -

    {{error}}

    - {% endif %} {% if sr_info %}

    diff --git a/minard/templates/standard_runs.html b/minard/templates/standard_runs.html index e0eba606..705c58a1 100644 --- a/minard/templates/standard_runs.html +++ b/minard/templates/standard_runs.html @@ -6,6 +6,7 @@ {% block body %} {{ super() }}
    + {% if values %}

    Standard Runs

      {% for k, v in values %} @@ -19,5 +20,6 @@

      {{ k }}

      {% endfor %}
    + {% endif %}
    {% endblock %} diff --git a/minard/views.py b/minard/views.py index e2eddc0b..8080171c 100644 --- a/minard/views.py +++ b/minard/views.py @@ -1585,7 +1585,12 @@ def _dropout_detail_n20(run_number): @app.route("/standard_runs") def standard_runs(uuid=None): if uuid is None: - return render_template('standard_runs.html', values=sr.get_standard_runs()) + values = None + try: + values = sr.get_standard_runs() + except sr.couchdb.http.socket.error: + flash("Error connecting to database, could not retrieve standard runs", "danger") + return render_template('standard_runs.html', values=values) if request.method =='POST': updater = request.form.get("name") info = request.form.get("info") @@ -1600,12 +1605,24 @@ def standard_runs(uuid=None): else: new_values["updated_by"] = updater new_values["comments"] = info - new_uuid = sr.update_standard_run(uuid, new_values) - flash("Updated standard run", "success") - return redirect(url_for("standard_runs",uuid=new_uuid)) - sr_info = sr.get_standard_run(uuid) + try: + new_uuid = sr.update_standard_run(uuid, new_values) + flash("Updated standard run", "success") + uuid = new_uuid + except sr.couchdb.http.socket.error: + flash("Error connecting to database, standard run not updated", "danger") + + return redirect(url_for("standard_runs",uuid=uuid)) + + error_string = "Requested standard run does not exist" + try: + sr_info = sr.get_standard_run(uuid) + except sr.couchdb.http.socket.error: + sr_info = None + error_string = "Error connecting to database" + if sr_info is None: - flash("Requested standard run does not exist", "danger") + flash(error_string, "danger") return render_template("standard_run.html") # Remove values that shouldn't be changed or are just noise From b7e01d779d16ebd6156db39aa6e4ab42e59963ef Mon Sep 17 00:00:00 2001 From: Eric Marzec Date: Thu, 31 May 2018 18:59:23 -0400 Subject: [PATCH 17/22] add some basic validation --- minard/standard_runs.py | 9 +++++++++ minard/views.py | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/minard/standard_runs.py b/minard/standard_runs.py index 3264690c..73b501ff 100644 --- a/minard/standard_runs.py +++ b/minard/standard_runs.py @@ -32,6 +32,15 @@ def update_standard_run(uuid, new_values): doc[k] = v doc["_id"] = uuid4().hex doc["time_stamp"] = time() + + if not doc.has_key("run_version") or not bool(doc["run_version"]): + raise RuntimeError("run_version must be present in new document") + + if not doc.has_key("run_type") or not bool(doc["run_type"]): + raise RuntimeError("run_type must be present in new document") + + doc["run_type"] = doc["run_type"].upper() + doc["run_version"] = doc["run_version"].upper() try: del doc["_rev"] except KeyError: diff --git a/minard/views.py b/minard/views.py index 8080171c..f79554ee 100644 --- a/minard/views.py +++ b/minard/views.py @@ -1611,7 +1611,8 @@ def standard_runs(uuid=None): uuid = new_uuid except sr.couchdb.http.socket.error: flash("Error connecting to database, standard run not updated", "danger") - + except RuntimeError as e: + flash("Did not update standard run: %s" % str(e), "danger") return redirect(url_for("standard_runs",uuid=uuid)) error_string = "Requested standard run does not exist" From 90fc79967e35183532968390dfa97d1cc3e57ec9 Mon Sep 17 00:00:00 2001 From: Eric Marzec Date: Thu, 31 May 2018 19:42:10 -0400 Subject: [PATCH 18/22] coerce types for new values --- minard/views.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/minard/views.py b/minard/views.py index f79554ee..5d9955a7 100644 --- a/minard/views.py +++ b/minard/views.py @@ -1597,7 +1597,11 @@ def standard_runs(uuid=None): passw = request.form.get("password") new_values = [x[:-8] for x in request.form.keys() if x[-8:] == "_replace"] new_values = {x:request.form[x+"_value"] for x in new_values} - new_values = {k:v for k,v in new_values.iteritems() if v} + # Convert values from strings to floats/integers/bools if appropriate + new_values = {k:True if v.lower() == 'true' else v for k,v in new_values.iteritems() if v} + new_values = {k:False if v.lower() == 'false' else v for k,v in new_values.iteritems()} + new_values = {k:float(v) if v.isdigit() else v for k,v in new_values.iteritems()} + new_values = {k:int(v) if type(v)==float and v.is_integer() else v for k,v in new_values.iteritems()} if not new_values: flash("No new values given. Update not performed", "danger") elif(passw != app.config["SECRET_KEY"]): From d290e2196aac7b5f21f0ae27264cfca5239ba03e Mon Sep 17 00:00:00 2001 From: Eric Marzec Date: Fri, 1 Jun 2018 13:15:33 -0400 Subject: [PATCH 19/22] Only display standard runs matching orca's standard run version --- minard/standard_runs.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/minard/standard_runs.py b/minard/standard_runs.py index 73b501ff..7d8c40de 100644 --- a/minard/standard_runs.py +++ b/minard/standard_runs.py @@ -5,13 +5,16 @@ from uuid import uuid4 def get_standard_runs(): + # This number should match the version used by ORCA + COUCH_DOC_VERSION = app.config["ORCA_STANDARD_RUN_VERSION"] couch = couchdb.Server("https://snoplus:"+app.config["COUCHDB_PASSWORD"]+"@"+app.config["COUCHDB_HOSTNAME"]) orca_db = couch['orca'] sr_view = orca_db.view("standardRuns/getStandardRunsWithVersion") # standard run keys are [doc-version, run name, run version, timestamp] # I want to groupby by run name then within that group all run versions sorted # by timestamp - rows = sorted(sr_view.rows, key=lambda x: x.key[1] + x.key[2]) + rows = filter(lambda x: x.key[0] == COUCH_DOC_VERSION, sr_view.rows) + rows = sorted(rows, key=lambda x: x.key[1] + x.key[2]) groups = groupby(rows, lambda x: x.key[1] + x.key[2]) groups = [(x, list(y)) for x, y in groups] runs = [max(group, key=lambda x: x.key[3]) for _, group in groups] @@ -33,14 +36,17 @@ def update_standard_run(uuid, new_values): doc["_id"] = uuid4().hex doc["time_stamp"] = time() - if not doc.has_key("run_version") or not bool(doc["run_version"]): + if not doc.has_key("run_version") or not doc["run_version"]: raise RuntimeError("run_version must be present in new document") - if not doc.has_key("run_type") or not bool(doc["run_type"]): + if not doc.has_key("run_type") or not doc["run_type"]: raise RuntimeError("run_type must be present in new document") doc["run_type"] = doc["run_type"].upper() doc["run_version"] = doc["run_version"].upper() + + # Remove revision field since we want to post a new document, not a + # revision of an existing one. try: del doc["_rev"] except KeyError: From b8522dee99421f09fcc89835a9ce2a1b2c0c364b Mon Sep 17 00:00:00 2001 From: Eric Marzec Date: Fri, 1 Jun 2018 13:26:56 -0400 Subject: [PATCH 20/22] remove dictionary list comprehesion for python 2.6 --- minard/views.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/minard/views.py b/minard/views.py index 5d9955a7..4ecaa536 100644 --- a/minard/views.py +++ b/minard/views.py @@ -1596,12 +1596,13 @@ def standard_runs(uuid=None): info = request.form.get("info") passw = request.form.get("password") new_values = [x[:-8] for x in request.form.keys() if x[-8:] == "_replace"] - new_values = {x:request.form[x+"_value"] for x in new_values} + new_values = [(x,request.form[x+"_value"]) for x in new_values] # Convert values from strings to floats/integers/bools if appropriate - new_values = {k:True if v.lower() == 'true' else v for k,v in new_values.iteritems() if v} - new_values = {k:False if v.lower() == 'false' else v for k,v in new_values.iteritems()} - new_values = {k:float(v) if v.isdigit() else v for k,v in new_values.iteritems()} - new_values = {k:int(v) if type(v)==float and v.is_integer() else v for k,v in new_values.iteritems()} + new_values = [(k, True if v.lower() == 'true' else v) for k,v in new_values if v] + new_values = [(k, False if v.lower() == 'false' else v) for k,v in new_values] + new_values = [(k, float(v) if v.isdigit() else v) for k,v in new_values] + new_values = [(k, int(v) if type(v)==float and v.is_integer() else v) for k,v in new_values] + new_values = dict(new_values) if not new_values: flash("No new values given. Update not performed", "danger") elif(passw != app.config["SECRET_KEY"]): From f8eacba422b02e634dd58ec526fe73dcc17305ec Mon Sep 17 00:00:00 2001 From: Eric Marzec Date: Sat, 2 Jun 2018 16:10:30 -0400 Subject: [PATCH 21/22] move standard run password validation to couch DB --- minard/standard_runs.py | 21 +++++++++++++++++---- minard/views.py | 2 -- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/minard/standard_runs.py b/minard/standard_runs.py index 7d8c40de..ee4b6cab 100644 --- a/minard/standard_runs.py +++ b/minard/standard_runs.py @@ -7,7 +7,8 @@ def get_standard_runs(): # This number should match the version used by ORCA COUCH_DOC_VERSION = app.config["ORCA_STANDARD_RUN_VERSION"] - couch = couchdb.Server("https://snoplus:"+app.config["COUCHDB_PASSWORD"]+"@"+app.config["COUCHDB_HOSTNAME"]) + url = "https://%s:%s@%s" % ("snoplus", app.config["COUCHDB_PASSWORD"], app.config["COUCHDB_HOSTNAME"]) + couch = couchdb.Server(url) orca_db = couch['orca'] sr_view = orca_db.view("standardRuns/getStandardRunsWithVersion") # standard run keys are [doc-version, run name, run version, timestamp] @@ -23,13 +24,25 @@ def get_standard_runs(): return runs def get_standard_run(uuid): - couch = couchdb.Server("https://snoplus:"+app.config["COUCHDB_PASSWORD"]+"@"+app.config["COUCHDB_HOSTNAME"]) + url = "https://%s:%s@%s" % ("snoplus", app.config["COUCHDB_PASSWORD"], app.config["COUCHDB_HOSTNAME"]) + couch = couchdb.Server(url) orca_db = couch['orca'] return orca_db.get(uuid) def update_standard_run(uuid, new_values): - couch = couchdb.Server("https://snoplus:"+app.config["COUCHDB_PASSWORD"]+"@"+app.config["COUCHDB_HOSTNAME"]) - orca_db = couch['orca'] + try: + password = new_values["password"] + except KeyError: + raise RuntimeError("no password given") + url = "https://%s:%s@%s" % (app.config["COUCH_DETECTOR_EXPERT_NAME"], + password, + app.config["COUCHDB_HOSTNAME"]) + couch = couchdb.Server(url) + try: + orca_db = couch['orca'] + except coucdb.http.Unautorized: + raise RuntimeError("Incorrect password given") + doc = dict(orca_db.get(uuid)) for k, v in new_values.iteritems(): doc[k] = v diff --git a/minard/views.py b/minard/views.py index 4ecaa536..271c5149 100644 --- a/minard/views.py +++ b/minard/views.py @@ -1605,8 +1605,6 @@ def standard_runs(uuid=None): new_values = dict(new_values) if not new_values: flash("No new values given. Update not performed", "danger") - elif(passw != app.config["SECRET_KEY"]): - flash("Incorrect password", "danger") else: new_values["updated_by"] = updater new_values["comments"] = info From 79e41e44e3809c6d1fefb2125764594abb01d39e Mon Sep 17 00:00:00 2001 From: Eric Marzec Date: Thu, 7 Jun 2018 15:12:47 -0400 Subject: [PATCH 22/22] reimplement UI using wtforms and add validators --- minard/standard_runs.py | 80 +++++++++++++++++++++++++-- minard/templates/standard_run.html | 86 +++++++++++++++++------------- minard/views.py | 42 +++++++-------- 3 files changed, 146 insertions(+), 62 deletions(-) diff --git a/minard/standard_runs.py b/minard/standard_runs.py index ee4b6cab..a3398192 100644 --- a/minard/standard_runs.py +++ b/minard/standard_runs.py @@ -1,8 +1,10 @@ import couchdb -from itertools import groupby from .views import app +from itertools import groupby from time import time from uuid import uuid4 +from wtforms import Form, IntegerField, StringField, TextAreaField, PasswordField,\ + DecimalField, BooleanField, validators def get_standard_runs(): # This number should match the version used by ORCA @@ -31,7 +33,7 @@ def get_standard_run(uuid): def update_standard_run(uuid, new_values): try: - password = new_values["password"] + password = new_values.pop("password", None) except KeyError: raise RuntimeError("no password given") url = "https://%s:%s@%s" % (app.config["COUCH_DETECTOR_EXPERT_NAME"], @@ -40,7 +42,7 @@ def update_standard_run(uuid, new_values): couch = couchdb.Server(url) try: orca_db = couch['orca'] - except coucdb.http.Unautorized: + except couchdb.http.Unauthorized: raise RuntimeError("Incorrect password given") doc = dict(orca_db.get(uuid)) @@ -67,3 +69,75 @@ def update_standard_run(uuid, new_values): new_uuid, _ = orca_db.save(doc) return new_uuid + +expected_fields = [ + IntegerField("CAEN_acquisitionMode", [validators.NumberRange(min=0, max=0b111)]), + IntegerField("CAEN_channelConfigMask"), + IntegerField("CAEN_coincidenceLevel"), + BooleanField("CAEN_countAllTriggers"), + IntegerField("CAEN_customSize"), + IntegerField("CAEN_dac_0", [validators.NumberRange(min=0, max=0xFFFF)]), + IntegerField("CAEN_dac_1", [validators.NumberRange(min=0, max=0xFFFF)]), + IntegerField("CAEN_dac_2", [validators.NumberRange(min=0, max=0xFFFF)]), + IntegerField("CAEN_dac_3", [validators.NumberRange(min=0, max=0xFFFF)]), + IntegerField("CAEN_dac_4", [validators.NumberRange(min=0, max=0xFFFF)]), + IntegerField("CAEN_dac_5", [validators.NumberRange(min=0, max=0xFFFF)]), + IntegerField("CAEN_dac_6", [validators.NumberRange(min=0, max=0xFFFF)]), + IntegerField("CAEN_dac_7", [validators.NumberRange(min=0, max=0xFFFF)]), + IntegerField("CAEN_enabledMask", [validators.NumberRange(min=0, max=0xFF)]), + IntegerField("CAEN_eventSize"), + IntegerField("CAEN_frontPanelControlMask"), + BooleanField("CAEN_isCustomSize"), + IntegerField("CAEN_postTriggerSetting"), + IntegerField("CAEN_triggerOutMask"), + IntegerField("CAEN_triggerSourceMask"), + IntegerField("MTC_ESUMH_Threshold", [validators.NumberRange(min=0,max=4095)]), + IntegerField("MTC_ESUML_Threshold", [validators.NumberRange(min=0,max=4095)]), + IntegerField("MTC_GTMask", [validators.NumberRange(min=0, max=0x3FFFFFF)]), + IntegerField("MTC_LockoutWidth", [validators.NumberRange(min=20, max=5000)]), + IntegerField("MTC_N100H_Threshold", [validators.NumberRange(min=0, max=4095)]), + IntegerField("MTC_N100L_Threshold", [validators.NumberRange(min=0, max=4095)]), + IntegerField("MTC_N100M_Threshold", [validators.NumberRange(min=0, max=4095)]), + IntegerField("MTC_N20LB_Threshold", [validators.NumberRange(min=0, max=4095)]), + IntegerField("MTC_N20_Threshold", [validators.NumberRange(min=0, max=4095)]), + IntegerField("MTC_OWLEH_Threshold", [validators.NumberRange(min=0, max=4095)]), + IntegerField("MTC_OWLEL_Threshold", [validators.NumberRange(min=0, max=4095)]), + IntegerField("MTC_OWLN_Threshold", [validators.NumberRange(min=0, max=4095)]), + IntegerField("MTC_PrescaleValue", [validators.NumberRange(min=2, max=65536)]), + BooleanField("MTC_PulserEnabled"), + BooleanField("MTC_PulserMode"), + DecimalField("MTC_PulserRate", [validators.NumberRange(min=0.04, max=390000)]), + IntegerField("TUBii_CaenChannelMask", [validators.NumberRange(min=0, max=255)]), + IntegerField("TUBii_CaenGainMask", [validators.NumberRange(min=0, max=255)]), + IntegerField("TUBii_DGT_Bits", [validators.NumberRange(min=0, max=255)]), + IntegerField("TUBii_LO_Bits", [validators.NumberRange(min=0, max=255)]), + IntegerField("TUBii_MTCAMimic1_ThresholdInBits", [validators.NumberRange(min=0, max=4095)]), + IntegerField("TUBii_TUBiiPGT_Rate", [validators.NumberRange(min=0)]), + IntegerField("TUBii_asyncTrigMask"), + IntegerField('TUBii_controlReg', [validators.NumberRange(min=0,max=255)]), + IntegerField('TUBii_counterMask', [validators.NumberRange(min=0)]), + IntegerField('TUBii_speakerMask', [validators.NumberRange(min=0)]), + IntegerField('TUBii_syncTrigMask', [validators.NumberRange(min=0)]), + IntegerField("run_type_word", [validators.NumberRange(min=0x0, max=0xFFFFFFF)]), + StringField("run_version", [validators.DataRequired()]), + StringField("type", [validators.DataRequired()]) +] +expected_fields = dict([(x.args[0], x) for x in expected_fields]) + +def create_form(fields): + class SRSettingsForm(Form): + name = StringField('Name', [validators.DataRequired()]) + info = TextAreaField('Info', [validators.DataRequired()]) + password = PasswordField('Password', [validators.DataRequired()]) + + # First create a form for the various fields in the couchDB doc + for key, value in fields.iteritems(): + # skip any fields that are already in the form + if key.lower() in ["name", "info", "password"]: + continue + if expected_fields.has_key(key): + field = expected_fields[key] + setattr(SRSettingsForm, key, field) + else: + setattr(SRSettingsForm, key, StringField(key)) + return SRSettingsForm diff --git a/minard/templates/standard_run.html b/minard/templates/standard_run.html index fc911394..139fa559 100644 --- a/minard/templates/standard_run.html +++ b/minard/templates/standard_run.html @@ -6,13 +6,22 @@ {% block body %} {{ super() }}
    - {% if sr_info %} + {% if form %} + {% if form.errors %} +
      + {% for field_name, field_errors in form.errors|dictsort if field_errors %} + {% for error in field_errors %} +
    • {{ form[field_name].label }}: {{ error }}
    • + {% endfor %} + {% endfor %} +
    + {% endif %}

    - {{sr_info.get('run_type')}} - {{sr_info.get('run_version')}} + {{ form.run_type.data }} - {{ form.run_version.data }}

    {% if updater %} @@ -29,43 +38,44 @@

    {% endif %}
    - -

    Name Setting Current Value New Value Replace?
    - - - - - - - {% for k, v in sr_info.iteritems()|sort %} - - - - - - - {% endfor %} -
    Setting Current Value New Value Replace?
    {{ v }}
    - -
    - - -
    - -
    - - -
    - -
    - - -
    -
    - -
    -
    +
    +
    + + + + + + + {% for field in form %} + {% if field.label.text.lower() not in ['name', 'password', 'info'] %} + + + + + + {% endif %} + {% endfor %} +
    Setting Current Value New Value
    {{ field.label }} {{ field.data }} {{ field()}}
    +
    + {{ form.name.label }} + {{ form.name(class="form-control",style="width:500px") }} +
    +
    + {{ form.info.label }} + {{ form.info(class="form-control",style="width:500px") }} +
    +
    + {{ form.password.label }} + {{ form.password(class="form-control",style="width:500px") }} +
    +
    + +
    +
    +
    + {% else %} +

    No form provided...not sure how this happened.

    {% endif %}

    diff --git a/minard/views.py b/minard/views.py index 271c5149..687e59c9 100644 --- a/minard/views.py +++ b/minard/views.py @@ -1591,23 +1591,16 @@ def standard_runs(uuid=None): except sr.couchdb.http.socket.error: flash("Error connecting to database, could not retrieve standard runs", "danger") return render_template('standard_runs.html', values=values) + if request.method =='POST': - updater = request.form.get("name") - info = request.form.get("info") - passw = request.form.get("password") - new_values = [x[:-8] for x in request.form.keys() if x[-8:] == "_replace"] - new_values = [(x,request.form[x+"_value"]) for x in new_values] - # Convert values from strings to floats/integers/bools if appropriate - new_values = [(k, True if v.lower() == 'true' else v) for k,v in new_values if v] - new_values = [(k, False if v.lower() == 'false' else v) for k,v in new_values] - new_values = [(k, float(v) if v.isdigit() else v) for k,v in new_values] - new_values = [(k, int(v) if type(v)==float and v.is_integer() else v) for k,v in new_values] - new_values = dict(new_values) - if not new_values: - flash("No new values given. Update not performed", "danger") - else: - new_values["updated_by"] = updater - new_values["comments"] = info + Form = sr.create_form(request.form) + form = Form(request.form) + if form.validate(): + # Change form to a dict + new_values = {} + for field in form: + new_values[field.name] = field.data + try: new_uuid = sr.update_standard_run(uuid, new_values) flash("Updated standard run", "success") @@ -1618,6 +1611,10 @@ def standard_runs(uuid=None): flash("Did not update standard run: %s" % str(e), "danger") return redirect(url_for("standard_runs",uuid=uuid)) + else: + flash("Did not update standard run, new settings are not valid", "danger") + return render_template("standard_run.html", form=form, uuid=uuid) + error_string = "Requested standard run does not exist" try: sr_info = sr.get_standard_run(uuid) @@ -1631,16 +1628,19 @@ def standard_runs(uuid=None): # Remove values that shouldn't be changed or are just noise sr_info.pop("version", None) - sr_info.pop("MTC,tub", None) sr_info.pop("timestamp", None) sr_info.pop("time_stamp", None) sr_info.pop("_rev", None) sr_info.pop("_id", None) - sr_info.pop("XilinxFilePath", None) sr_info.pop("type", None) sr_info.pop("Comments", None) - comments = sr_info.pop("comments", None) - updater = sr_info.pop("updated_by", None) + comments = sr_info.pop("info", None) + updater = sr_info.pop("name", None) + - return render_template("standard_run.html", sr_info=sr_info, uuid=uuid, + Form = sr.create_form(sr_info) + form = Form() + for k, v in sr_info.iteritems(): + form[k].data = v + return render_template("standard_run.html", form=form, uuid=uuid, comments=comments, updater=updater)