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...
This commit is contained in:
Greg Von Kuster
2011-06-16 10:54:29 -04:00
parent 5355a95ef3
commit 01ee17dd2b
2 changed files with 13 additions and 5 deletions
+10 -3
View File
@@ -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='',
+3 -2
View File
@@ -117,8 +117,9 @@ ${render_samples_messages(request, is_admin, is_submitted, message, status)}
<input type="file" name="file_data" />
<input type="submit" name="import_samples_button" value="Import samples"/>
<div class="toolParamHelp" style="clear: both;">
The csv file must be in the following format:<br/>
SampleName,DataLibraryName,DataLibraryFolderName,HistoryName,WorkflowName,Field1Name,Field2Name...
The csv file must be in the following format.<br/>
The [:FieldValue] is optional, the named form field will contain the value after the ':' if included.<br/>
SampleName,DataLibraryName,FolderName,HistoryName,WorkflowName,Field1Name:Field1Value,Field2Name:Field2Value...
</div>
</div>
</form>