galaxy-dist commit 7bded9108bd8: More miscellaneous Sample Tracking cleanup and bug fixes, move supported form_builder field types from form_builder.BaseField to Request.model and Sample.model.
# HG changeset patch -- Bitbucket.org # Project galaxy-dist # URL http://bitbucket.org/galaxy/galaxy-dist/overview # User Greg Von Kuster <greg@bx.psu.edu> # Date 1290007512 18000 # Node ID 7bded9108bd8297ea609e9ec06bbe516b5f0b83a # Parent a68c74ec8cfbc641db4b6fe424e3f77b9f3c5d3c More miscellaneous Sample Tracking cleanup and bug fixes, move supported form_builder field types from form_builder.BaseField to Request.model and Sample.model. --- a/templates/admin/requests/edit_request_type.mako +++ b/templates/admin/requests/edit_request_type.mako @@ -28,7 +28,7 @@ </div><div class="form-row"><label> - Sequencing Request Form definition: + Sequencing request form definition: </label><select name="form_id"> %for form in forms: @@ -42,7 +42,7 @@ </div><div class="form-row"><label> - Sample Form definition: + Sample form definition: </label><select name="form_id"> %for form in forms: --- a/lib/galaxy/web/form_builder.py +++ b/lib/galaxy/web/form_builder.py @@ -18,12 +18,6 @@ class BaseField(object): return ' disabled="disabled"' else: return '' - @staticmethod - def form_field_types(): - return ['TextField', 'TextArea', 'SelectField', 'CheckboxField', 'AddressField', 'WorkflowField'] - @staticmethod - def sample_field_types(): - return ['TextField', 'SelectField', 'CheckboxField', 'WorkflowField'] class TextField(BaseField): """ @@ -559,8 +553,8 @@ class AddressField(BaseField): self.select_address.add_option( 'Add a new address', 'new' ) return self.select_address.get_html( disabled=disabled ) + address_html -class WorkflowField(BaseField): - def __init__(self, name, user=None, value=None, params=None): +class WorkflowField( BaseField ): + def __init__( self, name, user=None, value=None, params=None ): self.name = name self.user = user self.value = value @@ -580,7 +574,7 @@ class WorkflowField(BaseField): else: self.select_workflow.add_option( a.name, str( a.id ) ) return self.select_workflow.get_html( disabled=disabled ) - + def get_suite(): """Get unittest suite for this module""" import doctest, sys @@ -592,11 +586,11 @@ def build_select_field( trans, objs, lab selected_value='none', refresh_on_change=False, multiple=False, display=None, size=None ): """ Build a SelectField given a set of objects. The received params are: - - objs: the set of object used to populate the option list + - objs: the set of objects used to populate the option list - label_attr: the attribute of each obj (e.g., name, email, etc ) whose value is used to populate each option label. If the string 'self' is passed as label_attr, each obj in objs is assumed to be a string, so the obj itself is used - select_field_name: the name of the SelectField - - initial_value: the vlaue of the first option in the SelectField - allows for an option telling the user to select something + - initial_value: the value of the first option in the SelectField - allows for an option telling the user to select something - selected_value: the value of the currently selected option - refresh_on_change: True if the SelectField should perform a refresh_on_change """ --- a/templates/admin/requests/view_request_type.mako +++ b/templates/admin/requests/view_request_type.mako @@ -38,7 +38,7 @@ <div style="clear: both"></div></div><div class="form-row"> - <label>Sequencing Request form definition</label> + <label>Sequencing request form definition</label> ${request_type.request_form.name} </div><div class="form-row"> --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -1495,12 +1495,11 @@ class MetadataFile( object ): class FormDefinition( object ): # The following form_builder classes are supported by the FormDefinition class. - # AddressField, CheckboxField, SelectField, TextArea, TextField, WorkflowField supported_field_types = [ AddressField, CheckboxField, SelectField, TextArea, TextField, WorkflowField ] types = Bunch( REQUEST = 'Sequencing Request Form', SAMPLE = 'Sequencing Sample Form', LIBRARY_INFO_TEMPLATE = 'Library information template', - USER_INFO = 'User Information' ) + USER_INFO = 'User Information' ) def __init__( self, name=None, desc=None, fields=[], form_definition_current=None, form_type=None, layout=None ): self.name = name self.desc = desc @@ -1792,6 +1791,8 @@ class RequestTypePermissions( object ): self.role = role class Sample( object ): + # The following form_builder classes are supported by the Sample class. + supported_field_types = [ CheckboxField, SelectField, TextField, WorkflowField ] bulk_operations = Bunch( CHANGE_STATE = 'Change state', SELECT_LIBRARY = 'Select data library and folder' ) api_collection_visible_keys = ( 'id', 'name' ) --- a/lib/galaxy/web/controllers/requests_common.py +++ b/lib/galaxy/web/controllers/requests_common.py @@ -588,12 +588,8 @@ class RequestsCommon( BaseController, Us request = trans.sa_session.query( trans.model.Request ).get( trans.security.decode_id( request_id ) ) except: return invalid_id_redirect( trans, cntrller, request_id ) - events_list = [] - for event in request.events: - events_list.append( ( event.state, time_ago( event.update_time ), event.comment ) ) return trans.fill_template( '/requests/common/view_request_history.mako', cntrller=cntrller, - events_list=events_list, request=request ) @web.expose @web.require_login( "edit email notification settings" ) @@ -777,7 +773,7 @@ class RequestsCommon( BaseController, Us search_box=search_box ) @web.expose @web.require_login( "sample events" ) - def sample_events( self, trans, cntrller, **kwd ): + def view_sample_history( self, trans, cntrller, **kwd ): params = util.Params( kwd ) status = params.get( 'status', 'done' ) message = util.restore_text( params.get( 'message', '' ) ) @@ -786,15 +782,8 @@ class RequestsCommon( BaseController, Us sample = trans.sa_session.query( trans.model.Sample ).get( trans.security.decode_id( sample_id ) ) except: return invalid_id_redirect( trans, cntrller, sample_id ) - events_list = [] - for event in sample.events: - events_list.append( ( event.state.name, - event.state.desc, - time_ago( event.update_time ), - event.comment ) ) - return trans.fill_template( '/requests/common/sample_events.mako', + return trans.fill_template( '/requests/common/view_sample_history.mako', cntrller=cntrller, - events_list=events_list, sample=sample ) @web.expose @web.require_login( "add sample" ) @@ -1054,9 +1043,9 @@ class RequestsCommon( BaseController, Us # selected sets of samples. If samples are selected, the sample_operation param # will have a value other than 'none', and the samples param will be a list of # encoded sample ids. There are currently only 2 multi-select operations; - # 'Change state' and 'Select data library and folder'. If sample_operation is - # 'none, then the samples param will be a list of sample objects. - if sample_operation == 'Change state': + # model.Sample.bulk_operations.CHANGE_STATE and model.sample.bulk_operations.SELECT_LIBRARY. + # If sample_operation is 'none, then the samples param will be a list of sample objects. + if sample_operation == trans.model.Sample.bulk_operations.CHANGE_STATE: sample_state_id = params.get( 'sample_state_id', None ) if sample_state_id in [ None, 'none' ]: message = "Select a new state from the <b>Change current state</b> list before clicking the <b>Save</b> button." @@ -1090,7 +1079,7 @@ class RequestsCommon( BaseController, Us cntrller=cntrller, action='update_request_state', request_id=trans.security.encode_id( request.id ) ) ) - elif sample_operation == 'Select data library and folder': + elif sample_operation == trans.model.sample.bulk_operations.SELECT_LIBRARY: # TODO: fix the code so that the sample_operation_select_field does not use # sample_0_library_id as it's name. it should use something like sample_operation_library_id # and sample_operation_folder_id because the name sample_0_library_id should belong to the --- a/lib/galaxy/web/controllers/forms.py +++ b/lib/galaxy/web/controllers/forms.py @@ -64,12 +64,12 @@ class FormsGrid( grids.Grid ): ] class Forms( BaseController ): - # Empty form field + # Empty TextField empty_field = { 'label': '', 'helptext': '', 'visible': True, 'required': False, - 'type': BaseField.form_field_types()[0], + 'type': model.TextField.__name__, 'selectlist': [], 'layout': 'none', 'default': '' } @@ -597,12 +597,12 @@ class Forms( BaseController ): self.selectbox_options = [] # if the form is for defining samples, then use the sample field types # which does not include TextArea & AddressField - if form_type == trans.app.model.FormDefinition.types.SAMPLE: - for ft in BaseField.sample_field_types(): - self.fieldtype.add_option(ft, ft) + if form_type == trans.model.FormDefinition.types.SAMPLE: + for ft in trans.model.Sample.supported_field_types: + self.fieldtype.add_option( ft.__name__, ft.__name__ ) else: - for ft in BaseField.form_field_types(): - self.fieldtype.add_option(ft, ft) + for ft in trans.model.Request.supported_field_types: + self.fieldtype.add_option( ft.__name__, ft__name__ ) self.required = SelectField('field_required_'+str(index), display='radio') self.required.add_option('Required', 'required') self.required.add_option('Optional', 'optional', selected=True) @@ -632,22 +632,22 @@ class Forms( BaseController ): field[ 'selectlist' ] = ['', ''] # if the form is for defining samples, then use the sample field types # which does not include TextArea & AddressField - if form_type == trans.app.model.FormDefinition.types.SAMPLE: - for ft in BaseField.sample_field_types(): - if ft == field['type']: - self.fieldtype.add_option(ft, ft, selected=True) + if form_type == trans.model.FormDefinition.types.SAMPLE: + for ft in trans.model.Sample.supported_field_types: + if ft.__name__ == field[ 'type' ]: + self.fieldtype.add_option( ft.__name__, ft__name__, selected=True ) if ft == 'SelectField': - self.selectbox_ui(field) + self.selectbox_ui( field ) else: - self.fieldtype.add_option(ft, ft) + self.fieldtype.add_option( ft.__name__, ft.__name__ ) else: - for ft in BaseField.form_field_types(): - if ft == field['type']: - self.fieldtype.add_option(ft, ft, selected=True) + for ft in trans.model.Request.supported_field_types: + if ft.__name__ == field[ 'type' ]: + self.fieldtype.add_option( ft.__name__, ft.__name__, selected=True ) if ft == 'SelectField': - self.selectbox_ui(field) + self.selectbox_ui( field ) else: - self.fieldtype.add_option(ft, ft) + self.fieldtype.add_option( ft.__name__, ft.__name__ ) # required/optional if field['required'] == 'required': self.required = SelectField('field_required_'+str(self.index), display='radio') --- a/templates/admin/requests/create_request_type.mako +++ b/templates/admin/requests/create_request_type.mako @@ -39,7 +39,7 @@ <div style="clear: both"></div></div> %endfor - <div class="toolFormTitle">Possible sample states</div> + <div class="toolFormTitle">Sample states</div> %if len(rt_states_widgets): %for index, info in enumerate(rt_states_widgets): ${render_state( index, info[0], info[1] )} --- a/templates/requests/common/common.mako +++ b/templates/requests/common/common.mako @@ -160,7 +160,7 @@ %if is_unsubmitted: <td>Unsubmitted</td> %else: - <td valign="top"><a href="${h.url_for( controller='requests_common', action='sample_events', cntrller=cntrller, sample_id=trans.security.encode_id( sample.id ) )}">${sample.state.name}</a></td> + <td valign="top"><a href="${h.url_for( controller='requests_common', action='view_sample_history', cntrller=cntrller, sample_id=trans.security.encode_id( sample.id ) )}">${sample.state.name}</a></td> %endif %else: <td></td> @@ -334,7 +334,7 @@ %if is_unsubmitted: <td>Unsubmitted</td> %else: - <td><a id="sampleState-${sample.id}" href="${h.url_for( controller='requests_common', action='sample_events', cntrller=cntrller, sample_id=trans.security.encode_id( sample.id ) )}">${render_sample_state( sample )}</a></td> + <td><a id="sampleState-${sample.id}" href="${h.url_for( controller='requests_common', action='view_sample_history', cntrller=cntrller, sample_id=trans.security.encode_id( sample.id ) )}">${render_sample_state( sample )}</a></td> %endif %if sample_widget_library and library_cntrller is not None: <td><a href="${h.url_for( controller='library_common', action='browse_library', cntrller=library_cntrller, id=trans.security.encode_id( sample_widget_library.id ) )}">${sample_widget_library.name}</a></td> --- a/test/base/twilltestcase.py +++ b/test/base/twilltestcase.py @@ -1536,7 +1536,7 @@ class TwillTestCase( unittest.TestCase ) self.visit_url( "%s/requests_common/view_request_history?cntrller=%s&id=%s" % ( self.url, cntrller, request_id ) ) self.check_page( strings_displayed, strings_displayed_count, strings_not_displayed ) def view_sample_history( self, cntrller, sample_id, strings_displayed=[], strings_displayed_count=[], strings_not_displayed=[] ): - self.visit_url( "%s/requests_common/sample_events?cntrller=%s&sample_id=%s" % ( self.url, cntrller, sample_id ) ) + self.visit_url( "%s/requests_common/view_sample_history?cntrller=%s&sample_id=%s" % ( self.url, cntrller, sample_id ) ) self.check_page( strings_displayed, strings_displayed_count, strings_not_displayed ) def edit_basic_request_info( self, cntrller, request_id, name, new_name='', new_desc='', new_fields=[], strings_displayed=[], strings_displayed_after_submit=[] ): --- a/templates/requests/common/edit_basic_request_info.mako +++ b/templates/requests/common/edit_basic_request_info.mako @@ -8,7 +8,6 @@ is_unsubmitted = request.is_unsubmitted can_add_samples = is_unsubmitted can_reject = is_admin and is_submitted - can_select_datasets = is_admin and ( is_complete or is_submitted ) can_submit_request = request.samples and is_unsubmitted %> @@ -24,9 +23,6 @@ %if can_reject: <a class="action-button" href="${h.url_for( controller='requests_admin', action='reject_request', cntrller=cntrller, id=trans.security.encode_id( request.id ) )}">Reject this request</a> %endif - %if can_select_datasets: - <a class="action-button" href="${h.url_for( controller='requests_admin', action='select_datasets_to_transfer', request_id=trans.security.encode_id( request.id ) )}">Select datasets to transfer</a> - %endif </div></ul> --- /dev/null +++ b/templates/requests/common/view_sample_history.mako @@ -0,0 +1,38 @@ +<%inherit file="/base.mako"/> +<%namespace file="/message.mako" import="render_msg" /> + +<% from galaxy.web.framework.helpers import time_ago %> + +<br/><br/> +<ul class="manage-table-actions"> + <li><a class="action-button" href="${h.url_for( controller='requests_common', action='view_request', cntrller=cntrller, id=trans.security.encode_id( sample.request.id ) )}">Browse this request</a></li> +</ul> + +%if message: + ${render_msg( message, status )} +%endif + +<h3>History of sample "${sample.name}"</h3> + +<div class="toolForm"> + <table class="grid"> + <thead> + <tr> + <th>State</th> + <th>Description</th> + <th>Last Updated</th> + <th>Comments</th> + </tr> + </thead> + <tbody> + %for event in sample.events: + <tr> + <td><b>${event.state.name}</b></td> + <td>${event.state.desc}</td> + <td>${time_ago( event.update_time )}</td> + <td>${event.comment}</td> + </tr> + %endfor + </tbody> + </table> +</div> --- a/lib/galaxy/config.py +++ b/lib/galaxy/config.py @@ -44,8 +44,6 @@ class Configuration( object ): # web API self.enable_api = string_as_bool( kwargs.get( 'enable_api', False ) ) self.enable_openid = string_as_bool( kwargs.get( 'enable_openid', False ) ) - # Communication with a sequencer - self.enable_sequencer_communication = string_as_bool( kwargs.get( 'enable_sequencer_communication', False ) ) # dataset Track files self.track_store_path = kwargs.get( "track_store_path", "${extra_files_path}/tracks") self.tool_path = resolve_path( kwargs.get( "tool_path", "tools" ), self.root ) --- a/templates/requests/common/view_request_history.mako +++ b/templates/requests/common/view_request_history.mako @@ -2,6 +2,8 @@ <%namespace file="/message.mako" import="render_msg" /><% + from galaxy.web.framework.helpers import time_ago + is_admin = cntrller == 'requests_admin' and trans.user_is_admin() is_complete = request.is_complete is_submitted = request.is_submitted @@ -41,16 +43,16 @@ <thead><tr><th>State</th> - <th>Last Update</th> + <th>Last Updated</th><th>Comments</th></tr></thead><tbody> - %for state, updated, comments in events_list: - <tr class="libraryRow libraryOrFolderRow" id="libraryRow"> - <td><b><a>${state}</a></b></td> - <td><a>${updated}</a></td> - <td><a>${comments}</a></td> + %for event in request.events: + <tr> + <td><b>${event.state}</b></td> + <td>${time_ago( event.update_time )}</td> + <td>${event.comment}</td></tr> %endfor </tbody> --- a/templates/requests/common/sample_events.mako +++ /dev/null @@ -1,44 +0,0 @@ -<%inherit file="/base.mako"/> -<%namespace file="/message.mako" import="render_msg" /> - -<%def name="title()">Events for Sample ${sample.name}</%def> - -<h2>Events for Sample "${sample.name}"</h2> -<ul class="manage-table-actions"> - <li><a class="action-button" href="${h.url_for( controller='requests_common', action='view_request', cntrller=cntrller, id=trans.security.encode_id( sample.request.id ) )}">Browse this request</a></li> -</ul> -<h3>Sequencing Request "${sample.request.name}"</h3> - -%if message: - ${render_msg( message, status )} -%endif - -<div class="toolForm"> - <div class="form-row"> - <div class="toolParamHelp" style="clear: both;"> - <b>Possible states: </b> - <% states = " > ".join([ ss.name for ss in sample.request.type.states ]) %> - ${states} - </div> - </div> - <table class="grid"> - <thead> - <tr> - <th>State</th> - <th>Description</th> - <th>Last Update</th> - <th>Comments</th> - </tr> - </thead> - <tbody> - %for state, desc, updated, comments in events_list: - <tr class="libraryRow libraryOrFolderRow" id="libraryRow"> - <td><b><a>${state}</a></b></td> - <td><a>${desc}</a></td> - <td><a>${updated}</a></td> - <td><a>${comments}</a></td> - </tr> - %endfor - </tbody> - </table> -</div>
participants (1)
-
commits-noreply@bitbucket.org