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 %} +
+ {{ error_message |e }} +
+ {% endif %} + +