diff --git a/microsetta_admin/server.py b/microsetta_admin/server.py index 0f0afb1..a689bba 100644 --- a/microsetta_admin/server.py +++ b/microsetta_admin/server.py @@ -326,6 +326,52 @@ def urlify_account_id(id_): projects=projects) +@app.route('/per_sample_summary', methods=['GET', 'POST']) +def per_sample_summary(): + strip_sampleid = request.form.get('strip_sampleid', 'off') + strip_sampleid = strip_sampleid.lower() == 'on' + + if request.method == 'GET': + sample_barcode = request.args.get('sample_barcode') + if sample_barcode is None: + return render_template('per_sample_summary.html', + resource=None, + **build_login_variables()) + sample_barcodes = [sample_barcode, ] + elif request.method == 'POST': + sample_barcodes, upload_err = upload_util.parse_request_csv_col( + request, + 'file', + 'sample_name' + ) + if upload_err is not None: + return render_template('per_sample_summary.html', + resource=None, + **build_login_variables(), + search_error=[{'error': upload_err}]) + + payload = {'sample_barcodes': sample_barcodes} + status, result = APIRequest.post('/api/admin/account_barcode_summary?' + 'strip_sampleid=%s' % str(strip_sampleid), + json=payload) + if status != 200: + return render_template('per_sample_summary.html', + resource=None, + error_message=result, + **build_login_variables()) + else: + resource = pd.DataFrame(result) + order = ['sampleid', 'project', 'account-email', 'source-email', + 'source-type', 'site-sampled', 'sample-status', + 'sample-received', 'ffq-taken', 'ffq-complete', + 'vioscreen_username'] + order.extend(sorted(set(resource.columns) - set(order))) + resource = resource[order] + return render_template('per_sample_summary.html', + resource=resource, + **build_login_variables()) + + @app.route('/create_kits', methods=['GET', 'POST']) def new_kits(): _, result = _get_projects(include_stats=False, is_active=True) diff --git a/microsetta_admin/templates/per_sample_summary.html b/microsetta_admin/templates/per_sample_summary.html new file mode 100644 index 0000000..a755e3a --- /dev/null +++ b/microsetta_admin/templates/per_sample_summary.html @@ -0,0 +1,64 @@ +{% extends "sitebase.html" %} +{% block head %} + + + + + +{% endblock %} +{% block content %} +

Microsetta Per Sample Summary

+
+ {% if error_message %} +

+ {{ error_message |e }} +

+ {% endif %} +
+ + + + + + + +
+ +
+
+ Or upload a file of barcodes listed in the column "sample_name" (max: 1000) +
+
+ +
+
+ +
+ {% if resource is not none %} +
+ {{resource.to_html(table_id="search_results", classes=["display"], render_links=True, escape=False) |safe}} +
+
+{% endif %} +{{blob}} +{% endblock %} diff --git a/microsetta_admin/templates/sitebase.html b/microsetta_admin/templates/sitebase.html index 38d4344..56309f7 100644 --- a/microsetta_admin/templates/sitebase.html +++ b/microsetta_admin/templates/sitebase.html @@ -49,6 +49,7 @@

Microsetta Utilities

  • Create Kit
  • Scan Barcode
  • Retrieve Metadata
  • +
  • Per sample summary
  • Submit Daklapack Order
  • Log Out
    ({{email |e}})
  • {% else %}