details: http://www.bx.psu.edu/hg/galaxy/rev/1d98e3705f35 changeset: 3543:1d98e3705f35 user: rc date: Wed Mar 17 17:10:24 2010 -0400 description: lims: added workflow field type to form_builder diffstat: lib/galaxy/model/__init__.py | 4 ++++ lib/galaxy/model/mapping.py | 4 +++- lib/galaxy/web/form_builder.py | 30 +++++++++++++++++++++++++++++- templates/admin/requests/show_request.mako | 10 ++++++++++ 4 files changed, 46 insertions(+), 2 deletions(-) diffs (95 lines): diff -r 032aae80bbb0 -r 1d98e3705f35 lib/galaxy/model/__init__.py --- a/lib/galaxy/model/__init__.py Wed Mar 17 16:40:36 2010 -0400 +++ b/lib/galaxy/model/__init__.py Wed Mar 17 17:10:24 2010 -0400 @@ -1319,6 +1319,10 @@ field_widget.user = user field_widget.value = value field_widget.params = params + elif field['type'] == 'WorkflowField': + field_widget.user = user + field_widget.value = value + field_widget.params = params elif field[ 'type' ] == 'SelectField': for option in field[ 'selectlist' ]: if option == value: diff -r 032aae80bbb0 -r 1d98e3705f35 lib/galaxy/model/mapping.py --- a/lib/galaxy/model/mapping.py Wed Mar 17 16:40:36 2010 -0400 +++ b/lib/galaxy/model/mapping.py Wed Mar 17 17:10:24 2010 -0400 @@ -1304,7 +1304,9 @@ assign_mapper( context, StoredWorkflow, StoredWorkflow.table, - properties=dict( user=relation( User ), + properties=dict( user=relation( User, + primaryjoin=( User.table.c.id == StoredWorkflow.table.c.user_id ), + backref='stored_workflows' ), workflows=relation( Workflow, backref='stored_workflow', cascade="all, delete-orphan", primaryjoin=( StoredWorkflow.table.c.id == Workflow.table.c.stored_workflow_id ) ), diff -r 032aae80bbb0 -r 1d98e3705f35 lib/galaxy/web/form_builder.py --- a/lib/galaxy/web/form_builder.py Wed Mar 17 16:40:36 2010 -0400 +++ b/lib/galaxy/web/form_builder.py Wed Mar 17 17:10:24 2010 -0400 @@ -12,7 +12,7 @@ raise TypeError( "Abstract Method" ) @staticmethod def form_field_types(): - return ['TextField', 'TextArea', 'SelectField', 'CheckboxField', 'AddressField'] + return ['TextField', 'TextArea', 'SelectField', 'CheckboxField', 'AddressField', 'WorkflowField'] class TextField(BaseField): """ @@ -433,6 +433,34 @@ else: self.select_address.add_option('Add a new address', 'new') return self.select_address.get_html()+address_html + + +class WorkflowField(BaseField): + def __init__(self, name, user=None, value=None, params=None): + self.name = name + self.user = user + self.value = value + self.select_workflow = None + self.params = params + def get_html(self): + from galaxy import util + add_ids = ['none'] + if self.user: + for a in self.user.stored_workflows: + add_ids.append(str(a.id)) + self.select_workflow = SelectField(self.name) + if self.value == 'none': + self.select_workflow.add_option('Select one', 'none', selected=True) + else: + self.select_workflow.add_option('Select one', 'none') + if self.user: + for a in self.user.stored_workflows: + if not a.deleted: + if self.value == str(a.id): + self.select_workflow.add_option(a.name, str(a.id), selected=True) + else: + self.select_workflow.add_option(a.name, str(a.id)) + return self.select_workflow.get_html() def get_suite(): diff -r 032aae80bbb0 -r 1d98e3705f35 templates/admin/requests/show_request.mako --- a/templates/admin/requests/show_request.mako Wed Mar 17 16:40:36 2010 -0400 +++ b/templates/admin/requests/show_request.mako Wed Mar 17 17:10:24 2010 -0400 @@ -284,6 +284,16 @@ %endif %endfor </select> + %elif field['type'] == 'WorkflowField': + <select name="sample_${index}_field_${field_index}"> + %for option_index, option in enumerate(request.user.stored_workflows): + %if option == sample_values[field_index]: + <option value="${option.id}" selected>${option.name}</option> + %else: + <option value="${option.id}">${option.name}</option> + %endif + %endfor + </select> %elif field['type'] == 'CheckboxField': <input type="checkbox" name="sample_${index}_field_${field_index}" value="Yes"/> %endif