More library work - requires database schema update:

1) include templates in the upload form for library datasets
2) Add user_id column to library_dataset_dataset_association table
3) Add message column to library_dataset_dataset_association table
4) Several miscellaneous bug fixes related to uploading library datasets

SQL commands required:

ALTER TABLE library_dataset_dataset_association ADD COLUMN user_id INTEGER;
ALTER TABLE library_dataset_dataset_association ADD CONSTRAINT library_dataset_dataset_association_user_id_id_fkey FOREIGN KEY (user_id) REFERENCES galaxy_user(id);
ALTER TABLE library_dataset_dataset_association ADD COLUMN message VARCHAR(255);
This commit is contained in:
Greg Von Kuster
2009-03-09 17:02:21 -04:00
parent 25b0fd287e
commit e55a4d84f8
14 changed files with 243 additions and 81 deletions
+23 -10
View File
@@ -632,7 +632,8 @@ class HistoryDatasetAssociation( DatasetInstance ):
visible=self.visible,
deleted=self.deleted,
parent_id=parent_id,
copied_from_history_dataset_association=self )
copied_from_history_dataset_association=self,
user=self.history.user )
ldda.flush()
# Must set metadata after flushed, as MetadataFiles require dataset.id
ldda.metadata = self.metadata
@@ -737,11 +738,17 @@ class LibraryDataset( object ):
return template_list
class LibraryDatasetDatasetAssociation( DatasetInstance ):
def __init__( self, copied_from_history_dataset_association=None, copied_from_library_dataset_dataset_association=None, library_dataset=None, **kwd ):
def __init__( self,
copied_from_history_dataset_association=None,
copied_from_library_dataset_dataset_association=None,
library_dataset=None,
user=None,
**kwd ):
DatasetInstance.__init__( self, **kwd )
self.copied_from_history_dataset_association = copied_from_history_dataset_association
self.copied_from_library_dataset_dataset_association = copied_from_library_dataset_dataset_association
self.library_dataset = library_dataset
self.user = user
def to_history_dataset_association( self, target_history, parent_id=None ):
hid = target_history._next_hid()
hda = HistoryDatasetAssociation( name=self.name,
@@ -829,38 +836,44 @@ class LibraryItemInfoTemplateElement( object ):
pass
class LibraryInfoAssociation( object ):
def set_library_item( self, library_item, user ):
def __init__( self, user=None ):
self.user = user
def set_library_item( self, library_item ):
if isinstance( library_item, Library ):
self.library = library_item
self.user = user
else:
raise "Invalid Library specified: %s" % library_item.__class__.__name__
class LibraryFolderInfoAssociation( object ):
def set_library_item( self, library_item, user ):
def __init__( self, user=None ):
self.user = user
def set_library_item( self, library_item ):
if isinstance( library_item, LibraryFolder ):
self.folder = library_item
self.user = user
else:
raise "Invalid Library specified: %s" % library_item.__class__.__name__
class LibraryDatasetInfoAssociation( object ):
def set_library_item( self, library_item, user ):
def __init__( self, user=None ):
self.user = user
def set_library_item( self, library_item ):
if isinstance( library_item, LibraryDataset ):
self.library_dataset = library_item
self.user = user
else:
raise "Invalid Library specified: %s" % library_item.__class__.__name__
class LibraryDatasetDatasetInfoAssociation( object ):
def set_library_item( self, library_item, user ):
def __init__( self, user=None ):
self.user = user
def set_library_item( self, library_item ):
if isinstance( library_item, LibraryDatasetDatasetAssociation ):
self.library_dataset_dataset_association = library_item
self.user = user
else:
raise "Invalid Library specified: %s" % library_item.__class__.__name__
class LibraryItemInfo( object ):
def __init__( self, user=None ):
self.user = user
def get_element_by_template_element( self, template_element ):
for element in self.elements:
if element.library_item_info_template_element == template_element:
+9 -1
View File
@@ -240,7 +240,9 @@ LibraryDatasetDatasetAssociation.table = Table( "library_dataset_dataset_associa
Column( "parent_id", Integer, ForeignKey( "library_dataset_dataset_association.id" ), nullable=True ),
Column( "designation", TrimmedString( 255 ) ),
Column( "deleted", Boolean, index=True, default=False ),
Column( "visible", Boolean ) )
Column( "visible", Boolean ),
Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), index=True ),
Column( "message", TrimmedString( 255 ) ) )
Library.table = Table( "library", metadata,
Column( "id", Integer, primary_key=True ),
@@ -711,6 +713,7 @@ assign_mapper( context, LibraryDatasetDatasetAssociation, LibraryDatasetDatasetA
dataset=relation( Dataset ),
library_dataset = relation( LibraryDataset,
primaryjoin=( LibraryDatasetDatasetAssociation.table.c.library_dataset_id == LibraryDataset.table.c.id ) ),
user=relation( User.mapper ),
copied_to_library_dataset_dataset_associations=relation(
LibraryDatasetDatasetAssociation,
primaryjoin=( LibraryDatasetDatasetAssociation.table.c.copied_from_library_dataset_dataset_association_id == LibraryDatasetDatasetAssociation.table.c.id ),
@@ -761,26 +764,31 @@ assign_mapper( context, LibraryItemInfoElement, LibraryItemInfoElement.table,
assign_mapper( context, LibraryItemInfo, LibraryItemInfo.table,
properties=dict( library_item_info_template=relation( LibraryItemInfoTemplate, backref="library_item_infos" ),
user=relation( User.mapper )
) )
assign_mapper( context, LibraryInfoAssociation, LibraryInfoAssociation.table,
properties=dict( library=relation( Library, backref="library_info_associations" ),
library_item_info = relation( LibraryItemInfo, backref="library_info_associations" ),
user=relation( User.mapper )
) )
assign_mapper( context, LibraryFolderInfoAssociation, LibraryFolderInfoAssociation.table,
properties=dict( folder=relation( LibraryFolder, backref="library_folder_info_associations" ),
library_item_info = relation( LibraryItemInfo, backref="library_folder_info_associations" ),
user=relation( User.mapper )
) )
assign_mapper( context, LibraryDatasetInfoAssociation, LibraryDatasetInfoAssociation.table,
properties=dict( library_dataset=relation( LibraryDataset, backref="library_dataset_info_associations" ),
library_item_info = relation( LibraryItemInfo, backref="library_dataset_info_associations" ),
user=relation( User.mapper )
) )
assign_mapper( context, LibraryDatasetDatasetInfoAssociation, LibraryDatasetDatasetInfoAssociation.table,
properties=dict( library_dataset_dataset_association = relation( LibraryDatasetDatasetAssociation, backref="library_dataset_dataset_info_associations" ),
library_item_info = relation( LibraryItemInfo, backref="library_dataset_dataset_info_associations" ),
user=relation( User.mapper )
) )
assign_mapper( context, JobToInputDatasetAssociation, JobToInputDatasetAssociation.table,
+13 -13
View File
@@ -927,6 +927,8 @@ class Admin( BaseController ):
permissions[ trans.app.security_agent.get_action( v.action ) ] = in_roles
trans.app.security_agent.set_all_library_permissions( library, permissions )
library.refresh()
# Copy the permissions to the root folder
trans.app.security_agent.copy_library_permissions( library, library.root_folder, user=trans.get_user() )
msg = "Permissions updated for library '%s'" % library.name
return trans.response.send_redirect( web.url_for( controller='admin',
action='library',
@@ -1349,12 +1351,14 @@ class Admin( BaseController ):
old_name = ldda.name
new_name = util.restore_text( params.get( 'name', '' ) )
new_info = util.restore_text( params.get( 'info', '' ) )
new_message = util.restore_text( params.get( 'message', '' ) )
if not new_name:
msg = 'Enter a valid name'
messagetype = 'error'
else:
ldda.name = new_name
ldda.info = new_info
ldda.message = new_message
# The following for loop will save all metadata_spec items
for name, spec in ldda.datatype.metadata_spec.items():
if spec.get("readonly"):
@@ -1808,12 +1812,7 @@ class Admin( BaseController ):
library_item = trans.app.model.LibraryDatasetDatasetAssociation.get( library_item_id )
# This response_action method requires a folder_id
folder_id = library_item.library_dataset.folder.id
elif library_item_type == 'library_item_info_elememt':
library_item = trans.app.model.LibraryItemInfoElement.get( int( id ) )
else:
library_item_type == None
library_item = None
if not library_item:
msg = "Invalid library item type ( %s ) specified, id ( %s )" % ( str( library_item_type ), str( library_item_id ) )
return trans.response.send_redirect( web.url_for( controller='admin',
action='browse_library',
@@ -1843,9 +1842,8 @@ class Admin( BaseController ):
msg=util.sanitize_text( msg ),
messagetype='error' ) )
user = trans.get_user()
library_item_info = trans.app.model.LibraryItemInfo()
library_item_info = trans.app.model.LibraryItemInfo( user=user )
library_item_info.library_item_info_template = library_item_info_template
library_item_info.user = user
library_item_info.flush()
trans.app.security_agent.copy_library_permissions( library_item_info_template, library_item_info )
for template_element in library_item_info_template.elements:
@@ -1860,10 +1858,9 @@ class Admin( BaseController ):
if isinstance( library_item, item_class ):
break
if info_association_class:
library_item_info_association = info_association_class()
library_item_info_association.set_library_item( library_item, trans.user )
library_item_info_association = info_association_class( user=user )
library_item_info_association.set_library_item( library_item )
library_item_info_association.library_item_info = library_item_info
library_item_info_association.user = user
library_item_info_association.flush()
else:
raise 'Invalid class (%s) specified for library_item (%s)' % ( library_item.__class__, library_item.__class__.__name__ )
@@ -1884,9 +1881,12 @@ class Admin( BaseController ):
messagetype=messagetype )
elif params.get( 'edit_info', False ):
if params.get( 'edit_info_button', False ):
new_contents = util.restore_text( params.get( ( 'info_element_%s' % id ), '' ) )
library_item.contents = new_contents
library_item.flush()
ids = util.listify( id )
for id in ids:
library_item_info_element = trans.app.model.LibraryItemInfoElement.get( int( id ) )
new_contents = util.restore_text( params.get( ( 'info_element_%s' % id ), '' ) )
library_item_info_element.contents = new_contents
library_item_info_element.flush()
msg = 'The information has been updated.'
return trans.response.send_redirect( web.url_for( controller='admin',
action=library_item_type,
+13 -13
View File
@@ -132,6 +132,8 @@ class Library( BaseController ):
permissions[ trans.app.security_agent.get_action( v.action ) ] = in_roles
trans.app.security_agent.set_all_library_permissions( library, permissions )
library.refresh()
# Copy the permissions to the root folder
trans.app.security_agent.copy_library_permissions( library, library.root_folder, user=trans.get_user() )
msg = "Permissions updated for library '%s'" % library.name
return trans.response.send_redirect( web.url_for( controller='library',
action='library',
@@ -523,12 +525,14 @@ class Library( BaseController ):
old_name = ldda.name
new_name = util.restore_text( params.get( 'name', '' ) )
new_info = util.restore_text( params.get( 'info', '' ) )
new_message = util.restore_text( params.get( 'message', '' ) )
if not new_name:
msg = 'Enter a valid name'
messagetype = 'error'
else:
ldda.name = new_name
ldda.info = new_info
ldda.message = new_message
# The following for loop will save all metadata_spec items
for name, spec in ldda.datatype.metadata_spec.items():
if spec.get("readonly"):
@@ -1239,12 +1243,7 @@ class Library( BaseController ):
library_item = trans.app.model.LibraryDatasetDatasetAssociation.get( library_item_id )
# This response_action method requires a folder_id
folder_id = library_item.library_dataset.folder.id
elif library_item_type == 'library_item_info_elememt':
library_item = trans.app.model.LibraryItemInfoElement.get( int( id ) )
else:
library_item_type == None
library_item = None
if not library_item:
msg = "Invalid library item type ( %s ) specified, id ( %s )" % ( str( library_item_type ), str( library_item_id ) )
return trans.response.send_redirect( web.url_for( controller='library',
action='browse_library',
@@ -1274,9 +1273,8 @@ class Library( BaseController ):
msg=util.sanitize_text( msg ),
messagetype='error' ) )
user = trans.get_user()
library_item_info = trans.app.model.LibraryItemInfo()
library_item_info = trans.app.model.LibraryItemInfo( user=user )
library_item_info.library_item_info_template = library_item_info_template
library_item_info.user = user
library_item_info.flush()
trans.app.security_agent.copy_library_permissions( library_item_info_template, library_item_info )
for template_element in library_item_info_template.elements:
@@ -1291,10 +1289,9 @@ class Library( BaseController ):
if isinstance( library_item, item_class ):
break
if info_association_class:
library_item_info_association = info_association_class()
library_item_info_association.set_library_item( library_item, trans.user )
library_item_info_association = info_association_class( user=user )
library_item_info_association.set_library_item( library_item )
library_item_info_association.library_item_info = library_item_info
library_item_info_association.user = user
library_item_info_association.flush()
else:
raise 'Invalid class (%s) specified for library_item (%s)' % ( library_item.__class__, library_item.__class__.__name__ )
@@ -1315,9 +1312,12 @@ class Library( BaseController ):
messagetype=messagetype )
elif params.get( 'edit_info', False ):
if params.get( 'edit_info_button', False ):
new_contents = util.restore_text( params.get( ( 'info_element_%s' % id ), '' ) )
library_item.contents = new_contents
library_item.flush()
ids = util.listify( id )
for id in ids:
library_item_info_element = trans.app.model.LibraryItemInfoElement.get( int( id ) )
new_contents = util.restore_text( params.get( ( 'info_element_%s' % id ), '' ) )
library_item_info_element.contents = new_contents
library_item_info_element.flush()
msg = 'The information has been updated.'
return trans.response.send_redirect( web.url_for( controller='library',
action=library_item_type,
+58 -5
View File
@@ -12,7 +12,8 @@ class UploadLibraryDataset( BaseController ):
os.unlink( filename )
except:
log.exception( 'failure removing temporary file: %s' % filename )
def add_file( self, trans, folder_id, file_obj, name, file_format, dbkey, roles, info='no info', space_to_tab=False, replace_dataset=None ):
def add_file( self, trans, folder_id, file_obj, name, file_format, dbkey, roles, info='no info', space_to_tab=False,
replace_dataset=None, library_item_info_template=None, template_elements={}, message=None ):
folder = trans.app.model.LibraryFolder.get( folder_id )
data_type = None
line_count = 0
@@ -111,7 +112,9 @@ class UploadLibraryDataset( BaseController ):
extension=data_type,
dbkey=dbkey,
library_dataset=library_dataset,
user=trans.get_user(),
create_dataset=True )
ldda.message = message
ldda.flush()
# Permissions must be the same on the LibraryDatasetDatasetAssociation and the associated LibraryDataset
trans.app.security_agent.copy_library_permissions( library_dataset, ldda )
@@ -124,6 +127,24 @@ class UploadLibraryDataset( BaseController ):
folder.add_library_dataset( library_dataset, genome_build=dbkey )
library_dataset.library_dataset_dataset_association_id = ldda.id
library_dataset.flush()
# Handle any templates included in the upload form
if library_item_info_template:
user = trans.get_user()
library_item_info = trans.app.model.LibraryItemInfo( user=user )
library_item_info.library_item_info_template = library_item_info_template
library_item_info.flush()
trans.app.security_agent.copy_library_permissions( library_item_info_template, library_item_info )
for template_element in library_item_info_template.elements:
info_element_value = template_elements.get( "info_element_%s_%s" % ( library_item_info_template.id, template_element.id ), None )
info_element = trans.app.model.LibraryItemInfoElement()
info_element.contents = info_element_value
info_element.library_item_info_template_element = template_element
info_element.library_item_info = library_item_info
info_element.flush()
library_item_info_association = trans.app.model.LibraryDatasetDatasetInfoAssociation( user=user )
library_item_info_association.set_library_item( ldda )
library_item_info_association.library_item_info = library_item_info
library_item_info_association.flush()
# If roles were selected upon upload, restrict access to the Dataset to those roles
if roles:
for role in roles:
@@ -160,6 +181,22 @@ class UploadLibraryDataset( BaseController ):
replace_id = replace_dataset.id
else:
replace_id = None
message = params.get( 'message', '' )
# Handle any templates included in the upload form by building a dictionary of info elements to send to add_file
template_elements = {}
library_item_info_template = None
library_item_info_template_id = params.get( 'library_item_info_template_id', None )
if library_item_info_template_id:
library_item_info_template = trans.app.model.LibraryItemInfoTemplate.get( int( library_item_info_template_id ) )
for template_element in library_item_info_template.elements:
# Make sure at least 1 template field is filled in
# TODO: Eventually we'll enhance templates to allow for required and optional fields.
if params.get( "info_element_%s_%s" % ( library_item_info_template.id, template_element.id ), None ):
for template_element in library_item_info_template.elements:
key = "info_element_%s_%s" % ( library_item_info_template.id, template_element.id )
value = params.get( key, None )
if value:
template_elements[ key ] = value
if data_file == '' and url_paste == '' and server_dir in [ 'None', '' ]:
if trans.app.config.library_import_dir is not None:
msg = 'Select a file, enter a URL or Text, or select a server directory.'
@@ -194,7 +231,10 @@ class UploadLibraryDataset( BaseController ):
roles,
info="uploaded file",
space_to_tab=space_to_tab,
replace_dataset=replace_dataset )
replace_dataset=replace_dataset,
library_item_info_template=library_item_info_template,
template_elements=template_elements,
message=message )
created_ldda_ids = str( created_ldda.id )
except Exception, e:
log.exception( 'exception in upload_dataset using file_name %s: %s' % ( str( file_name ), str( e ) ) )
@@ -202,9 +242,13 @@ class UploadLibraryDataset( BaseController ):
elif url_paste not in [ None, "" ]:
if url_paste.lower().find( 'http://' ) >= 0 or url_paste.lower().find( 'ftp://' ) >= 0:
url_paste = url_paste.replace( '\r', '' ).split( '\n' )
# If we are setting the name from the line, it needs to be the line that creates that dataset
name_set_from_line = False
for line in url_paste:
line = line.rstrip( '\r\n' )
if line:
if not line or name_set_from_line:
name_set_from_line = True
try:
created_ldda = self.add_file( trans,
folder_id,
@@ -215,7 +259,10 @@ class UploadLibraryDataset( BaseController ):
roles,
info="uploaded url",
space_to_tab=space_to_tab,
replace_dataset=replace_dataset )
replace_dataset=replace_dataset,
library_item_info_template=library_item_info_template,
template_elements=template_elements,
message=message )
created_ldda_ids = '%s,%s' % ( created_ldda_ids, str( created_ldda.id ) )
except Exception, e:
log.exception( 'exception in upload_dataset using url_paste %s' % str( e ) )
@@ -238,7 +285,10 @@ class UploadLibraryDataset( BaseController ):
roles,
info="pasted entry",
space_to_tab=space_to_tab,
replace_dataset=replace_dataset )
replace_dataset=replace_dataset,
library_item_info_template=library_item_info_template,
template_elements=template_elements,
message=message )
created_ldda_ids = '%s,%s' % ( created_ldda_ids, str( created_ldda.id ) )
except Exception, e:
log.exception( 'exception in add_file using StringIO.StringIO( url_paste ) %s' % str( e ) )
@@ -263,7 +313,10 @@ class UploadLibraryDataset( BaseController ):
roles,
info="imported file",
space_to_tab=space_to_tab,
replace_dataset=replace_dataset )
replace_dataset=replace_dataset,
library_item_info_template=library_item_info_template,
template_elements=template_elements,
message=message )
created_ldda_ids = '%s,%s' % ( created_ldda_ids, str( created_ldda.id ) )
except Exception, e:
log.exception( 'exception in add_file using server_dir %s' % str( e ) )
+22 -17
View File
@@ -138,7 +138,7 @@
%endif
</%def>
<%def name="render_available_templates( library_item, library_id, restrict=False )">
<%def name="render_available_templates( library_item, library_id, restrict=False, upload=False )">
<%
available_templates = library_item.get_library_item_info_templates( template_list=[], restrict=restrict )
if available_templates:
@@ -166,26 +166,31 @@
<div class="toolForm">
<div class="toolFormTitle">Other information about ${library_item_desc} ${library_item.name}</div>
<div class="toolFormBody">
%for available_template in available_templates:
<form name="add_template_info" action="${h.url_for( controller='admin', action='library_item_info', library_id=library_id, new_info=True )}" method="post">
<input type="hidden" name="library_item_id" value="${library_item.id}"/>
<input type="hidden" name="library_item_type" value="${library_item_type}"/>
<input type="hidden" name="library_item_info_template_id" value="${available_template.id}"/>
<p/>
%for info_elem in available_template.elements:
<div class="form-row">
<label>${info_elem.name}</label>
<input type="text" name="info_element_${available_template.id}_${info_elem.id}" value="" size="40"/>
<div class="toolParamHelp" style="clear: both;">
${info_elem.description}
</div>
<div style="clear: both"></div>
%for available_template in available_templates:
%if upload in [ False, 'False' ]:
# Only render a form if we're not within the upload form
<form name="add_template_info" action="${h.url_for( controller='admin', action='library_item_info', library_id=library_id, new_info=True )}" method="post">
%endif
<input type="hidden" name="library_item_id" value="${library_item.id}"/>
<input type="hidden" name="library_item_type" value="${library_item_type}"/>
<input type="hidden" name="library_item_info_template_id" value="${available_template.id}"/>
<p/>
%for info_elem in available_template.elements:
<div class="form-row">
<label>${info_elem.name}</label>
<input type="text" name="info_element_${available_template.id}_${info_elem.id}" value="" size="40"/>
<div class="toolParamHelp" style="clear: both;">
${info_elem.description}
</div>
%endfor
<div style="clear: both"></div>
</div>
%endfor
%if upload in [ False, 'False' ]:
<div class="form-row">
<input type="submit" name="create_new_info_button" value="Save"/>
</div>
</form>
</form>
%endif
%endfor
</div>
</div>
+10
View File
@@ -53,6 +53,16 @@
</div>
<div style="clear: both"></div>
</div>
<div class="form-row">
<label>Message:</label>
<div style="float: left; width: 250px; margin-right: 10px;">
<textarea name="message" rows="3" cols="35">${ldda.message}</textarea>
</div>
<div class="toolParamHelp" style="clear: both;">
This information will be displayed in the library browser
</div>
<div style="clear: both"></div>
</div>
%for name, spec in ldda.metadata.spec.items():
%if spec.visible:
<div class="form-row">
+17
View File
@@ -1,5 +1,6 @@
<%inherit file="/base.mako"/>
<%namespace file="/message.mako" import="render_msg" />
<%namespace file="/admin/library/common.mako" import="render_available_templates" />
<% import os %>
@@ -117,6 +118,16 @@
</div>
<div style="clear: both"></div>
</div>
<div class="form-row">
<label>Message:</label>
<div style="float: left; width: 250px; margin-right: 10px;">
<textarea name="message" rows="3" cols="35"></textarea>
</div>
<div class="toolParamHelp" style="clear: both;">
This information will be displayed in the library browser
</div>
<div style="clear: both"></div>
</div>
<div class="form-row">
<div style="float: left; width: 250px; margin-right: 10px;">
<label>Restrict dataset access to specific roles:</label>
@@ -131,6 +142,12 @@
</div>
</div>
<div style="clear: both"></div>
<% folder = trans.app.model.LibraryFolder.get( folder_id ) %>
%if folder.library_folder_info_template_associations:
${render_available_templates( folder, library_id, restrict=True, upload=True )}
%else:
${render_available_templates( folder, library_id, restrict=False, upload=True )}
%endif
<div class="form-row">
<input type="submit" class="primary-button" name="new_dataset_button" value="Add Dataset(s) to Folder"/>
</div>
+21 -16
View File
@@ -153,7 +153,7 @@
%endif
</%def>
<%def name="render_available_templates( library_item, library_id, restrict=False )">
<%def name="render_available_templates( library_item, library_id, restrict=False, upload=False )">
<%
available_templates = library_item.get_library_item_info_templates( template_list=[], restrict=restrict )
if available_templates:
@@ -184,25 +184,30 @@
<div class="toolForm">
<div class="toolFormTitle">Other information about ${library_item_desc} ${library_item.name}</div>
<div class="toolFormBody">
<form name="add_template_info" action="${h.url_for( controller='library', action='library_item_info', library_id=library_id, new_info=True )}" method="post">
<input type="hidden" name="library_item_id" value="${library_item.id}"/>
<input type="hidden" name="library_item_type" value="${library_item_type}"/>
<input type="hidden" name="library_item_info_template_id" value="${available_template.id}"/>
<p/>
%for info_elem in available_template.elements:
<div class="form-row">
<label>${info_elem.name}</label>
<input type="text" name="info_element_${available_template.id}_${info_elem.id}" value="" size="40"/>
<div class="toolParamHelp" style="clear: both;">
${info_elem.description}
</div>
<div style="clear: both"></div>
%if upload in [ False, 'False' ]:
# Only render a form if we're not within the upload form
<form name="add_template_info" action="${h.url_for( controller='library', action='library_item_info', library_id=library_id, new_info=True )}" method="post">
%endif
<input type="hidden" name="library_item_id" value="${library_item.id}"/>
<input type="hidden" name="library_item_type" value="${library_item_type}"/>
<input type="hidden" name="library_item_info_template_id" value="${available_template.id}"/>
<p/>
%for info_elem in available_template.elements:
<div class="form-row">
<label>${info_elem.name}</label>
<input type="text" name="info_element_${available_template.id}_${info_elem.id}" value="" size="40"/>
<div class="toolParamHelp" style="clear: both;">
${info_elem.description}
</div>
%endfor
<div style="clear: both"></div>
</div>
%endfor
%if upload in [ False, 'False' ]:
<div class="form-row">
<input type="submit" name="create_new_info_button" value="Save"/>
</div>
</form>
</form>
%endif
</div>
</div>
%endif
+10
View File
@@ -53,6 +53,16 @@
</div>
<div style="clear: both"></div>
</div>
<div class="form-row">
<label>Message:</label>
<div style="float: left; width: 250px; margin-right: 10px;">
<textarea name="message" rows="3" cols="35">${ldda.message}</textarea>
</div>
<div class="toolParamHelp" style="clear: both;">
This information will be displayed in the library browser
</div>
<div style="clear: both"></div>
</div>
%for name, spec in ldda.metadata.spec.items():
%if spec.visible:
<div class="form-row">
+17
View File
@@ -1,5 +1,6 @@
<%inherit file="/base.mako"/>
<%namespace file="/message.mako" import="render_msg" />
<%namespace file="/admin/library/common.mako" import="render_available_templates" />
<% import os %>
@@ -122,6 +123,16 @@
</div>
<div style="clear: both"></div>
</div>
<div class="form-row">
<label>Message:</label>
<div style="float: left; width: 250px; margin-right: 10px;">
<textarea name="message" rows="3" cols="35"></textarea>
</div>
<div class="toolParamHelp" style="clear: both;">
This information will be displayed in the library browser
</div>
<div style="clear: both"></div>
</div>
<div class="form-row">
<div style="float: left; width: 250px; margin-right: 10px;">
<label>Restrict dataset access to specific roles:</label>
@@ -136,6 +147,12 @@
</div>
</div>
<div style="clear: both"></div>
<% folder = trans.app.model.LibraryFolder.get( folder_id ) %>
%if folder.library_folder_info_template_associations:
${render_available_templates( folder, library_id, restrict=True, upload=True )}
%else:
${render_available_templates( folder, library_id, restrict=False, upload=True )}
%endif
<div class="form-row">
<input type="submit" class="primary-button" name="new_dataset_button" value="Add Dataset(s)"/>
</div>
+2 -2
View File
@@ -855,11 +855,11 @@ class TwillTestCase( unittest.TestCase ):
check_str = "Folder '%s' has been renamed to '%s'" % ( old_name, name )
self.check_page_for_string( check_str )
self.home()
def add_library_dataset( self, filename, library_id, folder_id, folder_name, file_format='auto', dbkey='hg18', roles=[] ):
def add_library_dataset( self, filename, library_id, folder_id, folder_name, file_format='auto', dbkey='hg18', roles=[], message='' ):
"""Add a dataset to a folder"""
filename = self.get_filename( filename )
self.home()
self.visit_url( "%s/admin/library_dataset_dataset_association?upload_option=upload_file&library_id=%s&folder_id=%s" % ( self.url, library_id, folder_id ) )
self.visit_url( "%s/admin/library_dataset_dataset_association?upload_option=upload_file&library_id=%s&folder_id=%s&message=%s" % ( self.url, library_id, folder_id, message ) )
self.check_page_for_string( 'Upload files' )
tc.fv( "1", "folder_id", folder_id )
tc.formfile( "1", "file_data", filename )
+27 -3
View File
@@ -487,7 +487,15 @@ class TestSecurityAndLibraries( TwillTestCase ):
def test_080_add_dataset_with_private_role_restriction_to_folder( self ):
"""Testing adding a dataset with a private role restriction to a folder"""
# Add a dataset restricted by regular_user1 private role
self.add_library_dataset( '1.bed', str( library_one.id ), str( folder_one.id ), folder_one.name, file_format='bed', dbkey='hg18', roles=[ str( regular_user1_private_role.id ) ] )
message ='This+is+a+test'
self.add_library_dataset( '1.bed',
str( library_one.id ),
str( folder_one.id ),
folder_one.name,
file_format='bed',
dbkey='hg18',
roles=[ str( regular_user1_private_role.id ) ],
message=message )
global ldda_three
ldda_three = galaxy.model.LibraryDatasetDatasetAssociation.query() \
.order_by( desc( galaxy.model.LibraryDatasetDatasetAssociation.table.c.create_time ) ).first()
@@ -558,7 +566,15 @@ class TestSecurityAndLibraries( TwillTestCase ):
# Add a dataset restricted by role_two, which is currently associated as follows:
# groups: group_two
# users: test@bx.psu.edu, test1@bx.psu.edu via group_two
self.add_library_dataset( '2.bed', str( library_one.id ), str( folder_one.id ), folder_one.name, file_format='bed', dbkey='hg17', roles=[ str( role_two.id ) ] )
message ='This+is+a+test'
self.add_library_dataset( '2.bed',
str( library_one.id ),
str( folder_one.id ),
folder_one.name,
file_format='bed',
dbkey='hg17',
roles=[ str( role_two.id ) ],
message=message )
global ldda_two
ldda_two = galaxy.model.LibraryDatasetDatasetAssociation.query() \
.order_by( desc( galaxy.model.LibraryDatasetDatasetAssociation.table.c.create_time ) ).first()
@@ -632,7 +648,15 @@ class TestSecurityAndLibraries( TwillTestCase ):
"""Testing adding a public dataset to a library root folder"""
self.login( email='test@bx.psu.edu' )
folder = library_one.root_folder
self.add_library_dataset( '3.bed', str( library_one.id ), str( folder.id ), folder.name, file_format='bed', dbkey='hg16', roles=[] )
message ='This+is+a+test'
self.add_library_dataset( '3.bed',
str( library_one.id ),
str( folder.id ),
folder.name,
file_format='bed',
dbkey='hg16',
roles=[],
message=message )
global ldda_three
ldda_three = galaxy.model.LibraryDatasetDatasetAssociation.query() \
.order_by( desc( galaxy.model.LibraryDatasetDatasetAssociation.table.c.create_time ) ).first()
+1 -1
View File
@@ -25,7 +25,7 @@
<data_type_translation>
<format galaxy_format="tabular" remote_format="primaryTable" />
<format galaxy_format="tabular" remote_format="selectedFields" />
<format galaxy_format="wig" remote_format="wigdata" />
<format galaxy_format="wig" remote_format="wigData" />
<format galaxy_format="interval" remote_format="tab" />
<format galaxy_format="html" remote_format="hyperlinks" />
<format galaxy_format="fasta" remote_format="sequence" />