[hg] galaxy 3595: lims: required fields of samples are now enfor...
details: http://www.bx.psu.edu/hg/galaxy/rev/0998e47bb63c changeset: 3595:0998e47bb63c user: rc date: Thu Apr 01 14:46:41 2010 -0400 description: lims: required fields of samples are now enforced before submission. (resolves issue #301) diffstat: lib/galaxy/web/controllers/requests.py | 33 +++++++++++++++++++++++---------- 1 files changed, 23 insertions(+), 10 deletions(-) diffs (50 lines): diff -r ab118eb3cfa6 -r 0998e47bb63c lib/galaxy/web/controllers/requests.py --- a/lib/galaxy/web/controllers/requests.py Thu Apr 01 14:27:13 2010 -0400 +++ b/lib/galaxy/web/controllers/requests.py Thu Apr 01 14:46:41 2010 -0400 @@ -726,8 +726,27 @@ msg = 'Fill the following fields of the request <b>%s</b> before submitting<br/>' % request.name for ef in empty_fields: msg = msg + '<b>' +ef + '</b><br/>' - return msg - return None + return trans.response.send_redirect( web.url_for( controller='requests', + action='list', + operation='edit', + messagetype = 'error', + msg=msg, + id=trans.security.encode_id(request.id) )) + # now check the required fields of all the samples of this request + for s in request.samples: + for index, field in enumerate(request.type.sample_form.fields): + if field['required'] == 'required' and s.values.content[index] in ['', None]: + empty_fields.append((s.name, field['label'])) + if empty_fields: + msg = 'Fill the following fields of the request <b>%s</b> before submitting<br/>' % request.name + for sname, ef in empty_fields: + msg = msg + '<b>%s</b> field of sample <b>%s</b><br/>' % (ef, sname) + return trans.response.send_redirect( web.url_for( controller='requests', + action='list', + operation='show_request', + messagetype = 'error', + msg=msg, + id=trans.security.encode_id(request.id) )) def __save_request(self, trans, request=None, **kwd): ''' This method saves a new request if request_id is None. @@ -948,14 +967,8 @@ status='error', message=msg, **kwd) ) - msg = self.__validate(trans, request) - if msg: - return trans.response.send_redirect( web.url_for( controller='requests', - action='list', - operation='edit', - messagetype = 'error', - msg=msg, - id=trans.security.encode_id(request.id) )) + # check if all the required request and its sample fields have been filled + self.__validate(trans, request) # change the request state to 'Submitted' comments = "Sequencing request is in progress." event = trans.app.model.RequestEvent(request, request.states.SUBMITTED, comments)
participants (1)
-
Greg Von Kuster