Bug fixes, enhancements, code refactoring and re-introduction of functional tests for library templates.

- Fixed bug where exception was thrown when chosing a role in the admin view
- The contents of inherited templates will no longer be displayed in the inherited container
- Old versions of library datasets will not be displayed in the lbrary browser
- Added the job.traceback information to the dataset error report
- Moved the get_form_wigets method the forms.py to the FormDefinition class, renaming it to get_wigets
This commit is contained in:
Greg Von Kuster
2009-09-19 00:25:14 -04:00
parent e2ceaddd35
commit 0f294b742c
15 changed files with 497 additions and 724 deletions
+117 -15
View File
@@ -14,6 +14,7 @@ import galaxy.datatypes.registry
from galaxy.datatypes.metadata import MetadataCollection
from galaxy.security import RBACAgent, get_permitted_actions
from galaxy.util.hash_util import *
from galaxy.web.form_builder import *
import logging
log = logging.getLogger( __name__ )
@@ -686,10 +687,23 @@ class Library( object ):
self.name = name or "Unnamed library"
self.description = description
self.root_folder = root_folder
def get_info_association( self, restrict=False ):
def get_info_association( self, restrict=False, inherited=False ):
if self.info_association:
return self.info_association[0]
return None
return self.info_association[0], inherited
return None, inherited
def get_template_widgets( self, trans, get_contents=True ):
# See if we have any associated templates - the returned value for
# inherited is not applicable at the library level
info_association, inherited = self.get_info_association()
if info_association:
template = info_association.template
if get_contents:
# See if we have any field contents
info = info_association.info
if info:
return template.get_widgets( trans.user, contents=info.content )
return template.get_widgets( trans.user )
return []
class LibraryFolder( object ):
def __init__( self, name=None, description=None, item_count=0, order_id=None ):
@@ -708,19 +722,35 @@ class LibraryFolder( object ):
folder.parent_id = self.id
folder.order_id = self.item_count
self.item_count += 1
def get_info_association( self, restrict=False ):
def get_info_association( self, restrict=False, inherited=False ):
# If restrict is True, we will return this folder's info_association, not inheriting.
# If restrict is False, we'll return the next available info_association in the
# inheritable hierarchy
# inheritable hierarchy. True is also returned if the info_association was inherited,
# and False if not. This enables us to eliminate displaying the any contents of the inherited
# template.
if self.info_association:
return self.info_association[0]
return self.info_association[0], inherited
if restrict:
return None
return None, inherited
if self.parent:
return self.parent.get_info_association()
return self.parent.get_info_association( inherited=True )
if self.library_root:
return self.library_root[0].get_info_association()
return None
return self.library_root[0].get_info_association( inherited=True )
return None, inherited
def get_template_widgets( self, trans, get_contents=True ):
# See if we have any associated templates
info_association, inherited = self.get_info_association()
if info_association:
template = info_association.template
# See if we have any field contents, but only if the info_association was
# not inherited ( we do not want to display the inherited contents ).
if not inherited and get_contents:
info = info_association.info
if info:
return template.get_widgets( trans.user, info.content )
else:
return template.get_widgets( trans.user )
return []
@property
def active_library_datasets( self ):
# This needs to be a list
@@ -839,15 +869,31 @@ class LibraryDatasetDatasetAssociation( DatasetInstance ):
return ldda
def clear_associated_files( self, metadata_safe = False, purge = False ):
return
def get_info_association( self, restrict=False ):
def get_info_association( self, restrict=False, inherited=False ):
# If restrict is True, we will return this ldda's info_association whether it
# exists or not. If restrict is False, we'll return the next available info_association
# in the inheritable hierarchy
# in the inheritable hierarchy. True is also returned if the info_association was inherited,
# and False if not. This enables us to eliminate displaying the any contents of the inherited
# template.
if self.info_association:
return self.info_association[0]
return self.info_association[0], inherited
if restrict:
return None
return self.library_dataset.folder.get_info_association()
return None, inherited
return self.library_dataset.folder.get_info_association( inherited=True )
def get_template_widgets( self, trans, get_contents=True ):
# See if we have any associated templates
info_association, inherited = self.get_info_association()
if info_association:
template = info_association.template
# See if we have any field contents, but only if the info_association was
# not inherited ( we do not want to display the inherited contents ).
if not inherited and get_contents:
info = info_association.info
if info:
return template.get_widgets( trans.user, info.content )
else:
return template.get_widgets( trans.user )
return []
class LibraryInfoAssociation( object ):
def __init__( self, library, form_definition, info ):
@@ -1030,6 +1076,62 @@ class FormDefinition( object ):
if f['layout'] == str(layout_index):
fields_dict[i] = f
return fields_dict
def get_widgets( self, user, contents=[], **kwd ):
'''
Return the list of widgets that comprise a form definition,
including field contents if any.
'''
params = util.Params( kwd )
widgets = []
for index, field in enumerate( self.fields ):
field_name = 'field_%i' % index
# determine the value of the field
if field_name in kwd:
# the user had already filled out this field and the same form is re-rendered
# due to some reason like required fields have been left out.
if field[ 'type' ] == 'CheckboxField':
value = CheckboxField.is_checked( util.restore_text( params.get( field_name, False ) ) )
else:
value = util.restore_text( params.get( field_name, '' ) )
elif contents:
# this field has a saved value
value = str( contents[ index ] )
else:
# if none of the above, then leave the field empty
if field[ 'type' ] == 'CheckboxField':
# Since we do not have contents, set checkbox value to False
value = False
else:
# Set other field types to empty string
value = ''
# create the field widget
field_widget = eval( field[ 'type' ] )( field_name )
if field[ 'type' ] == 'TextField':
field_widget.set_size( 40 )
field_widget.value = value
elif field[ 'type' ] == 'TextArea':
field_widget.set_size( 3, 40 )
field_widget.value = value
elif field['type'] == 'AddressField':
field_widget.user = user
field_widget.value = value
field_widget.params = params
elif field[ 'type' ] == 'SelectField':
for option in field[ 'selectlist' ]:
if option == value:
field_widget.add_option( option, option, selected=True )
else:
field_widget.add_option( option, option )
elif field[ 'type' ] == 'CheckboxField':
field_widget.checked = value
if field[ 'required' ] == 'required':
req = 'Required'
else:
req = 'Optional'
widgets.append( dict( label=field[ 'label' ],
widget=field_widget,
helptext='%s (%s)' % ( field[ 'helptext' ], req ) ) )
return widgets
class FormDefinitionCurrent( object ):
def __init__(self, form_definition=None):
+1 -2
View File
@@ -3,7 +3,6 @@ from datetime import datetime, timedelta
from galaxy import util, datatypes
from galaxy.web.base.controller import *
from galaxy.model.orm import *
from galaxy.web.controllers.forms import get_all_forms, get_form_widgets
from galaxy.web.framework.helpers import time_ago, iff, grids
import logging
log = logging.getLogger( __name__ )
@@ -242,7 +241,7 @@ class Admin( BaseController ):
# whose DatasetPermissions is associated with the Role
# [ ( LibraryDatasetDatasetAssociation [ action, action ] ) ]
library_dataset_actions = {}
for dp in role.actions:
for dp in role.dataset_actions:
for ldda in trans.app.model.LibraryDatasetDatasetAssociation \
.filter( trans.app.model.LibraryDatasetDatasetAssociation.dataset_id==dp.dataset_id ) \
.all():
+4
View File
@@ -36,6 +36,9 @@ ${stdout}
job info:
${info}
-----------------------------------------------------------------------------
job traceback:
${traceback}
-----------------------------------------------------------------------------
(This is an automated message).
"""
@@ -76,6 +79,7 @@ class DatasetInterface( BaseController ):
tool_id=job.tool_id,
stderr=job.stderr,
stdout=job.stdout,
traceback=job.traceback,
info=job.info ) )
frm = to_address
# Check email a bit
-65
View File
@@ -500,10 +500,6 @@ def get_all_forms( trans, all_versions=False, filter=None, form_type='All' ):
Return all the latest forms from the form_definition_current table
if all_versions is set to True. Otherwise return all the versions
of all the forms from the form_definition table.
TODO: when we add the concept of a form_definition_type ( e.g.,
'request_header', 'request_sample', 'library_template' ), filter
the query if received filter is not None.
'''
if all_versions:
return trans.app.model.FormDefinition.query().all()
@@ -515,64 +511,3 @@ def get_all_forms( trans, all_versions=False, filter=None, form_type='All' ):
return [ fdc.latest_form for fdc in fdc_list ]
else:
return [ fdc.latest_form for fdc in fdc_list if fdc.latest_form.type == form_type ]
def get_form_widgets( trans, form, contents=[], user=None, **kwd ):
'''
Return the list of widgets that comprise a form definition,
including field contents if any.
'''
params = util.Params( kwd )
if not user:
user = trans.user
widgets = []
for index, field in enumerate( form.fields ):
field_name = 'field_%i' % index
# determine the value of the field
if field_name in kwd:
# the user had already filled out this field and the same form is re-rendered
# due to some reason like required fields have been left out.
if field[ 'type' ] == 'CheckboxField':
value = CheckboxField.is_checked( util.restore_text( params.get( field_name, False ) ) )
else:
value = util.restore_text( params.get( field_name, '' ) )
elif contents:
# this field has a saved value
value = str(contents[ index ])
else:
# if none of the above, then leave the field empty
if field[ 'type' ] == 'CheckboxField':
# Since we do not have contents, set checkbox value to False
value = False
else:
# Set other field types to empty string
value = ''
# create the field widget
field_widget = eval( field[ 'type' ] )( field_name )
if field[ 'type' ] == 'TextField':
field_widget.set_size( 40 )
field_widget.value = value
elif field[ 'type' ] == 'TextArea':
field_widget.set_size( 3, 40 )
field_widget.value = value
elif field['type'] == 'AddressField':
field_widget.user = user
field_widget.value = value
field_widget.params = params
elif field[ 'type' ] == 'SelectField':
for option in field[ 'selectlist' ]:
if option == value:
field_widget.add_option( option, option, selected=True )
else:
field_widget.add_option( option, option )
elif field[ 'type' ] == 'CheckboxField':
field_widget.checked = value
if field[ 'required' ] == 'required':
req = 'Required'
else:
req = 'Optional'
widgets.append( dict( label=field[ 'label' ],
widget=field_widget,
helptext='%s (%s)' % ( field[ 'helptext' ], req ) ) )
return widgets
+7 -33
View File
@@ -3,7 +3,7 @@ from galaxy.model.orm import *
from galaxy.datatypes import sniff
from galaxy import util
from galaxy.util.odict import odict
from galaxy.web.controllers.forms import get_all_forms, get_form_widgets
from galaxy.web.controllers.forms import get_all_forms
from galaxy.util.streamball import StreamBall
import logging, tempfile, zipfile, tarfile, os, sys
@@ -149,16 +149,7 @@ class Library( BaseController ):
messagetype='error' ) )
if action == 'information':
# See if we have any associated templates
if library.info_association:
template = library.info_association[0].template
# See if we have any field contents
info = library.info_association[0].info
if info:
widgets = get_form_widgets( trans, template, info.content )
else:
widgets = get_form_widgets( trans, template )
else:
widgets = []
widgets = library.get_template_widgets( trans )
if params.get( 'rename_library_button', False ):
old_name = library.name
new_name = util.restore_text( params.name )
@@ -479,17 +470,7 @@ class Library( BaseController ):
msg=util.sanitize_text( msg ),
messagetype='error' ) )
# See if we have any associated templates
info_association = ldda.get_info_association()
if info_association:
template = info_association.template
# See if we have any field contents
info = info_association.info
if info:
widgets = get_form_widgets( trans, template, info.content )
else:
widgets = get_form_widgets( trans, template )
else:
widgets = []
widgets = ldda.get_template_widgets( trans )
if action == 'permissions':
if params.get( 'update_roles_button', False ):
# The user clicked the Save button on the 'Associate With Roles' form
@@ -782,6 +763,8 @@ class Library( BaseController ):
msg=util.sanitize_text( msg ),
messagetype='error' ) )
if not id or replace_dataset:
# See if we have any inherited templates, but do not inherit contents.
widgets = folder.get_template_widgets( trans, get_contents=False )
upload_option = params.get( 'upload_option', 'upload_file' )
# No dataset(s) specified, so display the upload form. Send list of data formats to the form
# so the "extension" select list can be populated dynamically
@@ -806,6 +789,7 @@ class Library( BaseController ):
last_used_build=last_used_build,
roles=roles,
history=history,
widgets=widgets,
msg=msg,
messagetype=messagetype,
replace_dataset=replace_dataset )
@@ -968,17 +952,7 @@ class Library( BaseController ):
messagetype=messagetype )
elif action == 'information':
# See if we have any associated templates
info_association = folder.get_info_association()
if info_association:
template = info_association.template
# See if we have any field contents
info = info_association.info
if info:
widgets = get_form_widgets( trans, template, info.content )
else:
widgets = get_form_widgets( trans, template )
else:
widgets = []
widgets = folder.get_template_widgets( trans )
if params.get( 'rename_folder_button', False ):
if trans.app.security_agent.can_modify_library_item( user, roles, folder ):
old_name = folder.name
+10 -44
View File
@@ -2,7 +2,7 @@ import sys
from galaxy import util
from galaxy.web.base.controller import *
from galaxy.model.orm import *
from galaxy.web.controllers.forms import get_all_forms, get_form_widgets
from galaxy.web.controllers.forms import get_all_forms
# Older py compatibility
try:
set()
@@ -96,17 +96,7 @@ class LibraryAdmin( BaseController ):
return trans.fill_template( '/admin/library/new_library.mako', msg=msg, messagetype=messagetype )
elif action == 'information':
# See if we have any associated templates
info_association = library.get_info_association()
if info_association:
template = info_association.template
# See if we have any field contents
info = info_association.info
if info:
widgets = get_form_widgets( trans, template, info.content )
else:
widgets = get_form_widgets( trans, template )
else:
widgets = []
widgets = library.get_template_widgets( trans )
if params.get( 'rename_library_button', False ):
old_name = library.name
new_name = util.restore_text( params.name )
@@ -293,17 +283,7 @@ class LibraryAdmin( BaseController ):
messagetype=messagetype )
elif action == 'information':
# See if we have any associated templates
info_association = folder.get_info_association()
if info_association:
template = info_association.template
# See if we have any field contents
info = info_association.info
if info:
widgets = get_form_widgets( trans, template, info.content )
else:
widgets = get_form_widgets( trans, template )
else:
widgets = []
widgets = folder.get_template_widgets( trans )
if params.get( 'rename_folder_button', False ):
old_name = folder.name
new_name = util.restore_text( params.name )
@@ -478,13 +458,8 @@ class LibraryAdmin( BaseController ):
msg=util.sanitize_text( msg ),
messagetype=messagetype ) )
elif not id or replace_dataset:
# See if we have any associated templates
info_association = folder.get_info_association()
if info_association:
template = info_association.template
widgets = get_form_widgets( trans, template )
else:
widgets = []
# See if we have any inherited templates, but do not inherit contents.
widgets = folder.get_template_widgets( trans, get_contents=False )
upload_option = params.get( 'upload_option', 'upload_file' )
# No dataset(s) specified, so display the upload form. Send list of data formats to the form
# so the "extension" select list can be populated dynamically
@@ -536,17 +511,7 @@ class LibraryAdmin( BaseController ):
msg=util.sanitize_text( msg ),
messagetype='error' ) )
# See if we have any associated templates
info_association = ldda.get_info_association()
if info_association:
template = info_association.template
# See if we have any field contents
info = info_association.info
if info:
widgets = get_form_widgets( trans, template, info.content )
else:
widgets = get_form_widgets( trans, template )
else:
widgets = []
widgets = ldda.get_template_widgets( trans )
if action == 'permissions':
if params.get( 'update_roles_button', False ):
permissions = {}
@@ -1019,8 +984,9 @@ class LibraryAdmin( BaseController ):
# Since information templates are inherited, the template fields can be displayed on the information
# page for a folder or library dataset when it has no info_association object. If the user has added
# field contents on an inherited template via a parent's info_association, we'll need to create a new
# form_values and info_association for the current object.
info_association = library_item.get_info_association( restrict=True )
# form_values and info_association for the current object. The value for the returned inherited variable
# is not applicable at this level.
info_association, inherited = library_item.get_info_association( restrict=True )
if info_association:
template = info_association.template
info = info_association.info
@@ -1031,7 +997,7 @@ class LibraryAdmin( BaseController ):
form_values.flush()
else:
# Inherit the next available info_association so we can get the template
info_association = library_item.get_info_association()
info_association, inherited = library_item.get_info_association()
template = info_association.template
# Create a new FormValues object
form_values = trans.app.model.FormValues( template, field_contents )
@@ -205,7 +205,7 @@ class UploadLibraryDataset( BaseController ):
template_field_contents = []
template = None
folder = trans.app.model.LibraryFolder.get( folder_id )
info_association = folder.get_info_association()
info_association, inherited = folder.get_info_association()
if info_association:
template = info_association.template
for field_index in range( len( template.fields ) ):
+2 -3
View File
@@ -9,7 +9,6 @@ import logging, tempfile, zipfile, tarfile, os, sys
from galaxy.web.form_builder import *
from datetime import datetime, timedelta
from cgi import escape, FieldStorage
from galaxy.web.controllers.forms import get_form_widgets
log = logging.getLogger( __name__ )
@@ -480,7 +479,7 @@ class Requests( BaseController ):
libraries[ library ] = hidden_folder_ids
libui = self.__library_ui(libraries, **kwd)
widgets = widgets + libui
widgets = widgets + get_form_widgets(trans, request_type.request_form, contents=[], **kwd)
widgets = widgets + request_type.request_form.get_widgets( user, **kwd )
return trans.fill_template( '/requests/new_request.mako',
select_request_type=select_request_type,
request_type=request_type,
@@ -722,7 +721,7 @@ class Requests( BaseController ):
libraries[ library ] = hidden_folder_ids
libui = self.__library_ui(libraries, request, **kwd)
widgets = widgets + libui
widgets = widgets + get_form_widgets(trans, request.type.request_form, request.values.content, **kwd)
widgets = widgets + request.type.request_form.get_widgets( user, request.values.content, **kwd )
return trans.fill_template( '/requests/edit_request.mako',
select_request_type=select_request_type,
request_type=request.type,
+2 -3
View File
@@ -7,7 +7,6 @@ from galaxy.util.streamball import StreamBall
import logging, tempfile, zipfile, tarfile, os, sys
from galaxy.web.form_builder import *
from datetime import datetime, timedelta
from galaxy.web.controllers.forms import get_form_widgets
from galaxy.web.controllers.forms import get_all_forms
log = logging.getLogger( __name__ )
@@ -178,7 +177,7 @@ class Requests( BaseController ):
# libraries selectbox
libui = self.__library_ui(trans, request.user, request, **kwd)
widgets = widgets + libui
widgets = widgets + get_form_widgets(trans, request.type.request_form, request.values.content, request.user, **kwd)
widgets = widgets + request.type.request_form.get_widgets( request.user, request.values.content, **kwd )
return trans.fill_template( '/admin/requests/edit_request.mako',
select_request_type=select_request_type,
request_type=request.type,
@@ -687,7 +686,7 @@ class Requests( BaseController ):
# libraries selectbox
libui = self.__library_ui(trans, user, **kwd)
widgets = widgets + libui
widgets = widgets + get_form_widgets(trans, request_type.request_form, contents=[], user=user, **kwd)
widgets = widgets + request_type.request_form.get_widgets( user, **kwd )
return trans.fill_template( '/admin/requests/new_request.mako',
select_request_type=select_request_type,
request_type=request_type,
+40 -40
View File
@@ -85,48 +85,48 @@
else:
current_version = False
%>
<div class="historyItemWrapper historyItem historyItem-${ldda.state}" id="libraryItem-${ldda.id}">
## Header row for library items (name, state, action buttons)
<div class="historyItemTitleBar">
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td width="*">
%if selected:
<input type="checkbox" name="ldda_ids" value="${ldda.id}" checked/>
%else:
<input type="checkbox" name="ldda_ids" value="${ldda.id}"/>
%endif
<span class="libraryItemDeleted-${ldda.deleted}">
<a href="${h.url_for( controller='library_admin', action='library_dataset_dataset_association', library_id=library.id, folder_id=folder.id, id=ldda.id, info=True, deleted=deleted, show_deleted=show_deleted )}"><b>${ldda.name[:50]}</b></a>
</span>
<a id="dataset-${ldda.id}-popup" class="popup-arrow" style="display: none;">&#9660;</a>
%if not library.deleted and not folder.deleted and not library_dataset.deleted:
<div popupmenu="dataset-${ldda.id}-popup">
<a class="action-button" href="${h.url_for( controller='library_admin', action='library_dataset_dataset_association', library_id=library.id, folder_id=folder.id, id=ldda.id, edit_info=True )}">Edit this dataset's information</a>
## We're disabling the ability to add templates at the LDDA and LibraryDataset level, but will leave this here for possible future use
##<a class="action-button" href="${h.url_for( controller='library_admin', action='info_template', library_id=library.id, library_dataset_id=library_dataset.id, new_template=True )}">Add an information template to this dataset</a>
<a class="action-button" href="${h.url_for( controller='library_admin', action='library_dataset_dataset_association', library_id=library.id, folder_id=folder.id, id=ldda.id, permissions=True )}">Edit this dataset's permissions</a>
%if current_version:
%if current_version:
<div class="historyItemWrapper historyItem historyItem-${ldda.state}" id="libraryItem-${ldda.id}">
## Header row for library items (name, state, action buttons)
<div class="historyItemTitleBar">
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td width="*">
%if selected:
<input type="checkbox" name="ldda_ids" value="${ldda.id}" checked/>
%else:
<input type="checkbox" name="ldda_ids" value="${ldda.id}"/>
%endif
<span class="libraryItemDeleted-${ldda.deleted}">
<a href="${h.url_for( controller='library_admin', action='library_dataset_dataset_association', library_id=library.id, folder_id=folder.id, id=ldda.id, info=True, deleted=deleted, show_deleted=show_deleted )}"><b>${ldda.name[:50]}</b></a>
</span>
<a id="dataset-${ldda.id}-popup" class="popup-arrow" style="display: none;">&#9660;</a>
%if not library.deleted and not folder.deleted and not library_dataset.deleted:
<div popupmenu="dataset-${ldda.id}-popup">
<a class="action-button" href="${h.url_for( controller='library_admin', action='library_dataset_dataset_association', library_id=library.id, folder_id=folder.id, id=ldda.id, edit_info=True )}">Edit this dataset's information</a>
## We're disabling the ability to add templates at the LDDA and LibraryDataset level, but will leave this here for possible future use
##<a class="action-button" href="${h.url_for( controller='library_admin', action='info_template', library_id=library.id, library_dataset_id=library_dataset.id, new_template=True )}">Add an information template to this dataset</a>
<a class="action-button" href="${h.url_for( controller='library_admin', action='library_dataset_dataset_association', library_id=library.id, folder_id=folder.id, id=ldda.id, permissions=True )}">Edit this dataset's permissions</a>
<a class="action-button" href="${h.url_for( controller='library_admin', action='library_dataset_dataset_association', library_id=library.id, folder_id=folder.id, replace_id=library_dataset.id )}">Upload a new version of this dataset</a>
%endif
%if ldda.has_data:
<a class="action-button" href="${h.url_for( controller='library_admin', action='download_dataset_from_folder', id=ldda.id, library_id=library.id )}">Download this dataset</a>
%endif
<a class="action-button" confirm="Click OK to delete dataset '${ldda.name}'." href="${h.url_for( controller='library_admin', action='delete_library_item', library_id=library.id, library_item_id=library_dataset.id, library_item_type='library_dataset' )}">Delete this dataset</a>
</div>
%elif not library.deleted and not folder.deleted and library_dataset.deleted:
<div popupmenu="dataset-${ldda.id}-popup">
<a class="action-button" href="${h.url_for( controller='library_admin', action='undelete_library_item', library_id=library.id, library_item_id=library_dataset.id, library_item_type='library_dataset' )}">Undelete this dataset</a>
</div>
%endif
</td>
<td width="300">${ldda.message}</td>
<td width="150">${uploaded_by}</td>
<td width="60">${ldda.create_time.strftime( "%Y-%m-%d" )}</td>
</tr>
</table>
%if ldda.has_data:
<a class="action-button" href="${h.url_for( controller='library_admin', action='download_dataset_from_folder', id=ldda.id, library_id=library.id )}">Download this dataset</a>
%endif
<a class="action-button" confirm="Click OK to delete dataset '${ldda.name}'." href="${h.url_for( controller='library_admin', action='delete_library_item', library_id=library.id, library_item_id=library_dataset.id, library_item_type='library_dataset' )}">Delete this dataset</a>
</div>
%elif not library.deleted and not folder.deleted and library_dataset.deleted:
<div popupmenu="dataset-${ldda.id}-popup">
<a class="action-button" href="${h.url_for( controller='library_admin', action='undelete_library_item', library_id=library.id, library_item_id=library_dataset.id, library_item_type='library_dataset' )}">Undelete this dataset</a>
</div>
%endif
</td>
<td width="300">${ldda.message}</td>
<td width="150">${uploaded_by}</td>
<td width="60">${ldda.create_time.strftime( "%Y-%m-%d" )}</td>
</tr>
</table>
</div>
</div>
</div>
%endif
</%def>
<%def name="render_folder( folder, folder_pad, deleted, show_deleted, created_ldda_ids, library_id, root_folder=False )">
+42 -41
View File
@@ -91,52 +91,53 @@ class RowCounter( object ):
uploaded_by = 'anonymous'
if ldda == library_dataset.library_dataset_dataset_association:
current_version = True
can_modify_library_dataset = trans.app.security_agent.can_modify_library_item( user, roles, library_dataset )
can_manage_library_dataset = trans.app.security_agent.can_manage_library_item( user, roles, library_dataset )
else:
current_version = False
can_modify_library_dataset = trans.app.security_agent.can_modify_library_item( user, roles, library_dataset )
can_manage_library_dataset = trans.app.security_agent.can_manage_library_item( user, roles, library_dataset )
%>
<tr class="datasetRow"
%if parent is not None:
parent="${parent}"
style="display: none;"
%endif
>
<td style="padding-left: ${pad+20}px;">
%if selected:
<input type="checkbox" name="ldda_ids" value="${ldda.id}" checked/>
%else:
<input type="checkbox" name="ldda_ids" value="${ldda.id}"/>
%endif
<a href="${h.url_for( controller='library', action='library_dataset_dataset_association', library_id=library.id, folder_id=folder.id, id=ldda.id, info=True )}"><b>${ldda.name[:60]}</b></a>
<a id="dataset-${ldda.id}-popup" class="popup-arrow" style="display: none;">&#9660;</a>
<div popupmenu="dataset-${ldda.id}-popup">
%if can_modify_library_dataset:
<a class="action-button" href="${h.url_for( controller='library', action='library_dataset_dataset_association', library_id=library.id, folder_id=folder.id, id=ldda.id, edit_info=True )}">Edit this dataset's information</a>
%if current_version:
<tr class="datasetRow"
%if parent is not None:
parent="${parent}"
style="display: none;"
%endif
>
<td style="padding-left: ${pad+20}px;">
%if selected:
<input type="checkbox" name="ldda_ids" value="${ldda.id}" checked/>
%else:
<a class="action-button" href="${h.url_for( controller='library', action='library_dataset_dataset_association', library_id=library.id, folder_id=folder.id, id=ldda.id, information=True )}">View this dataset's information</a>
<input type="checkbox" name="ldda_ids" value="${ldda.id}"/>
%endif
%if can_manage_library_dataset:
<a class="action-button" href="${h.url_for( controller='library', action='library_dataset_dataset_association', library_id=library.id, folder_id=folder.id, id=ldda.id, permissions=True )}">Edit this dataset's permissions</a>
%endif
%if current_version and can_modify_library_dataset:
<a class="action-button" href="${h.url_for( controller='library', action='library_dataset_dataset_association', library_id=library.id, folder_id=folder.id, replace_id=library_dataset.id )}">Upload a new version of this dataset</a>
%endif
%if ldda.has_data:
<a class="action-button" href="${h.url_for( controller='library', action='datasets', library_id=library.id, ldda_ids=str( ldda.id ), do_action='add' )}">Import this dataset into your current history</a>
<a class="action-button" href="${h.url_for( controller='library', action='download_dataset_from_folder', id=ldda.id, library_id=library.id )}">Download this dataset</a>
%endif
</div>
</td>
<td>${ldda.message}</td>
<td>${uploaded_by}</td>
<td>${ldda.create_time.strftime( "%Y-%m-%d" )}</td>
</tr>
<%
my_row = row_counter.count
row_counter.increment()
%>
<a href="${h.url_for( controller='library', action='library_dataset_dataset_association', library_id=library.id, folder_id=folder.id, id=ldda.id, info=True )}"><b>${ldda.name[:60]}</b></a>
<a id="dataset-${ldda.id}-popup" class="popup-arrow" style="display: none;">&#9660;</a>
<div popupmenu="dataset-${ldda.id}-popup">
%if can_modify_library_dataset:
<a class="action-button" href="${h.url_for( controller='library', action='library_dataset_dataset_association', library_id=library.id, folder_id=folder.id, id=ldda.id, edit_info=True )}">Edit this dataset's information</a>
%else:
<a class="action-button" href="${h.url_for( controller='library', action='library_dataset_dataset_association', library_id=library.id, folder_id=folder.id, id=ldda.id, information=True )}">View this dataset's information</a>
%endif
%if can_manage_library_dataset:
<a class="action-button" href="${h.url_for( controller='library', action='library_dataset_dataset_association', library_id=library.id, folder_id=folder.id, id=ldda.id, permissions=True )}">Edit this dataset's permissions</a>
%endif
%if can_modify_library_dataset:
<a class="action-button" href="${h.url_for( controller='library', action='library_dataset_dataset_association', library_id=library.id, folder_id=folder.id, replace_id=library_dataset.id )}">Upload a new version of this dataset</a>
%endif
%if ldda.has_data:
<a class="action-button" href="${h.url_for( controller='library', action='datasets', library_id=library.id, ldda_ids=str( ldda.id ), do_action='add' )}">Import this dataset into your current history</a>
<a class="action-button" href="${h.url_for( controller='library', action='download_dataset_from_folder', id=ldda.id, library_id=library.id )}">Download this dataset</a>
%endif
</div>
</td>
<td>${ldda.message}</td>
<td>${uploaded_by}</td>
<td>${ldda.create_time.strftime( "%Y-%m-%d" )}</td>
</tr>
<%
my_row = row_counter.count
row_counter.increment()
%>
%endif
</%def>
<%def name="render_folder( folder, folder_pad, created_ldda_ids, library_id, hidden_folder_ids, parent=None, row_counter=None, root_folder=False )">
+1 -1
View File
@@ -170,7 +170,7 @@
</div>
<div style="clear: both"></div>
<% folder = trans.app.model.LibraryFolder.get( folder_id ) %>
%if widgets:
%if upload_option == 'upload_file' and widgets:
${render_template_info( folder, library_id, widgets )}
%endif
<div class="form-row">
+20 -43
View File
@@ -980,8 +980,6 @@ class TwillTestCase( unittest.TestCase ):
different scope in the tool) cannot be properly tested when they both exist at the
same time.
"""
# TODO: RC: enhance this so that all supported field types can be passed in
# and tested. If nothing is passed, all fields are TextField.
self.home()
self.visit_url( "%s/forms/new" % self.url )
self.check_page_for_string( 'Create a new form definition' )
@@ -1253,21 +1251,13 @@ class TwillTestCase( unittest.TestCase ):
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=[], message='', root=False, check_template_str1='', check_template_str2='',
check_template_str3='' ):
dbkey='hg18', roles=[], message='', root=False, template_field_name1='', template_field_contents1='' ):
"""Add a dataset to a folder"""
filename = self.get_filename( filename )
self.home()
self.visit_url( "%s/library_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' )
# If we've been sent some template labels, make sure they are included in the upload form
if check_template_str1:
self.check_page_for_string( check_template_str1 )
if check_template_str2:
self.check_page_for_string( check_template_str2 )
if check_template_str3:
self.check_page_for_string( check_template_str3 )
tc.fv( "1", "folder_id", folder_id )
tc.formfile( "1", "file_data", filename )
tc.fv( "1", "file_format", file_format )
@@ -1275,6 +1265,9 @@ class TwillTestCase( unittest.TestCase ):
tc.fv( "1", "message", message.replace( '+', ' ' ) )
for role_id in roles:
tc.fv( "1", "roles", role_id ) # form field 7 is the select list named out_groups, note the buttons...
# Add template field contents, if any...
if template_field_name1:
tc.fv( "1", template_field_name1, template_field_contents1 )
tc.submit( "new_dataset_button" )
if root:
check_str = "Added 1 datasets to the library '%s' ( each is selected )." % folder_name
@@ -1347,7 +1340,7 @@ class TwillTestCase( unittest.TestCase ):
self.check_page_for_string( check_str )
self.home()
def upload_new_dataset_version( self, filename, library_id, folder_id, folder_name, library_dataset_id, ldda_name, file_format='auto',
dbkey='hg18', message='', check_template_str1='', check_template_str2='', check_template_str3='' ):
dbkey='hg18', message='', template_field_name1='', template_field_contents1='' ):
"""Upload new version(s) of a dataset"""
self.home()
filename = self.get_filename( filename )
@@ -1356,40 +1349,32 @@ class TwillTestCase( unittest.TestCase ):
self.check_page_for_string( 'Upload files' )
self.check_page_for_string( 'You are currently selecting a new file to replace' )
self.check_page_for_string( ldda_name )
# If we've been sent some template labels, make sure they are included in the upload form
if check_template_str1:
self.check_page_for_string( check_template_str1 )
if check_template_str2:
self.check_page_for_string( check_template_str2 )
if check_template_str3:
self.check_page_for_string( check_template_str3 )
tc.formfile( "1", "file_data", filename )
tc.fv( "1", "file_format", file_format )
tc.fv( "1", "dbkey", dbkey )
tc.fv( "1", "message", message.replace( '+', ' ' ) )
# Add template field contents, if any...
if template_field_name1:
tc.fv( "1", template_field_name1, template_field_contents1 )
tc.submit( "new_dataset_button" )
check_str = "Added 1 dataset versions to the library dataset '%s' in the folder '%s'." % ( ldda_name, folder_name )
self.check_page_for_string( check_str )
self.home()
def upload_new_dataset_versions( self, library_id, folder_id, folder_name, library_dataset_id, ldda_name, file_format='auto',
dbkey='hg18', message='', check_template_str1='', check_template_str2='', check_template_str3='' ):
dbkey='hg18', message='', template_field_name1='', template_field_contents1='' ):
"""Upload new version(s) of a dataset using a directory of files"""
self.home()
self.visit_url( "%s/library_admin/library_dataset_dataset_association?upload_option=upload_directory&library_id=%s&folder_id=%s&replace_id=%s" \
% ( self.url, library_id, folder_id, library_dataset_id ) )
self.check_page_for_string( 'Upload a directory of files' )
self.check_page_for_string( 'You are currently selecting a new file to replace' )
# If we've been sent some template labels, make sure they are included in the upload form
if check_template_str1:
self.check_page_for_string( check_template_str1 )
if check_template_str2:
self.check_page_for_string( check_template_str2 )
if check_template_str3:
self.check_page_for_string( check_template_str3 )
tc.fv( "1", "file_format", file_format )
tc.fv( "1", "dbkey", dbkey )
tc.fv( "1", "message", message.replace( '+', ' ' ) )
tc.fv( "1", "server_dir", "library" )
# Add template field contents, if any...
if template_field_name1:
tc.fv( "1", template_field_name1, template_field_contents1 )
tc.submit( "new_dataset_button" )
check_str = "Added 3 dataset versions to the library dataset '%s' in the folder '%s'." % ( ldda_name, folder_name )
self.check_page_for_string( check_str )
@@ -1406,19 +1391,12 @@ class TwillTestCase( unittest.TestCase ):
self.check_page_for_string( check_str )
self.home()
def add_dir_of_files_from_admin_view( self, library_id, folder_id, file_format='auto', dbkey='hg18', roles_tuple=[],
message='', check_str_after_submit='', check_str1='', check_str2='', check_str3='' ):
message='', check_str_after_submit='', template_field_name1='', template_field_contents1='' ):
"""Add a directory of datasets to a folder"""
# roles is a list of tuples: [ ( role_id, role_description ) ]
self.home()
self.visit_url( "%s/library_admin/library_dataset_dataset_association?upload_option=upload_directory&library_id=%s&folder_id=%s" % ( self.url, library_id, folder_id ) )
self.check_page_for_string( 'Upload a directory of files' )
# If we've been sent some template labels, make sure they are included in the upload form
if check_str1:
self.check_page_for_string( check_str1 )
if check_str2:
self.check_page_for_string( check_str2 )
if check_str3:
self.check_page_for_string( check_str3 )
tc.fv( "1", "folder_id", folder_id )
tc.fv( "1", "file_format", file_format )
tc.fv( "1", "dbkey", dbkey )
@@ -1426,24 +1404,20 @@ class TwillTestCase( unittest.TestCase ):
tc.fv( "1", "server_dir", "library" )
for role_tuple in roles_tuple:
tc.fv( "1", "roles", role_tuple[1] ) # role_tuple[1] is the role name
# Add template field contents, if any...
if template_field_name1:
tc.fv( "1", template_field_name1, template_field_contents1 )
tc.submit( "new_dataset_button" )
if check_str_after_submit:
self.check_page_for_string( check_str_after_submit )
self.home()
def add_dir_of_files_from_libraries_view( self, library_id, folder_id, selected_dir, file_format='auto', dbkey='hg18', roles_tuple=[],
message='', check_str_after_submit='', check_str1='', check_str2='', check_str3='' ):
message='', check_str_after_submit='', template_field_name1='', template_field_contents1='' ):
"""Add a directory of datasets to a folder"""
# roles is a list of tuples: [ ( role_id, role_description ) ]
self.home()
self.visit_url( "%s/library/library_dataset_dataset_association?upload_option=upload_directory&library_id=%s&folder_id=%s" % ( self.url, library_id, folder_id ) )
self.check_page_for_string( 'Upload a directory of files' )
# If we've been sent some template labels, make sure they are included in the upload form
if check_str1:
self.check_page_for_string( check_str1 )
if check_str2:
self.check_page_for_string( check_str2 )
if check_str3:
self.check_page_for_string( check_str3 )
tc.fv( "1", "folder_id", folder_id )
tc.fv( "1", "file_format", file_format )
tc.fv( "1", "dbkey", dbkey )
@@ -1451,6 +1425,9 @@ class TwillTestCase( unittest.TestCase ):
tc.fv( "1", "server_dir", selected_dir )
for role_tuple in roles_tuple:
tc.fv( "1", "roles", role_tuple[1] ) # role_tuple[1] is the role name
# Add template field contents, if any...
if template_field_name1:
tc.fv( "1", template_field_name1, template_field_contents1 )
tc.submit( "new_dataset_button" )
if check_str_after_submit:
self.check_page_for_string( check_str_after_submit )
+1 -1
View File
@@ -41,7 +41,7 @@ class TestFormsAndRequests( TwillTestCase ):
global form_one_name
name = form_one_name
desc = "This is Form One's description"
formtype = 'Sequencing Request Form'
formtype = galaxy.model.FormDefinition.types.REQUEST
self.create_form( name=name, desc=desc, formtype=formtype )
self.home()
self.visit_page( 'forms/manage' )
File diff suppressed because it is too large Load Diff