From 01ee17dd2be93c7b486d2d43d102a8a20aac113a Mon Sep 17 00:00:00 2001 From: Greg Von Kuster Date: Thu, 16 Jun 2011 10:54:29 -0400 Subject: [PATCH] Add the ability to include field values (in addition to field names ) when defining sample form rows by importing from a csv file. The csv file must be in the following format: the [:FieldValue] is optional, the named form field will contain the value after the ':' if included. SampleName,DataLibraryName,FolderName,HistoryName,WorkflowName,Field1Name:Field1Value,Field2Name:Field2Value... --- lib/galaxy/web/controllers/requests_common.py | 13 ++++++++++--- templates/requests/common/add_samples.mako | 5 +++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/galaxy/web/controllers/requests_common.py b/lib/galaxy/web/controllers/requests_common.py index e19dce3de60..977905c59ed 100644 --- a/lib/galaxy/web/controllers/requests_common.py +++ b/lib/galaxy/web/controllers/requests_common.py @@ -1049,8 +1049,9 @@ class RequestsCommon( BaseController, UsesFormDefinitions ): status=status ) def __import_samples( self, trans, cntrller, request, displayable_sample_widgets, libraries, workflows, **kwd ): """ - Reads the samples csv file and imports all the samples. The format of the csv file is: - SampleName,DataLibraryName,DataLibraryFolderName,HistoryName,WorkflowName,Field1Name,Field2Name... + Reads the samples csv file and imports all the samples. The csv file must be in the following format. The [:FieldValue] + is optional, the form field will contain the value after the ':' if included. + SampleName,DataLibraryName,DataLibraryFolderName,HistoryName,WorkflowName,Field1Name:Field1Value,Field2Name:Field2Value... """ params = util.Params( kwd ) current_user_roles = trans.get_current_user_roles() @@ -1123,7 +1124,13 @@ class RequestsCommon( BaseController, UsesFormDefinitions ): field_values = {} field_names = row[5:] for field_name in field_names: - field_values[ field_name ] = '' + if field_name.find( ':' ) >= 0: + field_list = field_name.split( ':' ) + field_name = field_list[0] + field_value = field_list[1] + else: + field_value = '' + field_values[ field_name ] = field_value displayable_sample_widgets.append( dict( id=None, name=row[0], bar_code='', diff --git a/templates/requests/common/add_samples.mako b/templates/requests/common/add_samples.mako index c46f194e61d..e79584124c7 100644 --- a/templates/requests/common/add_samples.mako +++ b/templates/requests/common/add_samples.mako @@ -117,8 +117,9 @@ ${render_samples_messages(request, is_admin, is_submitted, message, status)}
- The csv file must be in the following format:
- SampleName,DataLibraryName,DataLibraryFolderName,HistoryName,WorkflowName,Field1Name,Field2Name... + The csv file must be in the following format.
+ The [:FieldValue] is optional, the named form field will contain the value after the ':' if included.
+ SampleName,DataLibraryName,FolderName,HistoryName,WorkflowName,Field1Name:Field1Value,Field2Name:Field2Value...