[hg] galaxy 2498: LIMS Changes
details: http://www.bx.psu.edu/hg/galaxy/rev/643e3cd86e0b changeset: 2498:643e3cd86e0b user: rc date: Fri Jul 24 12:16:32 2009 -0400 description: LIMS Changes - Unique sample names within a request is now enforced - minor UI tweaks - show/hide request details 11 file(s) affected in this change: lib/galaxy/web/controllers/requests.py lib/galaxy/web/controllers/requests_admin.py templates/admin/index.mako templates/admin/requests/grid.mako templates/admin/requests/show_request.mako templates/admin/samples/bar_codes.mako templates/admin/samples/events.mako templates/requests/new_request.mako templates/requests/select_request_type.mako templates/requests/show_request.mako templates/sample/sample_events.mako diffs (504 lines): diff -r 4e0671e6eeaa -r 643e3cd86e0b lib/galaxy/web/controllers/requests.py --- a/lib/galaxy/web/controllers/requests.py Fri Jul 24 11:22:31 2009 -0400 +++ b/lib/galaxy/web/controllers/requests.py Fri Jul 24 12:16:32 2009 -0400 @@ -97,17 +97,18 @@ for s in request.samples: self.current_samples.append([s.name, s.values.content]) if add_sample: - self.current_samples.append(['New Sample',['' for field in request.type.sample_form.fields]]) + self.current_samples.append(['Sample_%i' % (len(self.current_samples)+1),['' for field in request.type.sample_form.fields]]) # selectfield of all samples copy_list = SelectField('copy_sample') copy_list.add_option('None', -1, selected=True) for i, s in enumerate(self.current_samples): - copy_list.add_option(i+1, i) + copy_list.add_option(i+1, i) + self.details_state = 'Show request details' return trans.fill_template( '/requests/show_request.mako', request=request, request_details=self.request_details(trans, id), current_samples = self.current_samples, - sample_copy=copy_list) + sample_copy=copy_list, details_state=self.details_state) def request_details(self, trans, id): ''' Shows the request details @@ -141,7 +142,20 @@ value=request.values.content[index], helptext=field['helptext']+' ('+req+')')) return request_details - + + def __update_samples(self, request, **kwd): + params = util.Params( kwd ) + num_samples = len(self.current_samples) + self.current_samples = [] + for s in request.samples: + self.current_samples.append([s.name, s.values.content]) + for index in range(num_samples-len(request.samples)): + sample_index = 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)): + sample_values.append(util.restore_text( params.get( 'sample_%i_field_%i' % (sample_index, field_index), '' ) )) + self.current_samples.append([sample_name, sample_values]) @web.expose def show_request(self, trans, **kwd): params = util.Params( kwd ) @@ -157,26 +171,17 @@ **kwd) ) if params.get('add_sample_button', False) == 'Add New': # save the all (saved+unsaved) sample info in 'current_samples' - num_samples = len(self.current_samples) - self.current_samples = [] - for s in request.samples: - self.current_samples.append([s.name, s.values.content]) - for index in range(num_samples-len(request.samples)): - sample_index = 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)): - sample_values.append(util.restore_text( params.get( 'sample_%i_field_%i' % (sample_index, field_index), '' ) )) - self.current_samples.append([sample_name, sample_values]) + self.__update_samples(request, **kwd) # add an empty or filled sample # if the user has selected a sample no. to copy then copy the contents # of the src sample to the new sample else an empty sample src_sample_index = int(params.get( 'copy_sample', -1 )) if src_sample_index == -1: # empty sample - self.current_samples.append(['New Sample',['' for field in request.type.sample_form.fields]]) + self.current_samples.append(['Sample_%i' % (len(self.current_samples)+1),['' for field in request.type.sample_form.fields]]) else: - self.current_samples.append([self.current_samples[src_sample_index][0]+'_copy',[val for val in self.current_samples[src_sample_index][1]]]) + self.current_samples.append([self.current_samples[src_sample_index][0]+'_%i' % (len(self.current_samples)+1), + [val for val in self.current_samples[src_sample_index][1]]]) # selectfield of all samples copy_list = SelectField('copy_sample') copy_list.add_option('None', -1, selected=True) @@ -186,11 +191,38 @@ request=request, request_details=self.request_details(trans, request.id), current_samples = self.current_samples, - sample_copy=copy_list) + sample_copy=copy_list, details_state=self.details_state) if params.get('save_samples_button', False) == 'Save': - num_samples = len(self.current_samples) + # update current_samples + self.__update_samples(request, **kwd) + # check for duplicate sample names + msg = '' + for index in range(len(self.current_samples)-len(request.samples)): + sample_index = index + len(request.samples) + sample_name = self.current_samples[sample_index][0] + if not sample_name.strip(): + msg = 'Please enter the name of sample number %i' % sample_index + break + count = 0 + for i in range(len(self.current_samples)): + if sample_name == self.current_samples[i][0]: + count = count + 1 + if count > 1: + msg = "This request has <b>%i</b> samples with the name <b>%s</b>.\nSamples belonging to a request must have unique names." % (count, sample_name) + break + if msg: + copy_list = SelectField('copy_sample') + copy_list.add_option('None', -1, selected=True) + for i, s in enumerate(self.current_samples): + copy_list.add_option(i+1, i) + return trans.fill_template( '/requests/show_request.mako', + request=request, + request_details=self.request_details(trans, request.id), + current_samples = self.current_samples, + sample_copy=copy_list, details_state=self.details_state, + messagetype='error', msg=msg) # save all the new/unsaved samples entered by the user - for index in range(num_samples-len(request.samples)): + for index in range(len(self.current_samples)-len(request.samples)): sample_index = index + len(request.samples) sample_name = util.restore_text( params.get( 'sample_%i_name' % sample_index, '' ) ) sample_values = [] @@ -208,7 +240,6 @@ action='list', operation='show_request', id=trans.security.encode_id(request.id)) ) - @web.expose def delete_sample(self, trans, **kwd): params = util.Params( kwd ) @@ -221,6 +252,7 @@ if s: s.delete() s.flush() + request.flush() del self.current_samples[sample_index] copy_list = SelectField('copy_sample') copy_list.add_option('None', -1, selected=True) @@ -230,7 +262,26 @@ request=request, request_details=self.request_details(trans, request.id), current_samples = self.current_samples, - sample_copy=copy_list) + sample_copy=copy_list, details_state=self.details_state) + @web.expose + def toggle_request_details(self, trans, **kwd): + params = util.Params( kwd ) + msg = util.restore_text( params.get( 'msg', '' ) ) + messagetype = params.get( 'messagetype', 'done' ) + request = trans.app.model.Request.get(int(params.get('request_id', 0))) + if self.details_state == 'Show request details': + self.details_state = 'Hide request details' + elif self.details_state == 'Hide request details': + self.details_state = 'Show request details' + copy_list = SelectField('copy_sample') + copy_list.add_option('None', -1, selected=True) + for i, s in enumerate(self.current_samples): + copy_list.add_option(i+1, i) + return trans.fill_template( '/requests/show_request.mako', + request=request, + request_details=self.request_details(trans, request.id), + current_samples = self.current_samples, + sample_copy=copy_list, details_state=self.details_state) @web.expose def new(self, trans, **kwd): params = util.Params( kwd ) @@ -248,7 +299,7 @@ elif params.get('save', False) == 'True': request_type = trans.app.model.RequestType.get(int(params.request_type_id)) msg = self.__validate(trans, - [('name','Name'), ('library_id','Library')], + [('name','Name')], request_type.request_form.fields, **kwd) if msg: @@ -283,7 +334,7 @@ ''' params = util.Params( kwd ) for field, field_name in main_fields: - if not util.restore_text(params.get(field, None)): + if not util.restore_text(params.get(field, '')): return 'Please enter the <b>%s</b> of the request' % field_name # check rest of the fields of the form for index, field in enumerate(form_fields): @@ -303,7 +354,15 @@ pass name = util.restore_text(params.get('name', '')) desc = util.restore_text(params.get('desc', '')) - library_id = int(util.restore_text(params.get('library_id', 0))) + try: + library_id = int(util.restore_text(params.get('library_id', None))) + except: + msg = "Sequencing request could not be saved. Invalid library" + return trans.response.send_redirect( web.url_for( controller='requests', + action='list', + status='error', + message=msg, + **kwd) ) values = [] for index, field in enumerate(request_type.request_form.fields): values.append(util.restore_text(params.get('field_%i' % index, ''))) diff -r 4e0671e6eeaa -r 643e3cd86e0b lib/galaxy/web/controllers/requests_admin.py --- a/lib/galaxy/web/controllers/requests_admin.py Fri Jul 24 11:22:31 2009 -0400 +++ b/lib/galaxy/web/controllers/requests_admin.py Fri Jul 24 12:16:32 2009 -0400 @@ -92,10 +92,31 @@ self.current_samples = [] for s in request.samples: self.current_samples.append([s.name, s.values.content]) + self.details_state = 'Show request details' return trans.fill_template( '/admin/requests/show_request.mako', request=request, request_details=self.request_details(trans, id), - current_samples = self.current_samples) + current_samples = self.current_samples, + details_state=self.details_state) + @web.expose + def toggle_request_details(self, trans, **kwd): + params = util.Params( kwd ) + msg = util.restore_text( params.get( 'msg', '' ) ) + messagetype = params.get( 'messagetype', 'done' ) + request = trans.app.model.Request.get(int(params.get('request_id', 0))) + if self.details_state == 'Show request details': + self.details_state = 'Hide request details' + elif self.details_state == 'Hide request details': + self.details_state = 'Show request details' + copy_list = SelectField('copy_sample') + copy_list.add_option('None', -1, selected=True) + for i, s in enumerate(self.current_samples): + copy_list.add_option(i+1, i) + return trans.fill_template( '/admin/requests/show_request.mako', + request=request, + request_details=self.request_details(trans, request.id), + current_samples = self.current_samples, + sample_copy=copy_list, details_state=self.details_state) def request_details(self, trans, id): ''' Shows the request details diff -r 4e0671e6eeaa -r 643e3cd86e0b templates/admin/index.mako --- a/templates/admin/index.mako Fri Jul 24 11:22:31 2009 -0400 +++ b/templates/admin/index.mako Fri Jul 24 12:16:32 2009 -0400 @@ -114,7 +114,7 @@ </div> <div class="toolSectionPad"></div> <div class="toolSectionTitle"> - <span>Requests</span> + <span>Sequencing Requests</span> </div> <div class="toolSectionBody"> <div class="toolSectionBg"> diff -r 4e0671e6eeaa -r 643e3cd86e0b templates/admin/requests/grid.mako --- a/templates/admin/requests/grid.mako Fri Jul 24 11:22:31 2009 -0400 +++ b/templates/admin/requests/grid.mako Fri Jul 24 12:16:32 2009 -0400 @@ -76,9 +76,6 @@ <div class="grid-header"> <h2>${grid.title}</h2> - %if len(query.all()): - <h3>All Users</h3> - %endif ## %if len(query.all()): ## <span class="title">Filter:</span> ## %for i, filter in enumerate( grid.standard_filters ): diff -r 4e0671e6eeaa -r 643e3cd86e0b templates/admin/requests/show_request.mako --- a/templates/admin/requests/show_request.mako Fri Jul 24 11:22:31 2009 -0400 +++ b/templates/admin/requests/show_request.mako Fri Jul 24 12:16:32 2009 -0400 @@ -8,7 +8,7 @@ <div class="grid-header"> - <h2>Request: ${request.name}</h2> + <h2>Sequencing Request "${request.name}"</h2> </div> <ul class="manage-table-actions"> @@ -38,21 +38,26 @@ <div class="toolForm"> ##<div class="toolFormTitle">Request Details: '${request_details[0]['value']}'</div> - %for index, rd in enumerate(request_details): - <div class="form-row"> - <label>${rd['label']}</label> - %if not rd['value']: - <i>None</i> - %else: - %if rd['label'] == 'Library': - <a href="${h.url_for( controller='admin', action='browse_library', id=request.library.id )}">${rd['value']}</a> - %else: - ${rd['value']} + <div class="form-row"> + <a href="${h.url_for( controller='requests_admin', action='toggle_request_details', request_id=request.id )}">${details_state}</a> + </div> + %if details_state == "Hide request details": + %for index, rd in enumerate(request_details): + <div class="form-row"> + <label>${rd['label']}</label> + %if not rd['value']: + <i>None</i> + %else: + %if rd['label'] == 'Library': + <a href="${h.url_for( controller='admin', action='browse_library', id=request.library.id )}">${rd['value']}</a> + %else: + ${rd['value']} + %endif %endif - %endif - </div> - <div style="clear: both"></div> - %endfor + </div> + <div style="clear: both"></div> + %endfor + %endif </div> </div> diff -r 4e0671e6eeaa -r 643e3cd86e0b templates/admin/samples/bar_codes.mako --- a/templates/admin/samples/bar_codes.mako Fri Jul 24 11:22:31 2009 -0400 +++ b/templates/admin/samples/bar_codes.mako Fri Jul 24 12:16:32 2009 -0400 @@ -1,12 +1,19 @@ <%inherit file="/base.mako"/> <%namespace file="/message.mako" import="render_msg" /> -<h2>Bar codes for Samples of Request: ${request.name}</h2> +<h2>Bar codes for Samples of Request "${request.name}"</h2> <h3>User: ${user.email}</h3> %if msg: ${render_msg( msg, messagetype )} %endif + +<ul class="manage-table-actions"> + <li> + <a class="action-button" href="${h.url_for( controller='requests_admin', action='list', operation='show_request', id=trans.security.encode_id(request.id) )}"> + <span>Browse this request</span></a> + </li> +</ul> <div class="toolForm"> <form name="bar_codes" action="${h.url_for( controller='requests_admin', action='save_bar_codes', request_id=request.id)}" method="post" > diff -r 4e0671e6eeaa -r 643e3cd86e0b templates/admin/samples/events.mako --- a/templates/admin/samples/events.mako Fri Jul 24 11:22:31 2009 -0400 +++ b/templates/admin/samples/events.mako Fri Jul 24 12:16:32 2009 -0400 @@ -3,7 +3,13 @@ <%def name="title()">Events for Sample ${sample.name}</%def> -<h2>Events for Sample "${sample.name}" of Request: <a href="${h.url_for( controller='requests_admin', action='list', operation='show_request', id=trans.security.encode_id(sample.request.id))}">${sample.request.name}</a></h2> +<h2>Events for Sample "${sample.name}"</h2> +<ul class="manage-table-actions"> + <li> + <a class="action-button" href="${h.url_for( controller='requests_admin', action='list', operation='show_request', id=trans.security.encode_id(sample.request.id) )}"> + <span>Browse this request</span></a> + </li> +</ul> <h3>User: ${sample.request.user.email}</h3> %if msg: diff -r 4e0671e6eeaa -r 643e3cd86e0b templates/requests/new_request.mako --- a/templates/requests/new_request.mako Fri Jul 24 11:22:31 2009 -0400 +++ b/templates/requests/new_request.mako Fri Jul 24 12:16:32 2009 -0400 @@ -5,6 +5,14 @@ %if msg: ${render_msg( msg, messagetype )} %endif +<br/> +<br/> +<ul class="manage-table-actions"> + <li> + <a class="action-button" href="${h.url_for( controller='requests', action='list')}"> + <span>Browse requests</span></a> + </li> +</ul> <div class="toolForm"> <div class="toolFormTitle">${title}</div> diff -r 4e0671e6eeaa -r 643e3cd86e0b templates/requests/select_request_type.mako --- a/templates/requests/select_request_type.mako Fri Jul 24 11:22:31 2009 -0400 +++ b/templates/requests/select_request_type.mako Fri Jul 24 12:16:32 2009 -0400 @@ -5,7 +5,14 @@ %if msg: ${render_msg( msg, messagetype )} %endif - +<br/> +<br/> +<ul class="manage-table-actions"> + <li> + <a class="action-button" href="${h.url_for( controller='requests', action='list')}"> + <span>Browse requests</span></a> + </li> +</ul> <div class="toolForm"> <div class="toolFormTitle">Add a new request</div> diff -r 4e0671e6eeaa -r 643e3cd86e0b templates/requests/show_request.mako --- a/templates/requests/show_request.mako Fri Jul 24 11:22:31 2009 -0400 +++ b/templates/requests/show_request.mako Fri Jul 24 12:16:32 2009 -0400 @@ -8,17 +8,23 @@ <div class="grid-header"> - <h2>Request: ${request.name}</h2> + <h2>Sequencing Request "${request.name}"</h2> </div> -%if not request.submitted and request.samples: + <ul class="manage-table-actions"> + %if not request.submitted and request.samples: + <li> + <a class="action-button" confirm="More samples cannot be added to this request once it is submitted. Click OK to submit." href="${h.url_for( controller='requests', action='submit_request', id=request.id)}"> + <span>Submit request</span></a> + </li> + %endif <li> - <a class="action-button" confirm="More samples cannot be added to this request once it is submitted. Click OK to submit." href="${h.url_for( controller='requests', action='submit_request', id=request.id)}"> - <span>Submit request</span></a> + <a class="action-button" href="${h.url_for( controller='requests', action='list')}"> + <span>Browse requests</span></a> </li> </ul> -%endif + <%def name="render_sample_form( index, sample_name, sample_values )"> @@ -60,21 +66,26 @@ <div class="toolForm"> ##<div class="toolFormTitle">Request Details: '${request_details[0]['value']}'</div> - %for index, rd in enumerate(request_details): - <div class="form-row"> - <label>${rd['label']}</label> - %if not rd['value']: - <i>None</i> - %else: - %if rd['label'] == 'Library': - <a href="${h.url_for( controller='library', action='browse_library', id=request.library.id )}">${rd['value']}</a> - %else: - ${rd['value']} + <div class="form-row"> + <a href="${h.url_for( controller='requests', action='toggle_request_details', request_id=request.id )}">${details_state}</a> + </div> + %if details_state == "Hide request details": + %for index, rd in enumerate(request_details): + <div class="form-row"> + <label>${rd['label']}</label> + %if not rd['value']: + <i>None</i> + %else: + %if rd['label'] == 'Library': + <a href="${h.url_for( controller='library', action='browse_library', id=request.library.id )}">${rd['value']}</a> + %else: + ${rd['value']} + %endif %endif - %endif - </div> - <div style="clear: both"></div> - %endfor + </div> + <div style="clear: both"></div> + %endfor + %endif </div> </div> @@ -101,10 +112,13 @@ </tr> <thead> <tbody> + <% + request.refresh() + %> %for sample_index, sample in enumerate(current_samples): <tr> <td>${sample_index+1}</td> - %if sample[0] in [s.name for s in request.samples]: + %if sample_index in range(len(request.samples)): ${render_sample( sample_index, request.samples[sample_index] )} %else: ${render_sample_form( sample_index, sample[0], sample[1])} diff -r 4e0671e6eeaa -r 643e3cd86e0b templates/sample/sample_events.mako --- a/templates/sample/sample_events.mako Fri Jul 24 11:22:31 2009 -0400 +++ b/templates/sample/sample_events.mako Fri Jul 24 12:16:32 2009 -0400 @@ -3,7 +3,19 @@ <%def name="title()">Events for Sample ${sample_name}</%def> -<h2>Events for Sample "${sample_name}" of Request: <a href="${h.url_for( controller='requests', action='list', operation='show_request', id=trans.security.encode_id(request.id))}">${request.name}</a></h2> + +<h2>Events for Sample "${sample_name}"</h2> + +<ul class="manage-table-actions"> + <li> + <a class="action-button" href="${h.url_for( controller='requests', action='list', operation='show_request', id=trans.security.encode_id(request.id) )}"> + <span>Browse this request</span></a> + </li> + <li> + <a class="action-button" href="${h.url_for( controller='requests', action='list')}"> + <span>Browse requests</span></a> + </li> +</ul> %if msg: ${render_msg( msg, messagetype )}
participants (1)
-
Nate Coraor