diff --git a/microsetta_admin/server.py b/microsetta_admin/server.py index e3439a9..f1530d4 100644 --- a/microsetta_admin/server.py +++ b/microsetta_admin/server.py @@ -404,8 +404,8 @@ def per_sample_summary(): **build_login_variables()) else: search_field = request.form.get('search_field') - search_value = request.form.get('text_input') - uploaded_file = request.files.get('file') + search_value = request.form.get('single_search') + uploaded_file = request.files.get('upload_list') search_values = [] @@ -420,16 +420,7 @@ def per_sample_summary(): search_values = [search_value] if search_value else [] payload = {} - if search_field == 'sample_barcode': - payload['sample_barcodes'] = search_values - elif search_field == 'kit_id': - payload['kit_ids'] = search_values - elif search_field == 'email': - payload['emails'] = search_values - elif search_field == 'outbound_tracking': - payload['outbound_tracking_numbers'] = search_values - elif search_field == 'inbound_tracking': - payload['inbound_tracking_numbers'] = search_values + payload[search_field] = search_values # perform the main query. status, result = APIRequest.post('/api/admin/account_barcode_summary?' @@ -447,7 +438,15 @@ def per_sample_summary(): order = ['sampleid', 'project', 'account-email', 'source-type', 'site-sampled', 'sample-date', 'sample-time', 'sample-status', 'sample-received', - 'ffq-taken', 'ffq-complete', 'vioscreen_username'] + 'first-scan-status', 'first-scan-timestamp', + 'latest-scan-status', 'latest-scan-timestamp', + 'sample-has-inconsistencies', 'sample-is-valid', + 'no-associated-source', 'no-collection-info', + 'no-registered-account', 'received-unknown-validity', + 'ffq-taken', 'ffq-complete', 'vioscreen_username', + 'kit-id', 'outbound-tracking', + 'inbound-tracking' + ] order.extend(sorted(set(resource.columns) - set(order))) resource = resource[order] else: diff --git a/microsetta_admin/templates/per_sample_summary.html b/microsetta_admin/templates/per_sample_summary.html index 6786fa5..214281d 100644 --- a/microsetta_admin/templates/per_sample_summary.html +++ b/microsetta_admin/templates/per_sample_summary.html @@ -13,16 +13,20 @@ }; function handleFormSubmit(event) { - var fileInput = document.getElementById('file'); - var textInput = document.getElementById('text_input'); + var fileInput = document.getElementById('upload_list'); + var textInput = document.getElementById('single_search'); - if (fileInput.files.length > 0 || textInput.value.trim() !== "") { - remove_error_messages(); - return true; - } else { - alert('Please provide either a file or text input.'); + if (fileInput.files.length > 0 && textInput.value.trim() !== "") { + alert("Please provide either a text input or a file, not both."); + event.preventDefault(); + return false; + } else if (fileInput.files.length === 0 && textInput.value.trim() === "") { + alert("Please provide either a text input or a file."); event.preventDefault(); return false; + } else { + remove_error_messages(); + return true; } } @@ -55,22 +59,22 @@