details: http://www.bx.psu.edu/hg/galaxy/rev/0e78d558fe57 changeset: 2958:0e78d558fe57 user: rc date: Wed Nov 04 10:16:20 2009 -0500 description: Fixed the ordering in selectboxes Fixed a bug in editing samples in the request page diffstat: lib/galaxy/model/mapping.py | 3 ++- lib/galaxy/web/controllers/forms.py | 4 +++- lib/galaxy/web/controllers/requests.py | 9 +++++---- lib/galaxy/web/controllers/requests_admin.py | 22 ++++++++++++---------- templates/admin/requests/show_request.mako | 2 +- templates/requests/show_request.mako | 4 ---- test/base/twilltestcase.py | 2 +- 7 files changed, 24 insertions(+), 22 deletions(-) diffs (191 lines): diff -r 5b2d593d9aed -r 0e78d558fe57 lib/galaxy/model/mapping.py --- a/lib/galaxy/model/mapping.py Wed Nov 04 10:04:51 2009 -0500 +++ b/lib/galaxy/model/mapping.py Wed Nov 04 10:16:20 2009 -0500 @@ -652,7 +652,8 @@ primaryjoin=( Request.table.c.user_id == User.table.c.id ), backref="requests" ), samples=relation( Sample, - primaryjoin=( Request.table.c.id == Sample.table.c.request_id ) ), + primaryjoin=( Request.table.c.id == Sample.table.c.request_id ), + order_by=asc(Sample.table.c.update_time) ), folder=relation( LibraryFolder, primaryjoin=( Request.table.c.folder_id == LibraryFolder.table.c.id ) ), library=relation( Library, diff -r 5b2d593d9aed -r 0e78d558fe57 lib/galaxy/web/controllers/forms.py --- a/lib/galaxy/web/controllers/forms.py Wed Nov 04 10:04:51 2009 -0500 +++ b/lib/galaxy/web/controllers/forms.py Wed Nov 04 10:16:20 2009 -0500 @@ -60,7 +60,9 @@ form_type_selectbox.add_option('Select one', 'none', selected=True) else: form_type_selectbox.add_option('Select one', 'none') - for ft in trans.app.model.FormDefinition.types.items(): + fd_types = trans.app.model.FormDefinition.types.items() + fd_types.sort() + for ft in fd_types: if selected == ft[1]: form_type_selectbox.add_option(ft[1], ft[1], selected=True) else: diff -r 5b2d593d9aed -r 0e78d558fe57 lib/galaxy/web/controllers/requests.py --- a/lib/galaxy/web/controllers/requests.py Wed Nov 04 10:04:51 2009 -0500 +++ b/lib/galaxy/web/controllers/requests.py Wed Nov 04 10:16:20 2009 -0500 @@ -304,8 +304,7 @@ s = trans.app.model.Sample(sample_name, '', request, form_values) s.flush() else: - for index in range(len(current_samples)): - sample_index = index + for sample_index in range(len(current_samples)): sample_name = current_samples[sample_index][0] new_sample_name = util.restore_text( params.get( 'sample_%i_name' % sample_index, '' ) ) sample_values = [] @@ -379,8 +378,10 @@ details=details, edit_mode=edit_mode) def __select_request_type(self, trans, rtid): + requesttype_list = trans.sa_session.query( trans.app.model.RequestType )\ + .order_by( trans.app.model.RequestType.name.asc() ) rt_ids = ['none'] - for rt in trans.sa_session.query( trans.app.model.RequestType ): + for rt in requesttype_list: if not rt.deleted: rt_ids.append(str(rt.id)) select_reqtype = SelectField('select_request_type', @@ -390,7 +391,7 @@ select_reqtype.add_option('Select one', 'none', selected=True) else: select_reqtype.add_option('Select one', 'none') - for rt in trans.sa_session.query( trans.app.model.RequestType ): + for rt in requesttype_list: if not rt.deleted: if rtid == rt.id: select_reqtype.add_option(rt.name, rt.id, selected=True) diff -r 5b2d593d9aed -r 0e78d558fe57 lib/galaxy/web/controllers/requests_admin.py --- a/lib/galaxy/web/controllers/requests_admin.py Wed Nov 04 10:04:51 2009 -0500 +++ b/lib/galaxy/web/controllers/requests_admin.py Wed Nov 04 10:16:20 2009 -0500 @@ -266,8 +266,10 @@ #---- Request Creation ---------------------------------------------------------- # def __select_request_type(self, trans, rtid): + requesttype_list = trans.sa_session.query( trans.app.model.RequestType )\ + .order_by( trans.app.model.RequestType.name.asc() ) rt_ids = ['none'] - for rt in trans.sa_session.query( trans.app.model.RequestType ): + for rt in requesttype_list: if not rt.deleted: rt_ids.append(str(rt.id)) select_reqtype = SelectField('select_request_type', @@ -277,7 +279,7 @@ select_reqtype.add_option('Select one', 'none', selected=True) else: select_reqtype.add_option('Select one', 'none') - for rt in trans.sa_session.query( trans.app.model.RequestType ): + for rt in requesttype_list: if not rt.deleted: if rtid == rt.id: select_reqtype.add_option(rt.name, rt.id, selected=True) @@ -799,7 +801,7 @@ # save all the new/unsaved samples entered by the user if edit_mode == 'False': for index in range(len(current_samples)-len(request.samples)): - sample_index = index + len(request.samples) + sample_index = len(request.samples) sample_name = util.restore_text( params.get( 'sample_%i_name' % sample_index, '' ) ) sample_values = [] for field_index in range(len(request.type.sample_form.fields)): @@ -992,7 +994,7 @@ bar_code = util.restore_text(params.get('sample_%i_bar_code' % index, '')) # check for empty bar code if not bar_code.strip(): - msg = 'Please fill the bar code for sample <b>%s</b>.' % request.samples[index].name + msg = 'Please fill the barcode for sample <b>%s</b>.' % request.samples[index].name break # check all the unsaved bar codes count = 0 @@ -1000,8 +1002,8 @@ if bar_code == util.restore_text(params.get('sample_%i_bar_code' % i, '')): count = count + 1 if count > 1: - msg = '''The bar code <b>%s</b> of sample <b>%s</b> already belongs - another sample in this request. The sample bar codes must + msg = '''The barcode <b>%s</b> of sample <b>%s</b> belongs + another sample in this request. The sample barcodes must be unique throughout the system''' % \ (bar_code, request.samples[index].name) break @@ -1009,7 +1011,7 @@ all_samples = trans.sa_session.query( trans.app.model.Sample ) for sample in all_samples: if bar_code == sample.bar_code: - msg = '''The bar code <b>%s</b> of sample <b>%s</b> already + msg = '''The bar code <b>%s</b> of sample <b>%s</b> belongs another sample. The sample bar codes must be unique throughout the system''' % \ (bar_code, request.samples[index].name) @@ -1044,7 +1046,7 @@ return trans.response.send_redirect( web.url_for( controller='requests_admin', action='bar_codes', request_id=request.id, - msg='Bar codes has been saved for this request', + msg='Bar codes have been saved for this request', messagetype='done')) def __set_request_state(self, request): @@ -1162,8 +1164,8 @@ if params.get( 'create', False ): return trans.fill_template( '/admin/requests/create_request_type.mako', request_forms=get_all_forms( trans, - filter=dict(deleted=False), - form_type=trans.app.model.FormDefinition.types.REQUEST ), + filter=dict(deleted=False), + form_type=trans.app.model.FormDefinition.types.REQUEST ), sample_forms=get_all_forms( trans, filter=dict(deleted=False), form_type=trans.app.model.FormDefinition.types.SAMPLE ), diff -r 5b2d593d9aed -r 0e78d558fe57 templates/admin/requests/show_request.mako --- a/templates/admin/requests/show_request.mako Wed Nov 04 10:04:51 2009 -0500 +++ b/templates/admin/requests/show_request.mako Wed Nov 04 10:16:20 2009 -0500 @@ -195,7 +195,7 @@ <div class="toolForm"> ##<div class="toolFormTitle">Samples (${len(request.samples)})</div> - <form id="edit_form" name="edit_form" action="${h.url_for( controller='requests_admin', action='show_request' )}" enctype="multipart/form-data" method="post" > + <form id="show_request" name="show_request" action="${h.url_for( controller='requests_admin', action='show_request', edit_mode=edit_mode )}" enctype="multipart/form-data" method="post" > <div class="form-row"> %if current_samples: %if not request.type.sample_form.layout: diff -r 5b2d593d9aed -r 0e78d558fe57 templates/requests/show_request.mako --- a/templates/requests/show_request.mako Wed Nov 04 10:04:51 2009 -0500 +++ b/templates/requests/show_request.mako Wed Nov 04 10:16:20 2009 -0500 @@ -224,20 +224,16 @@ %endif </td> <td> - ##<div class="form-row"> <label>Import from csv file</label> <input type="file" name="file_data" /> <input type="submit" name="import_samples_button" value="Import samples"/> - ##</div> </td> <td> - ##<div class="form-row"> %if current_samples: <label>Copy from sample</label> ${sample_copy.get_html()} %endif <input type="submit" name="add_sample_button" value="Add New"/> - ##</div> </td> </div> </tr> diff -r 5b2d593d9aed -r 0e78d558fe57 test/base/twilltestcase.py --- a/test/base/twilltestcase.py Wed Nov 04 10:04:51 2009 -0500 +++ b/test/base/twilltestcase.py Wed Nov 04 10:16:20 2009 -0500 @@ -1272,7 +1272,7 @@ for index, bar_code in enumerate(bar_codes): tc.fv( "1", "sample_%i_bar_code" % index, bar_code ) tc.submit( "save_bar_codes" ) - self.check_page_for_string( 'Bar codes has been saved for this request' ) + self.check_page_for_string( 'Bar codes have been saved for this request' ) def change_sample_state( self, sample_name, sample_id, new_state_id, new_state_name, comment='' ): self.home() self.visit_url( "%s/requests_admin/show_events?sample_id=%i" % (self.url, sample_id) )