galaxy-dev
Threads by month
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
November 2009
- 26 participants
- 233 discussions
23 Nov '09
details: http://www.bx.psu.edu/hg/galaxy/rev/6b3f453078c4
changeset: 3052:6b3f453078c4
user: Enis Afgan <afgane(a)gmail.com>
date: Mon Aug 24 17:46:22 2009 -0400
description:
Added ability to select default credentials.
diffstat:
eggs.ini | 2 +
lib/galaxy/model/mapping.py | 3 +-
lib/galaxy/model/migrate/versions/0014_credentials_table.py | 3 +-
lib/galaxy/web/controllers/cloud.py | 75 +++++++++++-------
templates/cloud/configure_cloud.mako | 20 ++++-
5 files changed, 68 insertions(+), 35 deletions(-)
diffs (236 lines):
diff -r a83d7220136f -r 6b3f453078c4 eggs.ini
--- a/eggs.ini Mon Aug 24 12:19:57 2009 -0400
+++ b/eggs.ini Mon Aug 24 17:46:22 2009 -0400
@@ -51,6 +51,7 @@
wsgiref = 0.1.2
Babel = 0.9.4
wchartype = 0.1
+boto = 1.8d
; extra version information
[tags]
@@ -100,3 +101,4 @@
wsgiref = http://pypi.python.org/packages/source/w/wsgiref/wsgiref-0.1.2.zip
Babel = http://ftp.edgewall.com/pub/babel/Babel-0.9.4.zip
wchartype = http://ginstrom.com/code/wchartype-0.1.zip
+boto = http://boto.googlecode.com/files/boto-1.8d.tar.gz
\ No newline at end of file
diff -r a83d7220136f -r 6b3f453078c4 lib/galaxy/model/mapping.py
--- a/lib/galaxy/model/mapping.py Mon Aug 24 12:19:57 2009 -0400
+++ b/lib/galaxy/model/mapping.py Mon Aug 24 17:46:22 2009 -0400
@@ -386,7 +386,8 @@
Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), index=True, nullable=False ),
Column( "name", TEXT),
Column( "access_key", TEXT),
- Column( "secret_key", TEXT)
+ Column( "secret_key", TEXT),
+ Column( "defaultCred", Boolean, default=False)
)
StoredWorkflow.table = Table( "stored_workflow", metadata,
diff -r a83d7220136f -r 6b3f453078c4 lib/galaxy/model/migrate/versions/0014_credentials_table.py
--- a/lib/galaxy/model/migrate/versions/0014_credentials_table.py Mon Aug 24 12:19:57 2009 -0400
+++ b/lib/galaxy/model/migrate/versions/0014_credentials_table.py Mon Aug 24 17:46:22 2009 -0400
@@ -19,7 +19,8 @@
Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), index=True, nullable=False ),
Column( "name", TEXT),
Column( "access_key", TEXT),
- Column( "secret_key", TEXT) )
+ Column( "secret_key", TEXT),
+ Column( "defaultCred", Boolean, default=False ) )
def upgrade():
metadata.reflect()
diff -r a83d7220136f -r 6b3f453078c4 lib/galaxy/web/controllers/cloud.py
--- a/lib/galaxy/web/controllers/cloud.py Mon Aug 24 12:19:57 2009 -0400
+++ b/lib/galaxy/web/controllers/cloud.py Mon Aug 24 17:46:22 2009 -0400
@@ -15,7 +15,11 @@
from galaxy.model.mapping import desc
from galaxy.model.orm import *
+# Required for Cloud tab
+import galaxy.eggs
+galaxy.eggs.require("boto")
from boto.ec2.connection import EC2Connection
+
import logging
log = logging.getLogger( __name__ )
@@ -32,34 +36,32 @@
Render cloud main page (management of cloud resources)
"""
user = trans.get_user()
- #awsCredentials = 0
awsCredentials = trans.sa_session.query ( model.StoredUserCredentials ) \
.order_by( desc( model.StoredUserCredentials.c.update_time ) ) \
.all()
- log.debug( "in list" )
- log.debug( awsCredentials )
-
- workflows = trans.sa_session.query( model.StoredWorkflow ) \
- .filter_by( user=user, deleted=False ) \
- .order_by( desc( model.StoredWorkflow.c.update_time ) ) \
- .all()
- return trans.fill_template( "cloud/configure_cloud.mako",
- awsCredentials = awsCredentials,
- workflows = workflows )
-
- @web.expose
- @web.require_login( "use Galaxy cloud" )
- def makeDefault( self, trans ):
- """
- Set current credentials as default to be used for submitting jobs
- TODO: Implement, this is only a dummy method.
- """
- awsCredentials = trans.sa_session.query ( model.StoredUserCredentials ).all()
return trans.fill_template( "cloud/configure_cloud.mako",
awsCredentials = awsCredentials )
@web.expose
+ @web.require_login( "use Galaxy cloud" )
+ def makeDefault( self, trans, id=None ):
+ """
+ Set current credentials as default to be used for acquiring cloud resources.
+ """
+ currentDefault = get_defalt_credentials (trans)
+ if currentDefault:
+ currentDefault.defaultCred = False
+
+ newDefault = get_stored_credentials( trans, id )
+ newDefault.defaultCred = True
+ trans.sa_session.flush()
+ trans.set_message( "Credentials '%s' set as default." % newDefault.name )
+
+ return self.list( trans ) #trans.fill_template( "cloud/configure_cloud.mako",
+ #awsCredentials = awsCredentials )
+
+ @web.expose
@web.require_login( "use Galaxy workflows" )
def list_for_run( self, trans ):
"""
@@ -176,10 +178,9 @@
@web.expose
@web.require_login( "add credentials" )
- def add( self, trans, credName='', accessKey='', secretKey='', default=False ):
+ def add( self, trans, credName='', accessKey='', secretKey='', defaultCred=False ):
"""
Add user's AWS credentials stored under name `credName`.
- TODO: Make use of 'default' credential selection
"""
user = trans.get_user()
cred_error = accessKey_error = secretKey_error = None
@@ -203,18 +204,15 @@
# Log and display the management page
trans.log_event( "User added new credentials" )
trans.set_message( "Credential '%s' created" % credentials.name )
- if default:
- mail = os.popen("%s -t" % trans.app.config.sendmail_path, 'w')
- mail.write("To: %s\nFrom: %s\nSubject: Join Mailing List\n\nJoin Mailing list." % (trans.app.config.mailing_join_addr,email) )
- if mail.close():
- return trans.show_warn_message( "Now logged in as " + user.email+". However, subscribing to the mailing list has failed.", refresh_frames=refresh_frames )
+ if defaultCred:
+ self.makeDefault( trans, credentials.id)
return self.list( trans )
return trans.show_form(
web.FormBuilder( web.url_for(), "Add credentials", submit_text="Add" )
.add_text( "credName", "Credentials name", value="Unnamed credentials", error=cred_error )
.add_text( "accessKey", "Access key", value='', error=accessKey_error )
.add_password( "secretKey", "Secret key", value='', error=secretKey_error )
- .add_input( "checkbox","Make default credentials","default", value='default' ) )
+ .add_input( "checkbox","Make default credentials","defaultCred", value='defaultCred' ) )
@web.expose
@web.require_login( "view credentials" )
@@ -232,7 +230,7 @@
@web.require_login( "delete credentials" )
def delete( self, trans, id=None ):
"""
- Delete credentials
+ Delete user's cloud credentials
"""
# Load credentials from database
stored = get_stored_credentials( trans, id )
@@ -690,8 +688,11 @@
"""
Get a StoredUserCredntials from the database by id, verifying ownership.
"""
- # Load credentials from database
- id = trans.security.decode_id( id )
+ # Check if 'id' is in int (i.e., it was called from this program) or
+ # it was passed from the web (in which case decode it)
+ if not isinstance( id, int ):
+ id = trans.security.decode_id( id )
+
stored = trans.sa_session.query( model.StoredUserCredentials ).get( id )
if not stored:
error( "Credentials not found" )
@@ -704,6 +705,18 @@
# Looks good
return stored
+def get_defalt_credentials( trans, check_ownership=True ):
+ """
+ Get a StoredUserCredntials from the database by 'default' setting, verifying ownership.
+ """
+ user = trans.get_user()
+ # Load credentials from database
+ stored = trans.sa_session.query( model.StoredUserCredentials ) \
+ .filter_by (user=user, defaultCred=True) \
+ .first()
+
+ return stored
+
def attach_ordered_steps( workflow, steps ):
ordered_steps = order_workflow_steps( steps )
if ordered_steps:
diff -r a83d7220136f -r 6b3f453078c4 templates/cloud/configure_cloud.mako
--- a/templates/cloud/configure_cloud.mako Mon Aug 24 12:19:57 2009 -0400
+++ b/templates/cloud/configure_cloud.mako Mon Aug 24 17:46:22 2009 -0400
@@ -9,6 +9,9 @@
except:
messagetype = "done"
%>
+
+
+
<p />
<div class="${messagetype}message">
${message}
@@ -31,7 +34,6 @@
<tr class="header">
<th>Credentials Name</th>
<th>Default</th>
- ## <th>Last Updated</th>
<th></th>
</tr>
%for i, awsCredential in enumerate( awsCredentials ):
@@ -41,8 +43,17 @@
<a id="wf-${i}-popup" class="popup-arrow" style="display: none;">▼</a>
</td>
## Comment <td>${len(workflow.latest_workflow.steps)}</td>
- ##<td>${str(awsCredentials.update_time)[:19]}</td>
+ ##<td>${str(awsCredential.update_time)[:19]}</td>
<td>
+ ${str(awsCredential.defaultCred)}
+ <%
+ c=str(awsCredential.defaultCred)
+ %>
+
+ ##${dflt(cred=c)}
+ </td>
+
+ <td>
<div popupmenu="wf-${i}-popup">
<a class="action-button" href="${h.url_for( action='view', id=trans.security.encode_id(awsCredential.id) )}">View</a>
<a class="action-button" href="${h.url_for( action='rename', id=trans.security.encode_id(awsCredential.id) )}">Rename</a>
@@ -65,3 +76,8 @@
%endif
+<%def name="dflt(cred)">
+ %if cred:
+ default
+ %endif
+</%def>
1
0
23 Nov '09
details: http://www.bx.psu.edu/hg/galaxy/rev/b46effa7b459
changeset: 3047:b46effa7b459
user: afgane(a)dhcp243061.rollins.emory.edu
date: Thu Aug 20 11:01:57 2009 -0400
description:
Added Cloud tab to main page with associated pages.
diffstat:
templates/base_panels.mako | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diffs (12 lines):
diff -r 5fa8803716fd -r b46effa7b459 templates/base_panels.mako
--- a/templates/base_panels.mako Wed Aug 19 18:07:55 2009 -0400
+++ b/templates/base_panels.mako Thu Aug 20 11:01:57 2009 -0400
@@ -141,6 +141,8 @@
${tab( "libraries", "Data Libraries", h.url_for( controller='library', action='index' ))}
+ ${tab( "cloud", "Cloud", h.url_for( controller='cloud', action='index' ))}
+
%if trans.request_types():
<td class="tab">
<a>Lab</a>
1
0
23 Nov '09
details: http://www.bx.psu.edu/hg/galaxy/rev/7d19363e6e0d
changeset: 3048:7d19363e6e0d
user: "Enis Afgan <afgane(a)gmail.com>"
date: Thu Aug 20 11:27:30 2009 -0400
description:
Added files associated with previous commit.
diffstat:
lib/galaxy/web/controllers/cloud.py | 844 ++++++++++++++++++++++++++++++++++++++++
templates/cloud/configure_cloud.mako | 61 ++
templates/cloud/index.mako | 16 +
3 files changed, 921 insertions(+), 0 deletions(-)
diffs (934 lines):
diff -r b46effa7b459 -r 7d19363e6e0d lib/galaxy/web/controllers/cloud.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/galaxy/web/controllers/cloud.py Thu Aug 20 11:27:30 2009 -0400
@@ -0,0 +1,844 @@
+from galaxy.web.base.controller import *
+
+import pkg_resources
+pkg_resources.require( "simplejson" )
+import simplejson
+
+from galaxy.tools.parameters import *
+from galaxy.tools import DefaultToolState
+from galaxy.tools.parameters.grouping import Repeat, Conditional
+from galaxy.datatypes.data import Data
+from galaxy.util.odict import odict
+from galaxy.util.bunch import Bunch
+from galaxy.util.topsort import topsort, topsort_levels, CycleError
+from galaxy.workflow.modules import *
+from galaxy.model.mapping import desc
+from galaxy.model.orm import *
+
+class CloudController( BaseController ):
+
+ @web.expose
+ def index( self, trans ):
+ return trans.fill_template( "cloud/index.mako" )
+
+ @web.expose
+ @web.require_login( "use Galaxy cloud" )
+ def list( self, trans ):
+ """
+ Render cloud main page (management of cloud resources)
+ """
+ user = trans.get_user()
+ workflows = trans.sa_session.query( model.StoredWorkflow ) \
+ .filter_by( user=user, deleted=False ) \
+ .order_by( desc( model.StoredWorkflow.c.update_time ) ) \
+ .all()
+ shared_by_others = trans.sa_session \
+ .query( model.StoredWorkflowUserShareAssociation ) \
+ .filter_by( user=user ) \
+ .join( 'stored_workflow' ) \
+ .filter( model.StoredWorkflow.deleted == False ) \
+ .order_by( desc( model.StoredWorkflow.update_time ) ) \
+ .all()
+ return trans.fill_template( "cloud/configure_cloud.mako",
+ workflows = workflows,
+ shared_by_others = shared_by_others )
+
+ @web.expose
+ @web.require_login( "use Galaxy workflows" )
+ def list_for_run( self, trans ):
+ """
+ Render workflow list for analysis view (just allows running workflow
+ or switching to management view)
+ """
+ user = trans.get_user()
+ workflows = trans.sa_session.query( model.StoredWorkflow ) \
+ .filter_by( user=user, deleted=False ) \
+ .order_by( desc( model.StoredWorkflow.c.update_time ) ) \
+ .all()
+ shared_by_others = trans.sa_session \
+ .query( model.StoredWorkflowUserShareAssociation ) \
+ .filter_by( user=user ) \
+ .filter( model.StoredWorkflow.c.deleted == False ) \
+ .order_by( desc( model.StoredWorkflow.c.update_time ) ) \
+ .all()
+ return trans.fill_template( "workflow/list_for_run.mako",
+ workflows = workflows,
+ shared_by_others = shared_by_others )
+
+ @web.expose
+ @web.require_login( "use Galaxy workflows" )
+ def share( self, trans, id, email="" ):
+ msg = mtype = None
+ # Load workflow from database
+ stored = get_stored_workflow( trans, id )
+ if email:
+ other = model.User.filter( and_( model.User.table.c.email==email,
+ model.User.table.c.deleted==False ) ).first()
+ if not other:
+ mtype = "error"
+ msg = ( "User '%s' does not exist" % email )
+ elif other == trans.get_user():
+ mtype = "error"
+ msg = ( "You cannot share a workflow with yourself" )
+ elif trans.sa_session.query( model.StoredWorkflowUserShareAssociation ) \
+ .filter_by( user=other, stored_workflow=stored ).count() > 0:
+ mtype = "error"
+ msg = ( "Workflow already shared with '%s'" % email )
+ else:
+ share = model.StoredWorkflowUserShareAssociation()
+ share.stored_workflow = stored
+ share.user = other
+ session = trans.sa_session
+ session.save_or_update( share )
+ session.flush()
+ trans.set_message( "Workflow '%s' shared with user '%s'" % ( stored.name, other.email ) )
+ return trans.response.send_redirect( url_for( controller='workflow', action='sharing', id=id ) )
+ return trans.fill_template( "workflow/share.mako",
+ message = msg,
+ messagetype = mtype,
+ stored=stored,
+ email=email )
+
+ @web.expose
+ @web.require_login( "use Galaxy workflows" )
+ def sharing( self, trans, id, **kwargs ):
+ session = trans.sa_session
+ stored = get_stored_workflow( trans, id )
+ if 'enable_import_via_link' in kwargs:
+ stored.importable = True
+ stored.flush()
+ elif 'disable_import_via_link' in kwargs:
+ stored.importable = False
+ stored.flush()
+ elif 'unshare_user' in kwargs:
+ user = session.query( model.User ).get( trans.security.decode_id( kwargs['unshare_user' ] ) )
+ if not user:
+ error( "User not found for provided id" )
+ association = session.query( model.StoredWorkflowUserShareAssociation ) \
+ .filter_by( user=user, stored_workflow=stored ).one()
+ session.delete( association )
+ session.flush()
+ return trans.fill_template( "workflow/sharing.mako",
+ stored=stored )
+
+ @web.expose
+ @web.require_login( "use Galaxy workflows" )
+ def imp( self, trans, id, **kwargs ):
+ session = trans.sa_session
+ stored = get_stored_workflow( trans, id, check_ownership=False )
+ if stored.importable == False:
+ error( "The owner of this workflow has disabled imports via this link" )
+ elif stored.user == trans.user:
+ error( "You are already the owner of this workflow, can't import" )
+ elif stored.deleted:
+ error( "This workflow has been deleted, can't import" )
+ elif session.query( model.StoredWorkflowUserShareAssociation ) \
+ .filter_by( user=trans.user, stored_workflow=stored ).count() > 0:
+ error( "This workflow is already shared with you" )
+ else:
+ share = model.StoredWorkflowUserShareAssociation()
+ share.stored_workflow = stored
+ share.user = trans.user
+ session = trans.sa_session
+ session.save_or_update( share )
+ session.flush()
+ # Redirect to load galaxy frames.
+ return trans.response.send_redirect( url_for( controller='workflow' ) )
+
+ @web.expose
+ @web.require_login( "use Galaxy workflows" )
+ def rename( self, trans, id, new_name=None ):
+ stored = get_stored_workflow( trans, id )
+ if new_name is not None:
+ stored.name = new_name
+ trans.sa_session.flush()
+ trans.set_message( "Workflow renamed to '%s'." % new_name )
+ return self.list( trans )
+ else:
+ return form( url_for( id=trans.security.encode_id(stored.id) ), "Rename workflow", submit_text="Rename" ) \
+ .add_text( "new_name", "Workflow Name", value=stored.name )
+
+ @web.expose
+ @web.require_login( "use Galaxy workflows" )
+ def clone( self, trans, id ):
+ stored = get_stored_workflow( trans, id, check_ownership=False )
+ user = trans.get_user()
+ if stored.user == user:
+ owner = True
+ else:
+ if trans.sa_session.query( model.StoredWorkflowUserShareAssociation ) \
+ .filter_by( user=user, stored_workflow=stored ).count() == 0:
+ error( "Workflow is not owned by or shared with current user" )
+ owner = False
+ new_stored = model.StoredWorkflow()
+ new_stored.name = "Clone of '%s'" % stored.name
+ new_stored.latest_workflow = stored.latest_workflow
+ if not owner:
+ new_stored.name += " shared by '%s'" % stored.user.email
+ new_stored.user = user
+ # Persist
+ session = trans.sa_session
+ session.save_or_update( new_stored )
+ session.flush()
+ # Display the management page
+ trans.set_message( 'Clone created with name "%s"' % new_stored.name )
+ return self.list( trans )
+
+ @web.expose
+ @web.require_login( "create workflows" )
+ def create( self, trans, workflow_name=None ):
+ """
+ Create a new stored workflow with name `workflow_name`.
+ """
+ user = trans.get_user()
+ if workflow_name is not None:
+ # Create the new stored workflow
+ stored_workflow = model.StoredWorkflow()
+ stored_workflow.name = workflow_name
+ stored_workflow.user = user
+ # And the first (empty) workflow revision
+ workflow = model.Workflow()
+ workflow.name = workflow_name
+ workflow.stored_workflow = stored_workflow
+ stored_workflow.latest_workflow = workflow
+ # Persist
+ session = trans.sa_session
+ session.save_or_update( stored_workflow )
+ session.flush()
+ # Display the management page
+ trans.set_message( "Workflow '%s' created" % stored_workflow.name )
+ return self.list( trans )
+ else:
+ return form( url_for(), "Create new workflow", submit_text="Create" ) \
+ .add_text( "workflow_name", "Workflow Name", value="Unnamed cloud" )
+
+ @web.expose
+ @web.require_login( "add AWS credentials" )
+ def add( self, trans, account_name=None ):
+ """
+ Add user's AWS credentials stored under name `account_name`.
+ """
+ user = trans.get_user()
+ if account_name is not None:
+ """
+ # Create the new stored workflow
+ stored_workflow = model.StoredWorkflow()
+ stored_workflow.name = workflow_name
+ stored_workflow.user = user
+ # And the first (empty) workflow revision
+ workflow = model.Workflow()
+ workflow.name = workflow_name
+ workflow.stored_workflow = stored_workflow
+ stored_workflow.latest_workflow = workflow
+ # Persist
+ session = trans.sa_session
+ session.save_or_update( stored_workflow )
+ session.flush()
+ # Display the management page
+ trans.set_message( "Workflow '%s' created" % stored_workflow.name )
+ return self.list( trans )
+ """
+ else:
+ return form( url_for(), "Add AWS credentials", submit_text="Add" ) \
+ .add_text( "account_name", "Account Name", value="Unnamed credentials" )
+
+ @web.expose
+ def delete( self, trans, id=None ):
+ """
+ Mark a workflow as deleted
+ """
+ # Load workflow from database
+ stored = get_stored_workflow( trans, id )
+ # Marke as deleted and save
+ stored.deleted = True
+ stored.flush()
+ # Display the management page
+ trans.set_message( "Workflow '%s' deleted" % stored.name )
+ return self.list( trans )
+
+ @web.expose
+ @web.require_login( "edit workflows" )
+ def editor( self, trans, id=None ):
+ """
+ Render the main workflow editor interface. The canvas is embedded as
+ an iframe (neccesary for scrolling to work properly), which is
+ rendered by `editor_canvas`.
+ """
+ if not id:
+ error( "Invalid workflow id" )
+ id = trans.security.decode_id( id )
+ return trans.fill_template( "workflow/editor.mako", workflow_id=id )
+
+ @web.json
+ def editor_form_post( self, trans, type='tool', tool_id=None, **incoming ):
+ """
+ Accepts a tool state and incoming values, and generates a new tool
+ form and some additional information, packed into a json dictionary.
+ This is used for the form shown in the right pane when a node
+ is selected.
+ """
+ trans.workflow_building_mode = True
+ module = module_factory.from_dict( trans, {
+ 'type': type,
+ 'tool_id': tool_id,
+ 'tool_state': incoming.pop("tool_state")
+ } )
+ module.update_state( incoming )
+ return {
+ 'tool_state': module.get_state(),
+ 'data_inputs': module.get_data_inputs(),
+ 'data_outputs': module.get_data_outputs(),
+ 'tool_errors': module.get_errors(),
+ 'form_html': module.get_config_form()
+ }
+
+ @web.json
+ def get_new_module_info( self, trans, type, **kwargs ):
+ """
+ Get the info for a new instance of a module initialized with default
+ paramters (any keyword arguments will be passed along to the module).
+ Result includes data inputs and outputs, html representation
+ of the initial form, and the initial tool state (with default values).
+ This is called asynchronously whenever a new node is added.
+ """
+ trans.workflow_building_mode = True
+ module = module_factory.new( trans, type, **kwargs )
+ return {
+ 'type': module.type,
+ 'name': module.get_name(),
+ 'tool_id': module.get_tool_id(),
+ 'tool_state': module.get_state(),
+ 'data_inputs': module.get_data_inputs(),
+ 'data_outputs': module.get_data_outputs(),
+ 'form_html': module.get_config_form()
+ }
+
+ @web.json
+ def load_workflow( self, trans, id ):
+ """
+ Get the latest Workflow for the StoredWorkflow identified by `id` and
+ encode it as a json string that can be read by the workflow editor
+ web interface.
+ """
+ user = trans.get_user()
+ id = trans.security.decode_id( id )
+ trans.workflow_building_mode = True
+ # Load encoded workflow from database
+ stored = trans.sa_session.query( model.StoredWorkflow ).get( id )
+ assert stored.user == user
+ workflow = stored.latest_workflow
+ # Pack workflow data into a dictionary and return
+ data = {}
+ data['name'] = workflow.name
+ data['steps'] = {}
+ data['upgrade_messages'] = {}
+ # For each step, rebuild the form and encode the state
+ for step in workflow.steps:
+ # Load from database representation
+ module = module_factory.from_workflow_step( trans, step )
+ # Fix any missing parameters
+ upgrade_message = module.check_and_update_state()
+ if upgrade_message:
+ data['upgrade_messages'][step.order_index] = upgrade_message
+ # Pack atrributes into plain dictionary
+ step_dict = {
+ 'id': step.order_index,
+ 'type': module.type,
+ 'tool_id': module.get_tool_id(),
+ 'name': module.get_name(),
+ 'tool_state': module.get_state(),
+ 'tool_errors': module.get_errors(),
+ 'data_inputs': module.get_data_inputs(),
+ 'data_outputs': module.get_data_outputs(),
+ 'form_html': module.get_config_form(),
+ }
+ # Connections
+ input_conn_dict = {}
+ for conn in step.input_connections:
+ input_conn_dict[ conn.input_name ] = \
+ dict( id=conn.output_step.order_index, output_name=conn.output_name )
+ step_dict['input_connections'] = input_conn_dict
+ # Position
+ step_dict['position'] = step.position
+ # Add to return value
+ data['steps'][step.order_index] = step_dict
+ print data['upgrade_messages']
+ return data
+
+ @web.json
+ def save_workflow( self, trans, id, workflow_data ):
+ """
+ Save the workflow described by `workflow_data` with id `id`.
+ """
+ # Get the stored workflow
+ stored = get_stored_workflow( trans, id )
+ # Put parameters in workflow mode
+ trans.workflow_building_mode = True
+ # Convert incoming workflow data from json
+ data = simplejson.loads( workflow_data )
+ # Create new workflow from incoming data
+ workflow = model.Workflow()
+ # Just keep the last name (user can rename later)
+ workflow.name = stored.name
+ # Assume no errors until we find a step that has some
+ workflow.has_errors = False
+ # Create each step
+ steps = []
+ # The editor will provide ids for each step that we don't need to save,
+ # but do need to use to make connections
+ steps_by_external_id = {}
+ # First pass to build step objects and populate basic values
+ for key, step_dict in data['steps'].iteritems():
+ # Create the model class for the step
+ step = model.WorkflowStep()
+ steps.append( step )
+ steps_by_external_id[ step_dict['id' ] ] = step
+ # FIXME: Position should be handled inside module
+ step.position = step_dict['position']
+ module = module_factory.from_dict( trans, step_dict )
+ module.save_to_step( step )
+ if step.tool_errors:
+ workflow.has_errors = True
+ # Stick this in the step temporarily
+ step.temp_input_connections = step_dict['input_connections']
+ # Second pass to deal with connections between steps
+ for step in steps:
+ # Input connections
+ for input_name, conn_dict in step.temp_input_connections.iteritems():
+ if conn_dict:
+ conn = model.WorkflowStepConnection()
+ conn.input_step = step
+ conn.input_name = input_name
+ conn.output_name = conn_dict['output_name']
+ conn.output_step = steps_by_external_id[ conn_dict['id'] ]
+ del step.temp_input_connections
+ # Order the steps if possible
+ attach_ordered_steps( workflow, steps )
+ # Connect up
+ workflow.stored_workflow = stored
+ stored.latest_workflow = workflow
+ # Persist
+ trans.sa_session.flush()
+ # Return something informative
+ errors = []
+ if workflow.has_errors:
+ errors.append( "Some steps in this workflow have validation errors" )
+ if workflow.has_cycles:
+ errors.append( "This workflow contains cycles" )
+ if errors:
+ rval = dict( message="Workflow saved, but will not be runnable due to the following errors",
+ errors=errors )
+ else:
+ rval = dict( message="Workflow saved" )
+ rval['name'] = workflow.name
+ return rval
+
+ @web.json
+ def get_datatypes( self, trans ):
+ ext_to_class_name = dict()
+ classes = []
+ for k, v in trans.app.datatypes_registry.datatypes_by_extension.iteritems():
+ c = v.__class__
+ ext_to_class_name[k] = c.__module__ + "." + c.__name__
+ classes.append( c )
+ class_to_classes = dict()
+ def visit_bases( types, cls ):
+ for base in cls.__bases__:
+ if issubclass( base, Data ):
+ types.add( base.__module__ + "." + base.__name__ )
+ visit_bases( types, base )
+ for c in classes:
+ n = c.__module__ + "." + c.__name__
+ types = set( [ n ] )
+ visit_bases( types, c )
+ class_to_classes[ n ] = dict( ( t, True ) for t in types )
+ return dict( ext_to_class_name=ext_to_class_name, class_to_classes=class_to_classes )
+
+ @web.expose
+ def build_from_current_history( self, trans, job_ids=None, dataset_ids=None, workflow_name=None ):
+ user = trans.get_user()
+ history = trans.get_history()
+ if not user:
+ return trans.show_error_message( "Must be logged in to create workflows" )
+ if ( job_ids is None and dataset_ids is None ) or workflow_name is None:
+ jobs, warnings = get_job_dict( trans )
+ # Render
+ return trans.fill_template(
+ "workflow/build_from_current_history.mako",
+ jobs=jobs,
+ warnings=warnings,
+ history=history )
+ else:
+ # Ensure job_ids and dataset_ids are lists (possibly empty)
+ if job_ids is None:
+ job_ids = []
+ elif type( job_ids ) is not list:
+ job_ids = [ job_ids ]
+ if dataset_ids is None:
+ dataset_ids = []
+ elif type( dataset_ids ) is not list:
+ dataset_ids = [ dataset_ids ]
+ # Convert both sets of ids to integers
+ job_ids = [ int( id ) for id in job_ids ]
+ dataset_ids = [ int( id ) for id in dataset_ids ]
+ # Find each job, for security we (implicately) check that they are
+ # associated witha job in the current history.
+ jobs, warnings = get_job_dict( trans )
+ jobs_by_id = dict( ( job.id, job ) for job in jobs.keys() )
+ steps = []
+ steps_by_job_id = {}
+ hid_to_output_pair = {}
+ # Input dataset steps
+ for hid in dataset_ids:
+ step = model.WorkflowStep()
+ step.type = 'data_input'
+ hid_to_output_pair[ hid ] = ( step, 'output' )
+ steps.append( step )
+ # Tool steps
+ for job_id in job_ids:
+ assert job_id in jobs_by_id, "Attempt to create workflow with job not connected to current history"
+ job = jobs_by_id[ job_id ]
+ tool = trans.app.toolbox.tools_by_id[ job.tool_id ]
+ param_values = job.get_param_values( trans.app )
+ associations = cleanup_param_values( tool.inputs, param_values )
+ step = model.WorkflowStep()
+ step.type = 'tool'
+ step.tool_id = job.tool_id
+ step.tool_inputs = tool.params_to_strings( param_values, trans.app )
+ # NOTE: We shouldn't need to do two passes here since only
+ # an earlier job can be used as an input to a later
+ # job.
+ for other_hid, input_name in associations:
+ if other_hid in hid_to_output_pair:
+ other_step, other_name = hid_to_output_pair[ other_hid ]
+ conn = model.WorkflowStepConnection()
+ conn.input_step = step
+ conn.input_name = input_name
+ # Should always be connected to an earlier step
+ conn.output_step = other_step
+ conn.output_name = other_name
+ steps.append( step )
+ steps_by_job_id[ job_id ] = step
+ # Store created dataset hids
+ for assoc in job.output_datasets:
+ hid_to_output_pair[ assoc.dataset.hid ] = ( step, assoc.name )
+ # Workflow to populate
+ workflow = model.Workflow()
+ workflow.name = workflow_name
+ # Order the steps if possible
+ attach_ordered_steps( workflow, steps )
+ # And let's try to set up some reasonable locations on the canvas
+ # (these are pretty arbitrary values)
+ levorder = order_workflow_steps_with_levels( steps )
+ base_pos = 10
+ for i, steps_at_level in enumerate( levorder ):
+ for j, index in enumerate( steps_at_level ):
+ step = steps[ index ]
+ step.position = dict( top = ( base_pos + 120 * j ),
+ left = ( base_pos + 220 * i ) )
+ # Store it
+ stored = model.StoredWorkflow()
+ stored.user = user
+ stored.name = workflow_name
+ workflow.stored_workflow = stored
+ stored.latest_workflow = workflow
+ trans.sa_session.save_or_update( stored )
+ trans.sa_session.flush()
+ # Index page with message
+ return trans.show_message( "Workflow '%s' created from current history." % workflow_name )
+ ## return trans.show_ok_message( "<p>Workflow '%s' created.</p><p><a target='_top' href='%s'>Click to load in workflow editor</a></p>"
+ ## % ( workflow_name, web.url_for( action='editor', id=trans.security.encode_id(stored.id) ) ) )
+
+ @web.expose
+ def run( self, trans, id, check_user=True, **kwargs ):
+ stored = get_stored_workflow( trans, id, check_ownership=False )
+ if check_user:
+ user = trans.get_user()
+ if stored.user != user:
+ if trans.sa_session.query( model.StoredWorkflowUserShareAssociation ) \
+ .filter_by( user=user, stored_workflow=stored ).count() == 0:
+ error( "Workflow is not owned by or shared with current user" )
+ # Get the latest revision
+ workflow = stored.latest_workflow
+ # It is possible for a workflow to have 0 steps
+ if len( workflow.steps ) == 0:
+ error( "Workflow cannot be run because it does not have any steps" )
+ #workflow = Workflow.from_simple( simplejson.loads( stored.encoded_value ), trans.app )
+ if workflow.has_cycles:
+ error( "Workflow cannot be run because it contains cycles" )
+ if workflow.has_errors:
+ error( "Workflow cannot be run because of validation errors in some steps" )
+ # Build the state for each step
+ errors = {}
+ if kwargs:
+ # If kwargs were provided, the states for each step should have
+ # been POSTed
+ for step in workflow.steps:
+ # Connections by input name
+ step.input_connections_by_name = \
+ dict( ( conn.input_name, conn ) for conn in step.input_connections )
+ # Extract just the arguments for this step by prefix
+ p = "%s|" % step.id
+ l = len(p)
+ step_args = dict( ( k[l:], v ) for ( k, v ) in kwargs.iteritems() if k.startswith( p ) )
+ step_errors = None
+ if step.type == 'tool' or step.type is None:
+ module = module_factory.from_workflow_step( trans, step )
+ # Any connected input needs to have value DummyDataset (these
+ # are not persisted so we need to do it every time)
+ module.add_dummy_datasets( connections=step.input_connections )
+ # Get the tool
+ tool = module.tool
+ # Get the state
+ step.state = state = module.state
+ # Get old errors
+ old_errors = state.inputs.pop( "__errors__", {} )
+ # Update the state
+ step_errors = tool.update_state( trans, tool.inputs, step.state.inputs, step_args,
+ update_only=True, old_errors=old_errors )
+ else:
+ module = step.module = module_factory.from_workflow_step( trans, step )
+ state = step.state = module.decode_runtime_state( trans, step_args.pop( "tool_state" ) )
+ step_errors = module.update_runtime_state( trans, state, step_args )
+ if step_errors:
+ errors[step.id] = state.inputs["__errors__"] = step_errors
+ if 'run_workflow' in kwargs and not errors:
+ # Run each step, connecting outputs to inputs
+ outputs = odict()
+ for i, step in enumerate( workflow.steps ):
+ if step.type == 'tool' or step.type is None:
+ tool = trans.app.toolbox.tools_by_id[ step.tool_id ]
+ input_values = step.state.inputs
+ # Connect up
+ def callback( input, value, prefixed_name, prefixed_label ):
+ if isinstance( input, DataToolParameter ):
+ if prefixed_name in step.input_connections_by_name:
+ conn = step.input_connections_by_name[ prefixed_name ]
+ return outputs[ conn.output_step.id ][ conn.output_name ]
+ visit_input_values( tool.inputs, step.state.inputs, callback )
+ # Execute it
+ outputs[ step.id ] = tool.execute( trans, step.state.inputs )
+ else:
+ outputs[ step.id ] = step.module.execute( trans, step.state )
+
+ return trans.fill_template( "workflow/run_complete.mako",
+ workflow=stored,
+ outputs=outputs )
+ else:
+ for step in workflow.steps:
+ if step.type == 'tool' or step.type is None:
+ # Restore the tool state for the step
+ module = module_factory.from_workflow_step( trans, step )
+ # Any connected input needs to have value DummyDataset (these
+ # are not persisted so we need to do it every time)
+ module.add_dummy_datasets( connections=step.input_connections )
+ # Store state with the step
+ step.module = module
+ step.state = module.state
+ # Error dict
+ if step.tool_errors:
+ errors[step.id] = step.tool_errors
+ else:
+ ## Non-tool specific stuff?
+ step.module = module_factory.from_workflow_step( trans, step )
+ step.state = step.module.get_runtime_state()
+ # Connections by input name
+ step.input_connections_by_name = dict( ( conn.input_name, conn ) for conn in step.input_connections )
+ # Render the form
+ return trans.fill_template(
+ "workflow/run.mako",
+ steps=workflow.steps,
+ workflow=stored,
+ errors=errors,
+ incoming=kwargs )
+
+ @web.expose
+ def configure_menu( self, trans, workflow_ids=None ):
+ user = trans.get_user()
+ if trans.request.method == "POST":
+ if workflow_ids is None:
+ workflow_ids = []
+ elif type( workflow_ids ) != list:
+ workflow_ids = [ workflow_ids ]
+ sess = trans.sa_session
+ # This explicit remove seems like a hack, need to figure out
+ # how to make the association do it automatically.
+ for m in user.stored_workflow_menu_entries:
+ sess.delete( m )
+ user.stored_workflow_menu_entries = []
+ q = sess.query( model.StoredWorkflow )
+ # To ensure id list is unique
+ seen_workflow_ids = set()
+ for id in workflow_ids:
+ if id in seen_workflow_ids:
+ continue
+ else:
+ seen_workflow_ids.add( id )
+ m = model.StoredWorkflowMenuEntry()
+ m.stored_workflow = q.get( id )
+ user.stored_workflow_menu_entries.append( m )
+ sess.flush()
+ return trans.show_message( "Menu updated", refresh_frames=['tools'] )
+ else:
+ user = trans.get_user()
+ ids_in_menu = set( [ x.stored_workflow_id for x in user.stored_workflow_menu_entries ] )
+ workflows = trans.sa_session.query( model.StoredWorkflow ) \
+ .filter_by( user=user, deleted=False ) \
+ .order_by( desc( model.StoredWorkflow.c.update_time ) ) \
+ .all()
+ shared_by_others = trans.sa_session \
+ .query( model.StoredWorkflowUserShareAssociation ) \
+ .filter_by( user=user ) \
+ .filter( model.StoredWorkflow.c.deleted == False ) \
+ .all()
+ return trans.fill_template( "workflow/configure_menu.mako",
+ workflows=workflows,
+ shared_by_others=shared_by_others,
+ ids_in_menu=ids_in_menu )
+
+## ---- Utility methods -------------------------------------------------------
+
+def get_stored_workflow( trans, id, check_ownership=True ):
+ """
+ Get a StoredWorkflow from the database by id, verifying ownership.
+ """
+ # Load workflow from database
+ id = trans.security.decode_id( id )
+ stored = trans.sa_session.query( model.StoredWorkflow ).get( id )
+ if not stored:
+ error( "Workflow not found" )
+ # Verify ownership
+ user = trans.get_user()
+ if not user:
+ error( "Must be logged in to use workflows" )
+ if check_ownership and not( stored.user == user ):
+ error( "Workflow is not owned by current user" )
+ # Looks good
+ return stored
+
+def attach_ordered_steps( workflow, steps ):
+ ordered_steps = order_workflow_steps( steps )
+ if ordered_steps:
+ workflow.has_cycles = False
+ for i, step in enumerate( ordered_steps ):
+ step.order_index = i
+ workflow.steps.append( step )
+ else:
+ workflow.has_cycles = True
+ workflow.steps = steps
+
+def edgelist_for_workflow_steps( steps ):
+ """
+ Create a list of tuples representing edges between `WorkflowSteps` based
+ on associated `WorkflowStepConnection`s
+ """
+ edges = []
+ steps_to_index = dict( ( step, i ) for i, step in enumerate( steps ) )
+ for step in steps:
+ edges.append( ( steps_to_index[step], steps_to_index[step] ) )
+ for conn in step.input_connections:
+ edges.append( ( steps_to_index[conn.output_step], steps_to_index[conn.input_step] ) )
+ return edges
+
+def order_workflow_steps( steps ):
+ """
+ Perform topological sort of the steps, return ordered or None
+ """
+ try:
+ edges = edgelist_for_workflow_steps( steps )
+ node_order = topsort( edges )
+ return [ steps[i] for i in node_order ]
+ except CycleError:
+ return None
+
+def order_workflow_steps_with_levels( steps ):
+ try:
+ return topsort_levels( edgelist_for_workflow_steps( steps ) )
+ except CycleError:
+ return None
+
+class FakeJob( object ):
+ """
+ Fake job object for datasets that have no creating_job_associations,
+ they will be treated as "input" datasets.
+ """
+ def __init__( self, dataset ):
+ self.is_fake = True
+ self.id = "fake_%s" % dataset.id
+
+def get_job_dict( trans ):
+ """
+ Return a dictionary of Job -> [ Dataset ] mappings, for all finished
+ active Datasets in the current history and the jobs that created them.
+ """
+ history = trans.get_history()
+ # Get the jobs that created the datasets
+ warnings = set()
+ jobs = odict()
+ for dataset in history.active_datasets:
+ # FIXME: Create "Dataset.is_finished"
+ if dataset.state in ( 'new', 'running', 'queued' ):
+ warnings.add( "Some datasets still queued or running were ignored" )
+ continue
+
+ #if this hda was copied from another, we need to find the job that created the origial hda
+ job_hda = dataset
+ while job_hda.copied_from_history_dataset_association:
+ job_hda = job_hda.copied_from_history_dataset_association
+
+ if not job_hda.creating_job_associations:
+ jobs[ FakeJob( dataset ) ] = [ ( None, dataset ) ]
+
+ for assoc in job_hda.creating_job_associations:
+ job = assoc.job
+ if job in jobs:
+ jobs[ job ].append( ( assoc.name, dataset ) )
+ else:
+ jobs[ job ] = [ ( assoc.name, dataset ) ]
+ return jobs, warnings
+
+def cleanup_param_values( inputs, values ):
+ """
+ Remove 'Data' values from `param_values`, along with metadata cruft,
+ but track the associations.
+ """
+ associations = []
+ names_to_clean = []
+ # dbkey is pushed in by the framework
+ if 'dbkey' in values:
+ del values['dbkey']
+ root_values = values
+ # Recursively clean data inputs and dynamic selects
+ def cleanup( prefix, inputs, values ):
+ for key, input in inputs.items():
+ if isinstance( input, ( SelectToolParameter, DrillDownSelectToolParameter ) ):
+ if input.is_dynamic:
+ values[key] = UnvalidatedValue( values[key] )
+ if isinstance( input, DataToolParameter ):
+ tmp = values[key]
+ values[key] = None
+ # HACK: Nested associations are not yet working, but we
+ # still need to clean them up so we can serialize
+ # if not( prefix ):
+ if tmp: #this is false for a non-set optional dataset
+ associations.append( ( tmp.hid, prefix + key ) )
+ # Cleanup the other deprecated crap associated with datasets
+ # as well. Worse, for nested datasets all the metadata is
+ # being pushed into the root. FIXME: MUST REMOVE SOON
+ key = prefix + key + "_"
+ for k in root_values.keys():
+ if k.startswith( key ):
+ del root_values[k]
+ elif isinstance( input, Repeat ):
+ group_values = values[key]
+ for i, rep_values in enumerate( group_values ):
+ rep_index = rep_values['__index__']
+ prefix = "%s_%d|" % ( key, rep_index )
+ cleanup( prefix, input.inputs, group_values[i] )
+ elif isinstance( input, Conditional ):
+ group_values = values[input.name]
+ current_case = group_values['__current_case__']
+ prefix = "%s|" % ( key )
+ cleanup( prefix, input.cases[current_case].inputs, group_values )
+ cleanup( "", inputs, values )
+ return associations
diff -r b46effa7b459 -r 7d19363e6e0d templates/cloud/configure_cloud.mako
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/templates/cloud/configure_cloud.mako Thu Aug 20 11:27:30 2009 -0400
@@ -0,0 +1,61 @@
+<%inherit file="/base.mako"/>
+
+<%def name="title()">Workflow home</%def>
+
+%if message:
+<%
+ try:
+ messagetype
+ except:
+ messagetype = "done"
+%>
+<p />
+<div class="${messagetype}message">
+ ${message}
+</div>
+%endif
+
+<h2>Galaxy in the clouds</h2>
+
+%if awsCredentials:
+ <table class="mange-table colored" border="0" cellspacing="0" cellpadding="0" width="100%">
+ <tr class="header">
+ <th>Name</th>
+ <th># of Steps</th>
+ ## <th>Last Updated</th>
+ <th></th>
+ </tr>
+ %for i, workflow in enumerate( workflows ):
+ <tr>
+ <td>
+ ${workflow.name}
+ <a id="wf-${i}-popup" class="popup-arrow" style="display: none;">▼</a>
+ </td>
+ <td>${len(workflow.latest_workflow.steps)}</td>
+ ## <td>${str(workflow.update_time)[:19]}</td>
+ <td>
+ <div popupmenu="wf-${i}-popup">
+ <a class="action-button" href="${h.url_for( action='editor', id=trans.security.encode_id(workflow.id) )}" target="_parent">Edit</a>
+ <a class="action-button" href="${h.url_for( controller='root', action='index', workflow_id=trans.security.encode_id(workflow.id) )}" target="_parent">Run</a>
+ <a class="action-button" href="${h.url_for( action='clone', id=trans.security.encode_id(workflow.id) )}">Clone</a>
+ <a class="action-button" href="${h.url_for( action='rename', id=trans.security.encode_id(workflow.id) )}">Rename</a>
+ <a class="action-button" href="${h.url_for( action='sharing', id=trans.security.encode_id(workflow.id) )}">Sharing</a>
+ <a class="action-button" confirm="Are you sure you want to delete workflow '${workflow.name}'?" href="${h.url_for( action='delete', id=trans.security.encode_id(workflow.id) )}">Delete</a>
+ </div>
+ </td>
+ </tr>
+ %endfor
+ </table>
+%else:
+
+ You have no AWS credentials associated with your Galaxy account:
+ <a class="action-button" href="${h.url_for( action='add' )}">
+ <img src="${h.url_for('/static/images/silk/add.png')}" />
+ <span>Add AWS credentials</span>
+ </a>
+ or
+ <a href="http://aws.amazon.com/" target="_blank">
+ open AWS account with Amazon</a>.
+
+%endif
+
diff -r b46effa7b459 -r 7d19363e6e0d templates/cloud/index.mako
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/templates/cloud/index.mako Thu Aug 20 11:27:30 2009 -0400
@@ -0,0 +1,16 @@
+<%inherit file="/base_panels.mako"/>
+
+<%def name="init()">
+<%
+ self.has_left_panel=False
+ self.has_right_panel=False
+ self.active_view="cloud"
+ self.message_box_visible=False
+%>
+</%def>
+
+<%def name="center_panel()">
+
+ <iframe name="galaxy_main" id="galaxy_main" frameborder="0" style="position: absolute; width: 100%; height: 100%;" src="${h.url_for( controller="cloud", action="list" )}"> </iframe>
+
+</%def>
\ No newline at end of file
1
0
Hi,
Our group has recently installed a local copy of GALAXY. Prior to that, I had been working from the online version and have a number of histories that I would like to be able to use in our local copy. Is there any way to transfer these histories?
Regards,
Beth Marosy
Beth Marosy, M.S.
Research Specialist
Center for Inherited Disease Research
Johns Hopkins University
410-550-2795
bmarosy1(a)jhmi.edu
2
1
Dear Galaxy team,
I am Sondos Seif, an undergrad student, in Cairo University,
Biomedical Engineering Department. I want to replace the SQLite
database with XML, I was just wondering if there is a way to do that
without having to edit in the engine or detaching SQLAlchemy?
Regards,
--
Sondos Seif El-Din
2
1
Hello Greg Von Kuster,
Thanks very much for your reply.
I have installed a local Galaxy and wrote a new tool config file for our GMap. It's really easy to build a local instance and it works very well now. :)
Becaues our GMap project is still under development, we will email you the inclusion file when we have a stable version which will come soon.
Thanks again for your help.
Best,
Kathleen
20091118
发件人: Greg Von Kuster
发送时间: 2009-11-18 02:10:17
收件人: wangjun
抄送: galaxy-dev
主题: Re: [galaxy-dev] Questions about Galaxy!
Kathleen,
Please install a local instance of Galaxy and develop a data source tool that works between your Galaxy instance and GMap. You can download Galaxy from http://bitbucket.org/galaxy/galaxy-central/wiki/GetGalaxy. When you have your tool working, please submit it to us for possible inclusion in the public Galaxy instance. Thanks very much for your interest in doing this.
Greg Von Kuster
1
0
17 Nov '09
details: http://www.bx.psu.edu/hg/galaxy/rev/4c3cddd02b09
changeset: 3043:4c3cddd02b09
user: Nate Coraor <nate(a)bx.psu.edu>
date: Mon Nov 16 18:38:32 2009 -0500
description:
Job recovery fix for jobs queued but with no runner where track_jobs_in_database=True
diffstat:
lib/galaxy/jobs/__init__.py | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diffs (20 lines):
diff -r df9814119044 -r 4c3cddd02b09 lib/galaxy/jobs/__init__.py
--- a/lib/galaxy/jobs/__init__.py Mon Nov 16 16:27:48 2009 -0500
+++ b/lib/galaxy/jobs/__init__.py Mon Nov 16 18:38:32 2009 -0500
@@ -139,10 +139,15 @@
JobWrapper( job, None, self ).fail( 'This tool was disabled before the job completed. Please contact your Galaxy administrator, or' )
elif job.job_runner_name is None:
log.debug( "no runner: %s is still in queued state, adding to the jobs queue" %job.id )
- self.queue.put( ( job.id, job.tool_id ) )
+ if self.track_jobs_in_database:
+ job.state = model.Job.states.NEW
+ else:
+ self.queue.put( ( job.id, job.tool_id ) )
else:
job_wrapper = JobWrapper( job, self.app.toolbox.tools_by_id[ job.tool_id ], self )
self.dispatcher.recover( job, job_wrapper )
+ if self.sa_session.dirty:
+ self.sa_session.flush()
def __monitor( self ):
"""
1
0
17 Nov '09
details: http://www.bx.psu.edu/hg/galaxy/rev/3c96ab27aa31
changeset: 3044:3c96ab27aa31
user: Greg Von Kuster <greg(a)bx.psu.edu>
date: Tue Nov 17 13:31:56 2009 -0500
description:
Fix a sqlalchemy session flush bug in the make_library_uploaded_dataset method.
diffstat:
lib/galaxy/web/controllers/library_common.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diffs (12 lines):
diff -r 4c3cddd02b09 -r 3c96ab27aa31 lib/galaxy/web/controllers/library_common.py
--- a/lib/galaxy/web/controllers/library_common.py Mon Nov 16 18:38:32 2009 -0500
+++ b/lib/galaxy/web/controllers/library_common.py Tue Nov 17 13:31:56 2009 -0500
@@ -117,7 +117,7 @@
uploaded_dataset.link_data_only = True
uploaded_dataset.data.file_name = os.path.abspath( path )
trans.sa_session.add( uploaded_dataset.data )
- trans.sa_session.data.flush()
+ trans.sa_session.flush()
return uploaded_dataset
def get_server_dir_uploaded_datasets( self, trans, params, full_dir, import_dir_desc, library_bunch, err_redirect, msg ):
files = []
1
0
details: http://www.bx.psu.edu/hg/galaxy/rev/56bb85457bc1
changeset: 3045:56bb85457bc1
user: Nate Coraor <nate(a)bx.psu.edu>
date: Tue Nov 17 13:43:34 2009 -0500
description:
Updated GeneTrack egg
diffstat:
eggs.ini | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diffs (21 lines):
diff -r 3c96ab27aa31 -r 56bb85457bc1 eggs.ini
--- a/eggs.ini Tue Nov 17 13:31:56 2009 -0500
+++ b/eggs.ini Tue Nov 17 13:43:34 2009 -0500
@@ -60,7 +60,7 @@
MySQL_python = _5.0.67_static
python_lzo = _static
bx_python = _dev_r4bf1f32e6b76
-GeneTrack = _dev_raa786e9fc131d998e532a1aef39d108850c9e93d
+GeneTrack = _dev_e380f21c704218622155b9d230a44b3c9c452524
SQLAlchemy = _dev_r6498
; nose = .dev_r7156749efc58
@@ -82,7 +82,7 @@
decorator = http://pypi.python.org/packages/source/d/decorator/decorator-3.1.2.tar.gz
docutils = http://downloads.sourceforge.net/docutils/docutils-0.4.tar.gz
elementtree = http://effbot.org/downloads/elementtree-1.2.6-20050316.tar.gz
-GeneTrack = http://github.com/ialbert/genetrack-central/tarball/aa786e9fc131d998e532a1a…
+GeneTrack = http://github.com/ialbert/genetrack-central/tarball/e380f21c704218622155b9d…
lrucache = http://evan.prodromou.name/lrucache/lrucache-0.2.tar.gz
Mako = http://www.makotemplates.org/downloads/Mako-0.2.5.tar.gz
nose = http://pypi.python.org/packages/source/n/nose/nose-0.11.1.tar.gz
1
0
17 Nov '09
details: http://www.bx.psu.edu/hg/galaxy/rev/ed8972386675
changeset: 3046:ed8972386675
user: rc
date: Tue Nov 17 14:28:34 2009 -0500
description:
Adding grids to forms, requests & request types pages. Resolves issue #231.
diffstat:
lib/galaxy/web/controllers/forms.py | 252 ++++++---
lib/galaxy/web/controllers/requests.py | 302 ++++++-----
lib/galaxy/web/controllers/requests_admin.py | 663 ++++++++++++++++---------
templates/admin/forms/edit_form.mako | 2 +-
templates/admin/forms/grid.mako | 1 +
templates/admin/forms/manage_forms.mako | 76 ---
templates/admin/forms/show_form_read_only.mako | 4 +-
templates/admin/requests/create_request_type.mako | 92 +-
templates/admin/requests/grid.mako | 218 +--------
templates/admin/requests/manage_request_types.mako | 69 +--
templates/admin/requests/show_request.mako | 2 +-
templates/admin/requests/view_request_type.mako | 70 +-
templates/requests/grid.mako | 218 +--------
templates/requests/show_request.mako | 2 +-
test/base/twilltestcase.py | 34 +-
test/functional/test_forms_and_requests.py | 44 +-
test/functional/test_user_info.py | 9 +-
17 files changed, 879 insertions(+), 1179 deletions(-)
diffs (2629 lines):
diff -r 56bb85457bc1 -r ed8972386675 lib/galaxy/web/controllers/forms.py
--- a/lib/galaxy/web/controllers/forms.py Tue Nov 17 13:43:34 2009 -0500
+++ b/lib/galaxy/web/controllers/forms.py Tue Nov 17 14:28:34 2009 -0500
@@ -8,9 +8,71 @@
from elementtree.ElementTree import XML, Element
from galaxy.util.odict import odict
import copy
+from galaxy.web.framework.helpers import time_ago, iff, grids
log = logging.getLogger( __name__ )
+class FormsGrid( grids.Grid ):
+ # Custom column types
+ class NameColumn( grids.TextColumn ):
+ def get_value(self, trans, grid, form):
+ return form.latest_form.name
+ class DescriptionColumn( grids.TextColumn ):
+ def get_value(self, trans, grid, form):
+ return form.latest_form.desc
+ class TypeColumn( grids.TextColumn ):
+ def get_value(self, trans, grid, form):
+ return form.latest_form.type
+ class DeletedColumn( grids.GridColumn ):
+ def get_accepted_filters( self ):
+ """ Returns a list of accepted filters for this column. """
+ accepted_filter_labels_and_vals = { "active" : "False", "deleted" : "True", "all": "All" }
+ accepted_filters = []
+ for label, val in accepted_filter_labels_and_vals.items():
+ args = { self.key: val }
+ accepted_filters.append( grids.GridColumnFilter( label, args) )
+ return accepted_filters
+ # Grid definition
+ title = "Forms"
+ template = "admin/forms/grid.mako"
+ model_class = model.FormDefinitionCurrent
+ default_sort_key = "-create_time"
+ num_rows_per_page = 50
+ preserve_state = True
+ use_paging = True
+ default_filter = dict( deleted="False" )
+ columns = [
+ NameColumn( "Name",
+ key="name",
+ model_class=model.FormDefinition,
+ link=( lambda item: iff( item.deleted, None, dict( operation="view", id=item.id ) ) ),
+ attach_popup=True,
+ filterable="advanced" ),
+ DescriptionColumn( "Description",
+ key='desc',
+ model_class=model.FormDefinition,
+ filterable="advanced" ),
+ TypeColumn( "Type" ),
+ DeletedColumn( "Deleted",
+ key="deleted",
+ visible=False,
+ filterable="advanced" )
+ ]
+ columns.append( grids.MulticolFilterColumn( "Search",
+ cols_to_filter=[ columns[0], columns[1] ],
+ key="free-text-search",
+ visible=False,
+ filterable="standard" ) )
+ operations = [
+ grids.GridOperation( "Edit", allow_multiple=False, condition=( lambda item: not item.deleted ) ),
+ grids.GridOperation( "Delete", allow_multiple=True, condition=( lambda item: not item.deleted ) ),
+ grids.GridOperation( "Undelete", condition=( lambda item: item.deleted ) ),
+ ]
+ global_actions = [
+ grids.GridAction( "Create new form", dict( controller='forms',
+ action='new' ) )
+ ]
+
class Forms( BaseController ):
# Empty form field
empty_field = { 'label': '',
@@ -20,38 +82,38 @@
'type': BaseField.form_field_types()[0],
'selectlist': [],
'layout': 'none' }
+ forms_grid = FormsGrid()
+
@web.expose
@web.require_admin
- def index( self, trans, **kwd ):
- params = util.Params( kwd )
- msg = util.restore_text( params.get( 'msg', '' ) )
- messagetype = params.get( 'messagetype', 'done' )
- return trans.fill_template( "/sample/index.mako",
- default_action=params.get( 'default_action', None ),
- msg=msg,
- messagetype=messagetype )
- @web.expose
- @web.require_admin
- def manage( self, trans, **kwd ):
- params = util.Params( kwd )
- msg = util.restore_text( params.get( 'msg', '' ) )
- messagetype = params.get( 'messagetype', 'done' )
- show_filter = params.get( 'show_filter', 'Active' )
- return self._show_forms_list(trans, msg, messagetype, show_filter)
- def _show_forms_list(self, trans, msg, messagetype, show_filter='Active'):
- all_forms = trans.sa_session.query( trans.app.model.FormDefinitionCurrent )
- if show_filter == 'All':
- forms_list = all_forms
- elif show_filter == 'Deleted':
- forms_list = [form for form in all_forms if form.deleted]
- else:
- forms_list = [form for form in all_forms if not form.deleted]
- return trans.fill_template( '/admin/forms/manage_forms.mako',
- fdc_list=forms_list,
- all_forms=all_forms,
- show_filter=show_filter,
- msg=msg,
- messagetype=messagetype )
+ def manage( self, trans, **kwd ):
+ if 'operation' in kwd:
+ operation = kwd['operation'].lower()
+ if not kwd.get( 'id', None ):
+ return trans.response.send_redirect( web.url_for( controller='forms',
+ action='manage',
+ status='error',
+ message="Invalid form ID") )
+ if operation == "view":
+ return self.__view( trans, **kwd )
+ elif operation == "delete":
+ return self.__delete( trans, **kwd )
+ elif operation == "undelete":
+ return self.__undelete( trans, **kwd )
+ elif operation == "edit":
+ return self.__edit( trans, **kwd )
+ return self.forms_grid( trans, **kwd )
+ def __view(self, trans, **kwd):
+ try:
+ fdc = trans.sa_session.query( trans.app.model.FormDefinitionCurrent )\
+ .get( trans.security.decode_id(kwd['id']) )
+ except:
+ return trans.response.send_redirect( web.url_for( controller='forms',
+ action='manage',
+ msg='Invalid form',
+ messagetype='error' ) )
+ return trans.fill_template( '/admin/forms/show_form_read_only.mako',
+ form=fdc.latest_form )
def __form_types_widget(self, trans, selected='none'):
form_type_selectbox = SelectField( 'form_type_selectbox',
refresh_on_change=True,
@@ -86,13 +148,14 @@
self.__get_saved_form( fd )
if self.__imported_from_file:
return trans.response.send_redirect( web.url_for( controller='forms',
- action='edit',
- show_form=True,
- form_id=fd.id) )
+ action='manage',
+ operation='edit',
+ id=trans.security.encode_id(fd.current.id)) )
else:
return trans.response.send_redirect( web.url_for( controller='forms',
- action='edit',
- form_id=fd.id,
+ action='manage',
+ operation='edit',
+ id=trans.security.encode_id(fd.current.id),
add_field_button='Add field',
name=fd.name,
description=fd.desc,
@@ -105,35 +168,43 @@
inputs=inputs,
msg=msg,
messagetype=messagetype )
- @web.expose
- @web.require_admin
- def delete( self, trans, **kwd ):
- params = util.Params( kwd )
- msg = util.restore_text( params.get( 'msg', '' ) )
- messagetype = params.get( 'messagetype', 'done' )
- fd = trans.sa_session.query( trans.app.model.FormDefinition ).get( int( util.restore_text( params.form_id ) ) )
- fd.form_definition_current.deleted = True
- trans.sa_session.add( fd.form_definition_current )
- trans.sa_session.flush()
- return self._show_forms_list(trans,
- msg='The form definition named %s is deleted.' % fd.name,
- messagetype='done')
- @web.expose
- @web.require_admin
- def undelete( self, trans, **kwd ):
- params = util.Params( kwd )
- msg = util.restore_text( params.get( 'msg', '' ) )
- messagetype = params.get( 'messagetype', 'done' )
- fd = trans.sa_session.query( trans.app.model.FormDefinition ).get( int( util.restore_text( params.form_id ) ) )
- fd.form_definition_current.deleted = False
- trans.sa_session.add( fd.form_definition_current )
- trans.sa_session.flush()
- return self._show_forms_list(trans,
- msg='The form definition named %s is undeleted.' % fd.name,
- messagetype='done')
- @web.expose
- @web.require_admin
- def edit( self, trans, **kwd ):
+ def __delete( self, trans, **kwd ):
+ id_list = util.listify( kwd['id'] )
+ delete_failed = []
+ for id in id_list:
+ try:
+ fdc = trans.sa_session.query( trans.app.model.FormDefinitionCurrent ).get( trans.security.decode_id(id) )
+ except:
+ return trans.response.send_redirect( web.url_for( controller='forms',
+ action='manage',
+ message='Invalid form',
+ status='error' ) )
+ fdc.deleted = True
+ trans.sa_session.add( fdc )
+ trans.sa_session.flush()
+ return trans.response.send_redirect( web.url_for( controller='forms',
+ action='manage',
+ message='%i form(s) is deleted.' % len(id_list),
+ status='done') )
+ def __undelete( self, trans, **kwd ):
+ id_list = util.listify( kwd['id'] )
+ delete_failed = []
+ for id in id_list:
+ try:
+ fdc = trans.sa_session.query( trans.app.model.FormDefinitionCurrent ).get( trans.security.decode_id(id) )
+ except:
+ return trans.response.send_redirect( web.url_for( controller='forms',
+ action='manage',
+ message='Invalid form',
+ status='error' ) )
+ fdc.deleted = False
+ trans.sa_session.add( fdc )
+ trans.sa_session.flush()
+ return trans.response.send_redirect( web.url_for( controller='forms',
+ action='manage',
+ message='%i form(s) is undeleted.' % len(id_list),
+ status='done') )
+ def __edit( self, trans, **kwd ):
'''
This callback method is for handling all the editing functions like
renaming fields, adding/deleting fields, changing fields attributes.
@@ -142,17 +213,28 @@
msg = util.restore_text( params.get( 'msg', '' ) )
messagetype = params.get( 'messagetype', 'done' )
try:
- fd = trans.sa_session.query( trans.app.model.FormDefinition ).get( int( params.get( 'form_id', None ) ) )
+ fdc = trans.sa_session.query( trans.app.model.FormDefinitionCurrent ).get( trans.security.decode_id(kwd['id']) )
except:
return trans.response.send_redirect( web.url_for( controller='forms',
action='manage',
- msg='Invalid form',
- messagetype='error' ) )
+ message='Invalid form',
+ status='error' ) )
+ fd = fdc.latest_form
#
- # Show the form for editing
+ # Save changes
#
- if params.get( 'show_form', False ):
+ if params.get( 'save_changes_button', False ):
+ fd_new, msg = self.__save_form( trans, fdc_id=fd.form_definition_current.id, **kwd )
+ # if validation error encountered while saving the form, show the
+ # unsaved form, with the error message
+ if not fd_new:
+ current_form = self.__get_form( trans, **kwd )
+ return self.__show( trans=trans, form=fd, current_form=current_form,
+ msg=msg, messagetype='error', **kwd )
+ # everything went fine. form saved successfully. Show the saved form
+ fd = fd_new
current_form = self.__get_saved_form( fd )
+ msg = "The form '%s' has been updated with the changes." % fd.name
return self.__show( trans=trans, form=fd, current_form=current_form,
msg=msg, messagetype=messagetype, **kwd )
#
@@ -193,31 +275,6 @@
return self.__show( trans=trans, form=fd, current_form=current_form,
msg=msg, messagetype=messagetype, **kwd )
#
- # Save changes
- #
- elif params.get( 'save_changes_button', False ):
- fd_new, msg = self.__save_form( trans, fdc_id=fd.form_definition_current.id, **kwd )
- # if validation error encountered while saving the form, show the
- # unsaved form, with the error message
- if not fd_new:
- current_form = self.__get_form( trans, **kwd )
- return self.__show( trans=trans, form=fd, current_form=current_form,
- msg=msg, messagetype='error', **kwd )
- # everything went fine. form saved successfully. Show the saved form
- fd = fd_new
- current_form = self.__get_saved_form( fd )
- msg = "The form '%s' has been updated with the changes." % fd.name
- return self.__show( trans=trans, form=fd, current_form=current_form,
- msg=msg, messagetype=messagetype, **kwd )
- #
- # Show form read-only
- #
- elif params.get( 'read_only', False ):
- return trans.fill_template( '/admin/forms/show_form_read_only.mako',
- form=fd,
- msg=msg,
- messagetype=messagetype )
- #
# Add SelectField option
#
elif 'Add' in kwd.values():
@@ -234,6 +291,13 @@
current_form = self.__get_form( trans, **kwd )
return self.__show( trans=trans, form=fd, current_form=current_form,
msg=msg, messagetype=messagetype, **kwd )
+ #
+ # Show the form for editing
+ #
+ else:
+ current_form = self.__get_saved_form( fd )
+ return self.__show( trans=trans, form=fd, current_form=current_form,
+ msg=msg, messagetype=messagetype, **kwd )
def __add_selectbox_option( self, trans, fd, msg, messagetype, **kwd ):
'''
diff -r 56bb85457bc1 -r ed8972386675 lib/galaxy/web/controllers/requests.py
--- a/lib/galaxy/web/controllers/requests.py Tue Nov 17 13:43:34 2009 -0500
+++ b/lib/galaxy/web/controllers/requests.py Tue Nov 17 14:28:34 2009 -0500
@@ -12,57 +12,109 @@
log = logging.getLogger( __name__ )
-class RequestsListGrid( grids.Grid ):
+class RequestsGrid( grids.Grid ):
+ # Custom column types
+ class NameColumn( grids.TextColumn ):
+ def get_value(self, trans, grid, request):
+ return request.name
+ class DescriptionColumn( grids.TextColumn ):
+ def get_value(self, trans, grid, request):
+ return request.desc
+ class SamplesColumn( grids.GridColumn ):
+ def get_value(self, trans, grid, request):
+ return str(len(request.samples))
+ class TypeColumn( grids.TextColumn ):
+ def get_value(self, trans, grid, request):
+ return request.type.name
+ class LastUpdateColumn( grids.TextColumn ):
+ def get_value(self, trans, grid, request):
+ return request.update_time
+ class StateColumn( grids.GridColumn ):
+ def filter( self, db_session, query, column_filter ):
+ """ Modify query to filter request by state. """
+ if column_filter == "All":
+ return query
+ if column_filter:
+ query = query.filter( model.Request.state == column_filter )
+ return query
+ def get_accepted_filters( self ):
+ """ Returns a list of accepted filters for this column. """
+ accepted_filter_labels_and_vals = [ model.Request.states.UNSUBMITTED,
+ model.Request.states.SUBMITTED,
+ model.Request.states.COMPLETE,
+ "All"]
+ accepted_filters = []
+ for val in accepted_filter_labels_and_vals:
+ label = val.lower()
+ args = { self.key: val }
+ accepted_filters.append( grids.GridColumnFilter( label, args) )
+ return accepted_filters
+ class DeletedColumn( grids.GridColumn ):
+ def get_accepted_filters( self ):
+ """ Returns a list of accepted filters for this column. """
+ accepted_filter_labels_and_vals = { "active" : "False", "deleted" : "True", "all": "All" }
+ accepted_filters = []
+ for label, val in accepted_filter_labels_and_vals.items():
+ args = { self.key: val }
+ accepted_filters.append( grids.GridColumnFilter( label, args) )
+ return accepted_filters
+ # Grid definition
title = "Sequencing Requests"
- template = '/requests/grid.mako'
+ template = 'requests/grid.mako'
model_class = model.Request
default_sort_key = "-create_time"
- show_filter = model.Request.states.UNSUBMITTED
+ num_rows_per_page = 50
+ preserve_state = True
+ use_paging = True
+ default_filter = dict( deleted="False", state=model.Request.states.UNSUBMITTED)
columns = [
- grids.GridColumn( "Name", key="name",
- link=( lambda item: iff( item.deleted, None, dict( operation="show_request", id=item.id ) ) ),
- attach_popup=True ),
- grids.GridColumn( "Description", key='desc'),
- grids.GridColumn( "Sample(s)", method='number_of_samples',
- link=( lambda item: iff( item.deleted, None, dict( operation="show_request", id=item.id ) ) ), ),
- grids.GridColumn( "Type", key="request_type_id", method='get_request_type'),
- grids.GridColumn( "Last update", key="update_time", format=time_ago ),
- grids.GridColumn( "State", key='state'),
+ NameColumn( "Name",
+ key="name",
+ model_class=model.Request,
+ link=( lambda item: iff( item.deleted, None, dict( operation="show_request", id=item.id ) ) ),
+ attach_popup=True,
+ filterable="advanced" ),
+ DescriptionColumn( "Description",
+ key='desc',
+ model_class=model.Request,
+ filterable="advanced" ),
+ SamplesColumn( "Sample(s)",
+ link=( lambda item: iff( item.deleted, None, dict( operation="show_request", id=item.id ) ) ), ),
+ TypeColumn( "Type" ),
+ LastUpdateColumn( "Last update",
+ format=time_ago ),
+ StateColumn( "State",
+ key='state',
+ filterable="advanced"),
+ DeletedColumn( "Deleted",
+ key="deleted",
+ visible=True,
+ filterable="advanced" )
]
+ columns.append( grids.MulticolFilterColumn( "Search",
+ cols_to_filter=[ columns[0], columns[1] ],
+ key="free-text-search",
+ visible=False,
+ filterable="standard" ) )
operations = [
grids.GridOperation( "Submit", allow_multiple=False, condition=( lambda item: not item.deleted and item.unsubmitted() and item.samples ) ),
grids.GridOperation( "Edit", allow_multiple=False, condition=( lambda item: not item.deleted and item.unsubmitted() ) ),
- grids.GridOperation( "Delete", allow_multiple=False, condition=( lambda item: not item.deleted and item.unsubmitted() ) ),
- grids.GridOperation( "Undelete", allow_multiple=False, condition=( lambda item: item.deleted ) )
+ grids.GridOperation( "Delete", allow_multiple=True, condition=( lambda item: not item.deleted and item.unsubmitted() ) ),
+ grids.GridOperation( "Undelete", allow_multiple=True, condition=( lambda item: item.deleted ) )
]
- standard_filters = [
- grids.GridColumnFilter( model.Request.states.UNSUBMITTED,
- args=dict( state=model.Request.states.UNSUBMITTED, deleted=False ) ),
- grids.GridColumnFilter( model.Request.states.SUBMITTED,
- args=dict( state=model.Request.states.SUBMITTED, deleted=False ) ),
- grids.GridColumnFilter( model.Request.states.COMPLETE, args=dict( state=model.Request.states.COMPLETE, deleted=False ) ),
- grids.GridColumnFilter( "Deleted", args=dict( deleted=True ) ),
- grids.GridColumnFilter( "All", args={} )
+ global_actions = [
+ grids.GridAction( "Create new request", dict( controller='requests',
+ action='new',
+ select_request_type='True' ) )
]
- #default_filter = dict( deleted=False )
- def get_current_item( self, trans ):
- return None
- def get_request_type(self, trans, request):
- return request.type.name
- def apply_default_filter( self, trans, query, **kwargs ):
- query = query.filter_by( user=trans.user )
- if self.default_filter:
- return query.filter_by( **self.default_filter )
- else:
- return query
- def number_of_samples(self, trans, request):
- return str(len(request.samples))
- def get_state(self, trans, request):
- return request.state
+ def apply_default_filter( self, trans, query, **kwd ):
+ return query.filter_by( user=trans.user )
+ def build_initial_query( self, session ):
+ return session.query( self.model_class )
class Requests( BaseController ):
- request_grid = RequestsListGrid()
+ request_grid = RequestsGrid()
@web.expose
@web.require_login( "create/submit sequencing requests" )
@@ -71,50 +123,43 @@
@web.expose
@web.require_login( "create/submit sequencing requests" )
- def list( self, trans, **kwargs ):
+ def list( self, trans, **kwd ):
'''
List all request made by the current user
'''
- status = message = None
- self.request_grid.default_filter = dict(state=trans.app.model.Request.states.UNSUBMITTED,
- deleted=False)
- if 'operation' in kwargs:
- operation = kwargs['operation'].lower()
+
+ if 'operation' in kwd:
+ operation = kwd['operation'].lower()
+ if not kwd.get( 'id', None ):
+ return trans.response.send_redirect( web.url_for( controller='requests',
+ action='list',
+ status='error',
+ message="Invalid request ID") )
if operation == "show_request":
- id = trans.security.decode_id(kwargs['id'])
- return self.__show_request(trans, id, kwargs.get('add_sample', False))
+ return self.__show_request( trans, **kwd )
elif operation == "submit":
- id = trans.security.decode_id(kwargs['id'])
- return self.__submit_request(trans, id)
+ return self.__submit_request( trans, **kwd )
elif operation == "delete":
- id = trans.security.decode_id(kwargs['id'])
- return self.__delete_request(trans, id)
+ return self.__delete_request( trans, **kwd )
elif operation == "undelete":
- id = trans.security.decode_id(kwargs['id'])
- return self.__undelete_request(trans, id)
+ return self.__undelete_request( trans, **kwd )
elif operation == "edit":
- id = trans.security.decode_id(kwargs['id'])
- return self.__edit_request(trans, id)
- if 'show_filter' in kwargs.keys():
- if kwargs['show_filter'] == 'All':
- self.request_grid.default_filter = {}
- elif kwargs['show_filter'] == 'Deleted':
- self.request_grid.default_filter = dict(deleted=True)
- else:
- self.request_grid.default_filter = dict(state=kwargs['show_filter'], deleted=False)
- self.request_grid.show_filter = kwargs.get('show_filter', trans.app.model.Request.states.UNSUBMITTED)
+ return self.__edit_request( trans, **kwd )
# Render the list view
- return self.request_grid( trans, **kwargs )
+ return self.request_grid( trans, **kwd )
- def __show_request(self, trans, id, add_sample=False):
+ def __show_request(self, trans, **kwd):
+ params = util.Params( kwd )
+ msg = util.restore_text( params.get( 'msg', '' ) )
+ messagetype = params.get( 'messagetype', 'done' )
+ add_sample = params.get('add_sample', False)
try:
- request = trans.sa_session.query( trans.app.model.Request ).get( id )
+ request = trans.sa_session.query( trans.app.model.Request ).get( trans.security.decode_id(kwd['id']) )
except:
return trans.response.send_redirect( web.url_for( controller='requests',
action='list',
status='error',
- message="Invalid request ID",
- **kwd) )
+ message="Invalid request ID" ) )
current_samples = []
for s in request.samples:
current_samples.append([s.name, s.values.content])
@@ -122,10 +167,11 @@
current_samples.append(['Sample_%i' % (len(current_samples)+1),['' for field in request.type.sample_form.fields]])
return trans.fill_template( '/requests/show_request.mako',
request=request,
- request_details=self.request_details(trans, id),
+ request_details=self.request_details(trans, request.id),
current_samples = current_samples,
sample_copy=self.__copy_sample(current_samples),
- details='hide', edit_mode='False')
+ details='hide', edit_mode='False',
+ msg=msg, messagetype=messagetype )
def request_details(self, trans, id):
'''
Shows the request details
@@ -685,7 +731,7 @@
message="Invalid request ID",
**kwd) )
if params.get('show', False) == 'True':
- return self.__edit_request(trans, request.id, **kwd)
+ return self.__edit_request(trans, **kwd)
elif params.get('save_changes_request_button', False) == 'Save changes' \
or params.get('edit_samples_button', False) == 'Edit samples':
request_type = trans.sa_session.query( trans.app.model.RequestType ).get( int( params.select_request_type ) )
@@ -714,11 +760,11 @@
messagetype='done',
**new_kwd) )
elif params.get('refresh', False) == 'true':
- return self.__edit_request(trans, request.id, **kwd)
+ return self.__edit_request(trans, **kwd)
- def __edit_request(self, trans, id, **kwd):
+ def __edit_request(self, trans, **kwd):
try:
- request = trans.sa_session.query( trans.app.model.Request ).get( id )
+ request = trans.sa_session.query( trans.app.model.Request ).get( trans.security.decode_id(kwd['id']) )
except:
msg = "Invalid request ID"
log.warn( msg )
@@ -758,59 +804,61 @@
msg=msg,
messagetype=messagetype)
return self.__show_request_form(trans)
- def __delete_request(self, trans, id):
- try:
- request = trans.sa_session.query( trans.app.model.Request ).get( id )
- except:
- msg = "Invalid request ID"
- log.warn( msg )
- return trans.response.send_redirect( web.url_for( controller='requests',
- action='list',
- status='error',
- message=msg,
- **kwd) )
- # change request's submitted field
- if not request.unsubmitted():
- return trans.response.send_redirect( web.url_for( controller='requests',
- action='list',
- status='error',
- message='This request cannot be deleted as it is already been submitted',
- **kwd) )
- request.deleted = True
- trans.sa_session.add( request )
- trans.sa_session.flush()
- kwd = {}
- kwd['id'] = trans.security.encode_id(request.id)
+ def __delete_request(self, trans, **kwd):
+ id_list = util.listify( kwd['id'] )
+ delete_failed = []
+ for id in id_list:
+ try:
+ request = trans.sa_session.query( trans.app.model.Request ).get( trans.security.decode_id(id) )
+ except:
+ msg = "Invalid request ID"
+ log.warn( msg )
+ return trans.response.send_redirect( web.url_for( controller='requests',
+ action='list',
+ status='error',
+ message=msg,
+ **kwd) )
+ # a request cannot be deleted once its submitted
+ if not request.unsubmitted():
+ delete_failed.append(request.name)
+ else:
+ request.deleted = True
+ trans.sa_session.add( request )
+ trans.sa_session.flush()
+ if not len(delete_failed):
+ msg = '%i request(s) has been deleted.' % len(id_list)
+ status = 'done'
+ else:
+ msg = '%i request(s) has been deleted. %i request %s could not be deleted as they have been submitted.' % (len(id_list)-len(delete_failed),
+ len(delete_failed), str(delete_failed))
+ status = 'warning'
+ return trans.response.send_redirect( web.url_for( controller='requests',
+ action='list',
+ status=status,
+ message=msg) )
+ def __undelete_request(self, trans, **kwd):
+ id_list = util.listify( kwd['id'] )
+ for id in id_list:
+ try:
+ request = trans.sa_session.query( trans.app.model.Request ).get( trans.security.decode_id(id) )
+ except:
+ msg = "Invalid request ID"
+ log.warn( msg )
+ return trans.response.send_redirect( web.url_for( controller='requests',
+ action='list',
+ status='error',
+ message=msg,
+ **kwd) )
+ request.deleted = False
+ trans.sa_session.add( request )
+ trans.sa_session.flush()
return trans.response.send_redirect( web.url_for( controller='requests',
action='list',
status='done',
- message='The request <b>%s</b> has been deleted.' % request.name,
- **kwd) )
- def __undelete_request(self, trans, id):
+ message='%i request(s) has been undeleted.' % len(id_list) ) )
+ def __submit_request(self, trans, **kwd):
try:
- request = trans.sa_session.query( trans.app.model.Request ).get( id )
- except:
- msg = "Invalid request ID"
- log.warn( msg )
- return trans.response.send_redirect( web.url_for( controller='requests',
- action='list',
- status='error',
- message=msg,
- **kwd) )
- # change request's submitted field
- request.deleted = False
- trans.sa_session.add( request )
- trans.sa_session.flush()
- kwd = {}
- kwd['id'] = trans.security.encode_id(request.id)
- return trans.response.send_redirect( web.url_for( controller='requests',
- action='list',
- status='done',
- message='The request <b>%s</b> has been undeleted.' % request.name,
- **kwd) )
- def __submit_request(self, trans, id):
- try:
- request = trans.sa_session.query( trans.app.model.Request ).get( id )
+ request = trans.sa_session.query( trans.app.model.Request ).get( trans.security.decode_id(kwd['id']) )
except:
msg = "Invalid request ID"
log.warn( msg )
@@ -837,14 +885,12 @@
request.state = request.states.SUBMITTED
trans.sa_session.add( request )
trans.sa_session.flush()
- kwd = {}
- kwd['id'] = trans.security.encode_id(request.id)
- kwd['status'] = 'done'
- kwd['message'] = 'The request <b>%s</b> has been submitted.' % request.name
return trans.response.send_redirect( web.url_for( controller='requests',
action='list',
- show_filter=trans.app.model.Request.states.SUBMITTED,
- **kwd) )
+ id=trans.security.encode_id(request.id),
+ status='done',
+ message='The request <b>%s</b> has been submitted.' % request.name
+ ) )
@web.expose
@web.require_login( "create/submit sequencing requests" )
def show_events(self, trans, **kwd):
diff -r 56bb85457bc1 -r ed8972386675 lib/galaxy/web/controllers/requests_admin.py
--- a/lib/galaxy/web/controllers/requests_admin.py Tue Nov 17 13:43:34 2009 -0500
+++ b/lib/galaxy/web/controllers/requests_admin.py Tue Nov 17 14:28:34 2009 -0500
@@ -15,63 +15,187 @@
# ---- Request Grid ------------------------------------------------------------
#
-class RequestsListGrid( grids.Grid ):
+class RequestsGrid( grids.Grid ):
+ # Custom column types
+ class NameColumn( grids.TextColumn ):
+ def get_value(self, trans, grid, request):
+ return request.name
+ class DescriptionColumn( grids.TextColumn ):
+ def get_value(self, trans, grid, request):
+ return request.desc
+ class SamplesColumn( grids.GridColumn ):
+ def get_value(self, trans, grid, request):
+ return str(len(request.samples))
+ class TypeColumn( grids.TextColumn ):
+ def get_value(self, trans, grid, request):
+ return request.type.name
+ class LastUpdateColumn( grids.TextColumn ):
+ def get_value(self, trans, grid, request):
+ return request.update_time
+ class StateColumn( grids.GridColumn ):
+ def filter( self, db_session, query, column_filter ):
+ """ Modify query to filter request by state. """
+ if column_filter == "All":
+ return query
+ if column_filter:
+ query = query.filter( model.Request.state == column_filter )
+ return query
+ def get_accepted_filters( self ):
+ """ Returns a list of accepted filters for this column. """
+ accepted_filter_labels_and_vals = [ model.Request.states.UNSUBMITTED,
+ model.Request.states.SUBMITTED,
+ model.Request.states.COMPLETE,
+ "All"]
+ accepted_filters = []
+ for val in accepted_filter_labels_and_vals:
+ label = val.lower()
+ args = { self.key: val }
+ accepted_filters.append( grids.GridColumnFilter( label, args) )
+ return accepted_filters
+ class UserColumn( grids.TextColumn ):
+ def get_value(self, trans, grid, request):
+ return request.user.email
+ class DeletedColumn( grids.GridColumn ):
+ def get_accepted_filters( self ):
+ """ Returns a list of accepted filters for this column. """
+ accepted_filter_labels_and_vals = { "active" : "False", "deleted" : "True", "all": "All" }
+ accepted_filters = []
+ for label, val in accepted_filter_labels_and_vals.items():
+ args = { self.key: val }
+ accepted_filters.append( grids.GridColumnFilter( label, args) )
+ return accepted_filters
+ # Grid definition
title = "Sequencing Requests"
template = "admin/requests/grid.mako"
model_class = model.Request
default_sort_key = "-create_time"
- show_filter = model.Request.states.SUBMITTED
+ num_rows_per_page = 50
+ preserve_state = True
+ use_paging = True
+ default_filter = dict( deleted="False", state=model.Request.states.SUBMITTED)
columns = [
- grids.GridColumn( "Name", key="name",
- link=( lambda item: iff( item.deleted, None, dict( operation="show_request", id=item.id ) ) ),
- attach_popup=True ),
- grids.GridColumn( "Description", key="desc"),
- grids.GridColumn( "Sample(s)", method='number_of_samples',
- link=( lambda item: iff( item.deleted, None, dict( operation="show_request", id=item.id ) ) ), ),
- grids.GridColumn( "Type", key="request_type_id", method='get_request_type'),
- grids.GridColumn( "Last update", key="update_time", format=time_ago ),
- grids.GridColumn( "State", key='state'),
- grids.GridColumn( "User", key="user_id", method='get_user')
-
+ NameColumn( "Name",
+ key="name",
+ model_class=model.Request,
+ link=( lambda item: iff( item.deleted, None, dict( operation="show_request", id=item.id ) ) ),
+ attach_popup=True,
+ filterable="advanced" ),
+ DescriptionColumn( "Description",
+ key='desc',
+ model_class=model.Request,
+ filterable="advanced" ),
+ SamplesColumn( "Sample(s)",
+ link=( lambda item: iff( item.deleted, None, dict( operation="show_request", id=item.id ) ) ), ),
+ TypeColumn( "Type" ),
+ LastUpdateColumn( "Last update",
+ format=time_ago ),
+ StateColumn( "State",
+ key='state',
+ filterable="advanced"),
+ UserColumn( "User",
+ key='user.email',
+ model_class=model.Request,
+ filterable="advanced" ),
+ DeletedColumn( "Deleted",
+ key="deleted",
+ visible=True,
+ filterable="advanced" )
]
+ columns.append( grids.MulticolFilterColumn( "Search",
+ cols_to_filter=[ columns[0], columns[1], columns[6] ],
+ key="free-text-search",
+ visible=False,
+ filterable="standard" ) )
operations = [
grids.GridOperation( "Submit", allow_multiple=False, condition=( lambda item: not item.deleted and item.unsubmitted() and item.samples ) ),
grids.GridOperation( "Edit", allow_multiple=False, condition=( lambda item: not item.deleted ) ),
grids.GridOperation( "Reject", allow_multiple=False, condition=( lambda item: not item.deleted and item.submitted() ) ),
- grids.GridOperation( "Delete", allow_multiple=False, condition=( lambda item: not item.deleted and item.unsubmitted() ) ),
+ grids.GridOperation( "Delete", allow_multiple=True, condition=( lambda item: not item.deleted and item.unsubmitted() ) ),
grids.GridOperation( "Undelete", condition=( lambda item: item.deleted ) ),
]
- standard_filters = [
- grids.GridColumnFilter( model.Request.states.UNSUBMITTED,
- args=dict( state=model.Request.states.UNSUBMITTED, deleted=False ) ),
- grids.GridColumnFilter( model.Request.states.SUBMITTED,
- args=dict( state=model.Request.states.SUBMITTED, deleted=False ) ),
- grids.GridColumnFilter( model.Request.states.COMPLETE, args=dict( state=model.Request.states.COMPLETE, deleted=False ) ),
- grids.GridColumnFilter( "Deleted", args=dict( deleted=True ) ),
- grids.GridColumnFilter( "All", args=dict( deleted=False ) )
+ global_actions = [
+ grids.GridAction( "Create new request", dict( controller='requests_admin',
+ action='new',
+ select_request_type='True' ) )
]
- def get_user(self, trans, request):
- return trans.sa_session.query( trans.app.model.User ).get( request.user_id ).email
- def get_current_item( self, trans ):
- return None
- def get_request_type(self, trans, request):
- request_type = trans.sa_session.query( trans.app.model.RequestType ).get( request.request_type_id )
- return request_type.name
- def number_of_samples(self, trans, request):
- return str(len(request.samples))
- def apply_default_filter( self, trans, query, **kwargs ):
- if self.default_filter:
- return query.filter_by( **self.default_filter )
- else:
- return query
-
+
+#
+# ---- Request Type Gridr ------------------------------------------------------
+#
+class RequestTypeGrid( grids.Grid ):
+ # Custom column types
+ class NameColumn( grids.TextColumn ):
+ def get_value(self, trans, grid, request_type):
+ return request_type.name
+ class DescriptionColumn( grids.TextColumn ):
+ def get_value(self, trans, grid, request_type):
+ return request_type.desc
+ class RequestFormColumn( grids.TextColumn ):
+ def get_value(self, trans, grid, request_type):
+ return request_type.request_form.name
+ class SampleFormColumn( grids.TextColumn ):
+ def get_value(self, trans, grid, request_type):
+ return request_type.sample_form.name
+ class DeletedColumn( grids.GridColumn ):
+ def get_accepted_filters( self ):
+ """ Returns a list of accepted filters for this column. """
+ accepted_filter_labels_and_vals = { "active" : "False", "deleted" : "True", "all": "All" }
+ accepted_filters = []
+ for label, val in accepted_filter_labels_and_vals.items():
+ args = { self.key: val }
+ accepted_filters.append( grids.GridColumnFilter( label, args) )
+ return accepted_filters
+ # Grid definition
+ title = "Requests Types"
+ template = "admin/requests/manage_request_types.mako"
+ model_class = model.RequestType
+ default_sort_key = "-create_time"
+ num_rows_per_page = 50
+ preserve_state = True
+ use_paging = True
+ default_filter = dict( deleted="False" )
+ columns = [
+ NameColumn( "Name",
+ key="name",
+ model_class=model.RequestType,
+ link=( lambda item: iff( item.deleted, None, dict( operation="view", id=item.id ) ) ),
+ attach_popup=True,
+ filterable="advanced" ),
+ DescriptionColumn( "Description",
+ key='desc',
+ model_class=model.Request,
+ filterable="advanced" ),
+ RequestFormColumn( "Request Form",
+ link=( lambda item: iff( item.deleted, None, dict( operation="view_form", id=item.request_form.id ) ) ), ),
+ SampleFormColumn( "Sample Form",
+ link=( lambda item: iff( item.deleted, None, dict( operation="view_form", id=item.sample_form.id ) ) ), ),
+ DeletedColumn( "Deleted",
+ key="deleted",
+ visible=False,
+ filterable="advanced" )
+ ]
+ columns.append( grids.MulticolFilterColumn( "Search",
+ cols_to_filter=[ columns[0], columns[1] ],
+ key="free-text-search",
+ visible=False,
+ filterable="standard" ) )
+ operations = [
+ #grids.GridOperation( "Update", allow_multiple=False, condition=( lambda item: not item.deleted ) ),
+ grids.GridOperation( "Delete", allow_multiple=True, condition=( lambda item: not item.deleted ) ),
+ grids.GridOperation( "Undelete", condition=( lambda item: item.deleted ) ),
+ ]
+ global_actions = [
+ grids.GridAction( "Create new request type", dict( controller='requests_admin',
+ action='create_request_type' ) )
+ ]
#
# ---- Request Controller ------------------------------------------------------
#
class Requests( BaseController ):
- request_grid = RequestsListGrid()
+ request_grid = RequestsGrid()
+ requesttype_grid = RequestTypeGrid()
@web.expose
@web.require_admin
@@ -80,67 +204,59 @@
@web.expose
@web.require_admin
- def list( self, trans, **kwargs ):
+ def list( self, trans, **kwd ):
'''
List all request made by the current user
'''
- message = util.restore_text( kwargs.get( 'message', '' ) )
- status = kwargs.get( 'status', 'done' )
- self.request_grid.default_filter = dict(state=trans.app.model.Request.states.SUBMITTED,
- deleted=False)
- if 'operation' in kwargs:
- operation = kwargs['operation'].lower()
+ if 'operation' in kwd:
+ operation = kwd['operation'].lower()
+ if not kwd.get( 'id', None ):
+ return trans.response.send_redirect( web.url_for( controller='requests_admin',
+ action='list',
+ status='error',
+ message="Invalid request ID") )
if operation == "show_request":
- id = trans.security.decode_id(kwargs['id'])
- return self.__show_request(trans, id, status, message)
+ return self.__show_request( trans, **kwd )
elif operation == "submit":
- id = trans.security.decode_id(kwargs['id'])
- return self.__submit_request(trans, id)
+ return self.__submit_request( trans, **kwd )
+ elif operation == "delete":
+ return self.__delete_request( trans, **kwd )
+ elif operation == "undelete":
+ return self.__undelete_request( trans, **kwd )
elif operation == "edit":
- id = trans.security.decode_id(kwargs['id'])
- return self.__edit_request(trans, id)
- elif operation == "delete":
- id = trans.security.decode_id(kwargs['id'])
- return self.__delete_request(trans, id)
- elif operation == "undelete":
- id = trans.security.decode_id(kwargs['id'])
- return self.__undelete_request(trans, id)
+ return self.__edit_request( trans, **kwd )
elif operation == "reject":
- id = trans.security.decode_id(kwargs['id'])
- return self.__reject_request(trans, id)
- if 'show_filter' in kwargs.keys():
- if kwargs['show_filter'] == 'All':
- self.request_grid.default_filter = {}
- elif kwargs['show_filter'] == 'Deleted':
- self.request_grid.default_filter = dict(deleted=True)
- else:
- self.request_grid.default_filter = dict(state=kwargs['show_filter'], deleted=False)
- self.request_grid.show_filter = kwargs.get('show_filter', trans.app.model.Request.states.SUBMITTED)
- # Render the list view
- return self.request_grid( trans, **kwargs )
- def __show_request(self, trans, id, messagetype, msg):
+ return self.__reject_request( trans, **kwd )
+ # Render the grid view
+ return self.request_grid( trans, **kwd )
+ def __show_request(self, trans, **kwd):
+ params = util.Params( kwd )
+ msg = util.restore_text( params.get( 'msg', '' ) )
+ messagetype = params.get( 'messagetype', 'done' )
+ add_sample = params.get('add_sample', False)
try:
- request = trans.sa_session.query( trans.app.model.Request ).get( id )
+ request = trans.sa_session.query( trans.app.model.Request ).get( trans.security.decode_id(kwd['id']) )
except:
return trans.response.send_redirect( web.url_for( controller='requests_admin',
action='list',
status='error',
- message="Invalid request ID",
- **kwd) )
+ message="Invalid request ID") )
current_samples = []
for s in request.samples:
current_samples.append([s.name, s.values.content])
+ if add_sample:
+ current_samples.append(['Sample_%i' % (len(current_samples)+1),['' for field in request.type.sample_form.fields]])
return trans.fill_template( '/admin/requests/show_request.mako',
request=request,
- request_details=self.request_details(trans, id),
+ request_details=self.request_details(trans, request.id),
current_samples = current_samples,
sample_copy=self.__copy_sample(current_samples),
details='hide', edit_mode='False',
- msg=msg, messagetype=messagetype)
+ msg=msg, messagetype=messagetype )
- def __edit_request(self, trans, id, **kwd):
+ def __edit_request(self, trans, **kwd):
try:
- request = trans.sa_session.query( trans.app.model.Request ).get( id )
+ request = trans.sa_session.query( trans.app.model.Request ).get( trans.security.decode_id(kwd['id']) )
except:
msg = "Invalid request ID"
log.warn( msg )
@@ -180,61 +296,61 @@
msg=msg,
messagetype=messagetype)
return self.__show_request_form(trans)
- def __delete_request(self, trans, id):
- try:
- request = trans.sa_session.query( trans.app.model.Request ).get( id )
- except:
- msg = "Invalid request ID"
- log.warn( msg )
- return trans.response.send_redirect( web.url_for( controller='requests_admin',
- action='list',
- status='error',
- message=msg,
- **kwd) )
- # change request's submitted field
- if not request.unsubmitted():
- return trans.response.send_redirect( web.url_for( controller='requests_admin',
- action='list',
- status='error',
- message='This request cannot be deleted as it is already been submitted',
- **kwd) )
- request.deleted = True
- trans.sa_session.add( request )
- trans.sa_session.flush()
- kwd = {}
- kwd['id'] = trans.security.encode_id(request.id)
+ def __delete_request(self, trans, **kwd):
+ id_list = util.listify( kwd['id'] )
+ delete_failed = []
+ for id in id_list:
+ try:
+ request = trans.sa_session.query( trans.app.model.Request ).get( trans.security.decode_id(id) )
+ except:
+ msg = "Invalid request ID"
+ log.warn( msg )
+ return trans.response.send_redirect( web.url_for( controller='requests_admin',
+ action='list',
+ status='error',
+ message=msg,
+ **kwd) )
+ # a request cannot be deleted once its submitted
+ if not request.unsubmitted():
+ delete_failed.append(request.name)
+ else:
+ request.deleted = True
+ trans.sa_session.add( request )
+ trans.sa_session.flush()
+ if not len(delete_failed):
+ msg = '%i request(s) has been deleted.' % len(id_list)
+ status = 'done'
+ else:
+ msg = '%i request(s) has been deleted. %i request %s could not be deleted as they have been submitted.' % (len(id_list)-len(delete_failed),
+ len(delete_failed), str(delete_failed))
+ status = 'warning'
return trans.response.send_redirect( web.url_for( controller='requests_admin',
action='list',
- show_filter=trans.app.model.Request.states.UNSUBMITTED,
- status='done',
- message='The request <b>%s</b> has been deleted.' % request.name,
- **kwd) )
- def __undelete_request(self, trans, id):
- try:
- request = trans.sa_session.query( trans.app.model.Request ).get( id )
- except:
- msg = "Invalid request ID"
- log.warn( msg )
- return trans.response.send_redirect( web.url_for( controller='requests_admin',
- action='list',
- status='error',
- message=msg,
- **kwd) )
- # change request's submitted field
- request.deleted = False
- trans.sa_session.add( request )
- trans.sa_session.flush()
- kwd = {}
- kwd['id'] = trans.security.encode_id(request.id)
+ status=status,
+ message=msg) )
+ def __undelete_request(self, trans, **kwd):
+ id_list = util.listify( kwd['id'] )
+ for id in id_list:
+ try:
+ request = trans.sa_session.query( trans.app.model.Request ).get( trans.security.decode_id(id) )
+ except:
+ msg = "Invalid request ID"
+ log.warn( msg )
+ return trans.response.send_redirect( web.url_for( controller='requests_admin',
+ action='list',
+ status='error',
+ message=msg,
+ **kwd) )
+ request.deleted = False
+ trans.sa_session.add( request )
+ trans.sa_session.flush()
return trans.response.send_redirect( web.url_for( controller='requests_admin',
action='list',
- show_filter=trans.app.model.Request.states.UNSUBMITTED,
status='done',
- message='The request <b>%s</b> has been undeleted.' % request.name,
- **kwd) )
- def __submit_request(self, trans, id):
+ message='%i request(s) has been undeleted.' % len(id_list) ) )
+ def __submit_request(self, trans, **kwd):
try:
- request = trans.sa_session.query( trans.app.model.Request ).get( id )
+ request = trans.sa_session.query( trans.app.model.Request ).get( trans.security.decode_id(kwd['id']) )
except:
msg = "Invalid request ID"
log.warn( msg )
@@ -260,15 +376,32 @@
request.state = request.states.SUBMITTED
trans.sa_session.add( request )
trans.sa_session.flush()
- kwd = {}
- kwd['id'] = trans.security.encode_id(request.id)
- kwd['status'] = 'done'
- kwd['message'] = 'The request <b>%s</b> has been submitted.' % request.name
return trans.response.send_redirect( web.url_for( controller='requests_admin',
action='list',
- show_filter=trans.app.model.Request.states.SUBMITTED,
- **kwd) )
-
+ id=trans.security.encode_id(request.id),
+ status='done',
+ message='The request <b>%s</b> has been submitted.' % request.name
+ ) )
+ def __reject_request(self, trans, **kwd):
+ try:
+ request = trans.sa_session.query( trans.app.model.Request ).get( trans.security.decode_id(kwd['id']) )
+ except:
+ msg = "Invalid request ID"
+ log.warn( msg )
+ return trans.response.send_redirect( web.url_for( controller='requests_admin',
+ action='list',
+ status='error',
+ message=msg,
+ **kwd) )
+ # change request's submitted field
+ request.state = request.states.UNSUBMITTED
+ trans.sa_session.add( request )
+ trans.sa_session.flush()
+ return trans.response.send_redirect( web.url_for( controller='requests_admin',
+ action='list',
+ status='done',
+ message='The request <b>%s</b> is now unsubmitted.' % request.name
+ ) )
#
#---- Request Creation ----------------------------------------------------------
#
@@ -325,7 +458,6 @@
if params.get('create_request_button', False) == 'Save':
return trans.response.send_redirect( web.url_for( controller='requests_admin',
action='list',
- show_filter=trans.app.model.Request.states.UNSUBMITTED,
message=msg ,
status='done') )
elif params.get('create_request_samples_button', False) == 'Add samples':
@@ -664,29 +796,6 @@
**new_kwd) )
elif params.get('refresh', False) == 'true':
return self.__edit_request(trans, request.id, **kwd)
- def __reject_request(self, trans, id):
- try:
- request = trans.sa_session.query( trans.app.model.Request ).get( id )
- except:
- msg = "Invalid request ID"
- log.warn( msg )
- return trans.response.send_redirect( web.url_for( controller='requests_admin',
- action='list',
- status='error',
- message=msg,
- **kwd) )
- # change request's submitted field
- request.state = request.states.UNSUBMITTED
- trans.sa_session.add( request )
- trans.sa_session.flush()
- kwd = {}
- kwd['id'] = trans.security.encode_id(request.id)
- kwd['status'] = 'done'
- kwd['message'] = 'The request <b>%s</b> is now unsubmitted.' % request.name
- return trans.response.send_redirect( web.url_for( controller='requests_admin',
- action='list',
- show_filter=trans.app.model.Request.states.UNSUBMITTED,
- **kwd) )
def __update_samples(self, request, **kwd):
'''
This method retrieves all the user entered sample information and
@@ -1049,8 +1158,8 @@
action='list',
operation='show_request',
id=trans.security.encode_id(request.id),
- message='Bar codes have been saved for this request',
- status='done'))
+ msg='Bar codes have been saved for this request',
+ messagetype='done'))
def __set_request_state( self, trans, request ):
# check if all the samples of the current request are in the final state
complete = True
@@ -1138,50 +1247,72 @@
##
@web.expose
@web.require_admin
- def manage_request_types( self, trans, **kwd ):
- params = util.Params( kwd )
- msg = util.restore_text( params.get( 'msg', '' ) )
- messagetype = params.get( 'messagetype', 'done' )
- show_filter = util.restore_text( params.get( 'show_filter', 'Active' ) )
- forms = get_all_forms(trans, all_versions=True)
- request_types_list = trans.sa_session.query( trans.app.model.RequestType )
- if show_filter == 'All':
- request_types = request_types_list
- elif show_filter == 'Deleted':
- request_types = [rt for rt in request_types_list if rt.deleted]
- else:
- request_types = [rt for rt in request_types_list if not rt.deleted]
- return trans.fill_template( '/admin/requests/manage_request_types.mako',
- request_types=request_types,
- forms=forms,
- show_filter=show_filter,
- msg=msg,
- messagetype=messagetype )
+ def manage_request_types( self, trans, **kwd ):
+ if 'operation' in kwd:
+ operation = kwd['operation'].lower()
+ if not kwd.get( 'id', None ):
+ return trans.response.send_redirect( web.url_for( controller='requests_admin',
+ action='manage_request_types',
+ status='error',
+ message="Invalid requesttype ID") )
+ if operation == "view":
+ return self.__view_request_type( trans, **kwd )
+ elif operation == "view_form":
+ return self.__view_form( trans, **kwd )
+ elif operation == "delete":
+ return self.__delete_request_type( trans, **kwd )
+ elif operation == "undelete":
+ return self.__undelete_request_type( trans, **kwd )
+# elif operation == "update":
+# return self.__edit_request( trans, **kwd )
+ # Render the grid view
+ return self.requesttype_grid( trans, **kwd )
+ def __view_request_type(self, trans, **kwd):
+ try:
+ rt = trans.sa_session.query( trans.app.model.RequestType ).get( trans.security.decode_id(kwd['id']) )
+ except:
+ return trans.response.send_redirect( web.url_for( controller='requests_admin',
+ action='manage_request_types',
+ status='error',
+ message="Invalid requesttype ID") )
+ return trans.fill_template( '/admin/requests/view_request_type.mako',
+ request_type=rt,
+ forms=get_all_forms( trans ),
+ states_list=rt.states )
+ def __view_form(self, trans, **kwd):
+ try:
+ fd = trans.sa_session.query( trans.app.model.FormDefinition ).get( trans.security.decode_id(kwd['id']) )
+ except:
+ return trans.response.send_redirect( web.url_for( controller='requests_admin',
+ action='manage_request_types',
+ status='error',
+ message="Invalid form ID") )
+ return trans.fill_template( '/admin/forms/show_form_read_only.mako',
+ form=fd )
+
@web.expose
@web.require_admin
- def request_type( self, trans, **kwd ):
+ def create_request_type( self, trans, **kwd ):
params = util.Params( kwd )
msg = util.restore_text( params.get( 'msg', '' ) )
messagetype = params.get( 'messagetype', 'done' )
- if params.get( 'create', False ):
+ if params.get( 'add_state_button', False ):
+ rt_info, rt_states = self.__create_request_type_form(trans, **kwd)
+ rt_states.append(("", ""))
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 ),
- sample_forms=get_all_forms( trans,
- filter=dict(deleted=False),
- form_type=trans.app.model.FormDefinition.types.SAMPLE ),
+ rt_info_widgets=rt_info,
+ rt_states_widgets=rt_states,
msg=msg,
messagetype=messagetype)
- elif params.get( 'define_states_button', False ):
- return trans.fill_template( '/admin/requests/add_states.mako',
- request_type_name=util.restore_text( params.name ),
- desc=util.restore_text( params.description ),
- num_states=int(util.restore_text( params.num_states )),
- request_form_id=int(util.restore_text( params.request_form_id )),
- sample_form_id=int(util.restore_text( params.sample_form_id )),
+ elif params.get( 'remove_state_button', False ):
+ rt_info, rt_states = self.__create_request_type_form(trans, **kwd)
+ index = int(params.get( 'remove_state_button', '' ).split(" ")[2])
+ del rt_states[index-1]
+ return trans.fill_template( '/admin/requests/create_request_type.mako',
+ rt_info_widgets=rt_info,
+ rt_states_widgets=rt_states,
msg=msg,
- messagetype=messagetype)
+ messagetype=messagetype)
elif params.get( 'save_request_type', False ):
st, msg = self.__save_request_type(trans, **kwd)
if not st:
@@ -1191,32 +1322,65 @@
messagetype='error')
return trans.response.send_redirect( web.url_for( controller='requests_admin',
action='manage_request_types',
- msg='Request type <b>%s</b> has been created' % st.name,
- messagetype='done') )
- elif params.get('view', False):
- rt = trans.sa_session.query( trans.app.model.RequestType ).get( int( util.restore_text( params.id ) ) )
- return trans.fill_template( '/admin/requests/view_request_type.mako',
- request_type=rt,
- forms=get_all_forms( trans ),
- states_list=rt.states,
- deleted=False,
- show_deleted=False,
+ message='Request type <b>%s</b> has been created' % st.name,
+ status='done') )
+ else:
+ rt_info, rt_states = self.__create_request_type_form(trans, **kwd)
+ return trans.fill_template( '/admin/requests/create_request_type.mako',
+ rt_info_widgets=rt_info,
+ rt_states_widgets=rt_states,
msg=msg,
- messagetype=messagetype )
+ messagetype=messagetype)
+ def __create_request_type_form(self, trans, **kwd):
+ request_forms=get_all_forms( trans,
+ 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 )
+ if not len(request_forms) or not len(sample_forms):
+ return [],[]
+ params = util.Params( kwd )
+ rt_info = []
+ rt_info.append(dict(label='Name',
+ widget=TextField('name', 40, util.restore_text( params.get( 'name', '' ) ) ) ))
+ rt_info.append(dict(label='Description',
+ widget=TextField('desc', 40, util.restore_text( params.get( 'desc', '' ) ) ) ))
+
+ rf_selectbox = SelectField('request_form_id')
+ for fd in request_forms:
+ if str(fd.id) == params.get( 'request_form_id', '' ):
+ rf_selectbox.add_option(fd.name, fd.id, selected=True)
+ else:
+ rf_selectbox.add_option(fd.name, fd.id)
+ rt_info.append(dict(label='Request form',
+ widget=rf_selectbox ))
+
+ sf_selectbox = SelectField('sample_form_id')
+ for fd in sample_forms:
+ if str(fd.id) == params.get( 'sample_form_id', '' ):
+ sf_selectbox.add_option(fd.name, fd.id, selected=True)
+ else:
+ sf_selectbox.add_option(fd.name, fd.id)
+ rt_info.append(dict(label='Sample form',
+ widget=sf_selectbox ))
+ # possible sample states
+ rt_states = []
+ i=0
+ while True:
+ if kwd.has_key( 'state_name_%i' % i ):
+ rt_states.append((params.get( 'state_name_%i' % i, '' ),
+ params.get( 'state_desc_%i' % i, '' )))
+ i=i+1
+ else:
+ break
+ return rt_info, rt_states
+
def __save_request_type(self, trans, **kwd):
params = util.Params( kwd )
- num_states = int( util.restore_text( params.get( 'num_states', 0 ) ))
- proceed = True
- for i in range( num_states ):
- if not util.restore_text( params.get( 'state_name_%i' % i, None ) ):
- proceed = False
- break
- if not proceed:
- msg = "All the state name(s) must be completed."
- return None, msg
rt = trans.app.model.RequestType()
- rt.name = util.restore_text( params.name )
- rt.desc = util.restore_text( params.description ) or ""
+ rt.name = util.restore_text( params.get( 'name', '' ) )
+ rt.desc = util.restore_text( params.get( 'desc', '' ) )
rt.request_form = trans.sa_session.query( trans.app.model.FormDefinition ).get( int( params.request_form_id ) )
rt.sample_form = trans.sa_session.query( trans.app.model.FormDefinition ).get( int( params.sample_form_id ) )
trans.sa_session.add( rt )
@@ -1226,37 +1390,50 @@
for ss in ss_list:
trans.sa_session.delete( ss )
trans.sa_session.flush()
- for i in range( num_states ):
- name = util.restore_text( params.get( 'state_name_%i' % i, None ))
- desc = util.restore_text( params.get( 'state_desc_%i' % i, None ))
- ss = trans.app.model.SampleState(name, desc, rt)
- trans.sa_session.add( ss )
+ i=0
+ while True:
+ if kwd.has_key( 'state_name_%i' % i ):
+ name = util.restore_text( params.get( 'state_name_%i' % i, None ))
+ desc = util.restore_text( params.get( 'state_desc_%i' % i, None ))
+ ss = trans.app.model.SampleState(name, desc, rt)
+ trans.sa_session.add( ss )
+ trans.sa_session.flush()
+ i = i + 1
+ else:
+ break
+ msg = "The new request type named '%s' with %s state(s) has been created" % (rt.name, i)
+ return rt, msg
+ def __delete_request_type( self, trans, **kwd ):
+ id_list = util.listify( kwd['id'] )
+ for id in id_list:
+ try:
+ rt = trans.sa_session.query( trans.app.model.RequestType ).get( trans.security.decode_id(id) )
+ except:
+ return trans.response.send_redirect( web.url_for( controller='requests_admin',
+ action='manage_request_types',
+ msg='Invalid request type ID',
+ messagetype='error') )
+ rt.deleted = True
+ trans.sa_session.add( rt )
trans.sa_session.flush()
- msg = "The new request type named '%s' with %s state(s) has been created" % (rt.name, num_states)
- return rt, msg
- @web.expose
- @web.require_admin
- def delete_request_type( self, trans, **kwd ):
- params = util.Params( kwd )
- msg = util.restore_text( params.get( 'msg', '' ) )
- messagetype = params.get( 'messagetype', 'done' )
- rt = trans.sa_session.query( trans.app.model.RequestType ).get( int( util.restore_text( params.request_type_id ) ) )
- rt.deleted = True
- trans.sa_session.flush()
return trans.response.send_redirect( web.url_for( controller='requests_admin',
action='manage_request_types',
- msg='Request type <b>%s</b> has been deleted' % rt.name,
+ msg='%i request type(s) has been deleted' % len(id_list),
messagetype='done') )
- @web.expose
- @web.require_admin
- def undelete_request_type( self, trans, **kwd ):
- params = util.Params( kwd )
- msg = util.restore_text( params.get( 'msg', '' ) )
- messagetype = params.get( 'messagetype', 'done' )
- rt = trans.sa_session.query( trans.app.model.RequestType ).get( int( util.restore_text( params.request_type_id ) ) )
- rt.deleted = False
- trans.sa_session.flush()
+ def __undelete_request_type( self, trans, **kwd ):
+ id_list = util.listify( kwd['id'] )
+ for id in id_list:
+ try:
+ rt = trans.sa_session.query( trans.app.model.RequestType ).get( trans.security.decode_id(id) )
+ except:
+ return trans.response.send_redirect( web.url_for( controller='requests_admin',
+ action='manage_request_types',
+ msg='Invalid request type ID',
+ messagetype='error') )
+ rt.deleted = False
+ trans.sa_session.add( rt )
+ trans.sa_session.flush()
return trans.response.send_redirect( web.url_for( controller='requests_admin',
action='manage_request_types',
- msg='Request type <b>%s</b> has been undeleted' % rt.name,
+ msg='%i request type(s) has been undeleted' % len(id_list),
messagetype='done') )
diff -r 56bb85457bc1 -r ed8972386675 templates/admin/forms/edit_form.mako
--- a/templates/admin/forms/edit_form.mako Tue Nov 17 13:43:34 2009 -0500
+++ b/templates/admin/forms/edit_form.mako Tue Nov 17 14:28:34 2009 -0500
@@ -85,7 +85,7 @@
<div class="toolForm">
<div class="toolFormTitle">Edit form definition "${form.name}"</div>
- <form id="edit_form" name="edit_form" action="${h.url_for( controller='forms', action='edit', form_id=form.id )}" method="post" >
+ <form id="edit_form" name="edit_form" action="${h.url_for( controller='forms', action='manage', operation="Edit", id=trans.security.encode_id(form.current.id) )}" method="post" >
%for label, input in form_details:
<div class="form-row">
<label>${label}</label>
diff -r 56bb85457bc1 -r ed8972386675 templates/admin/forms/grid.mako
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/templates/admin/forms/grid.mako Tue Nov 17 14:28:34 2009 -0500
@@ -0,0 +1,1 @@
+<%inherit file="/grid_base.mako"/>
diff -r 56bb85457bc1 -r ed8972386675 templates/admin/forms/manage_forms.mako
--- a/templates/admin/forms/manage_forms.mako Tue Nov 17 13:43:34 2009 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-<%inherit file="/base.mako"/>
-<%namespace file="/message.mako" import="render_msg" />
-
-<%def name="title()">Manage Form Definitions</%def>
-
-%if msg:
- ${render_msg( msg, messagetype )}
-%endif
-
-## Render a row
-<%def name="render_row( form, ctr )">
- %if ctr % 2 == 1:
- <tr class="odd_row">
- %else:
- <tr>
- %endif
- <td>
- <a href="${h.url_for( controller='forms', action='edit', form_id=form.id, read_only=True )}">${form.name}</a>
- <a id="form-${form.id}-popup" class="popup-arrow" style="display: none;">▼</a>
- %if form.form_definition_current.deleted:
- <div popupmenu="form-${form.id}-popup">
- <a class="action-button" href="${h.url_for( action='undelete', form_id=form.id )}">Undelete</a>
- </div>
- %else:
- <div popupmenu="form-${form.id}-popup">
- <a class="action-button" href="${h.url_for( action='edit', form_id=form.id, show_form=True )}">Edit</a>
- <a class="action-button" confirm="Click OK to delete the form ${form.name}." href="${h.url_for( action='delete', form_id=form.id )}">Delete</a>
- </div>
- %endif
- </td>
- <td><i>${form.desc}</i></td>
- <td>${form.type}</td>
- </tr>
-</%def>
-
-<h2>Forms</h2>
-
-<ul class="manage-table-actions">
- <li>
- <a class="action-button" href="${h.url_for( controller='forms', action='new' )}">
- <span>Create a new form</span></a>
- </li>
-</ul>
-
-%if not all_forms:
- There are no forms.
-%else:
- <div class="grid-header">
- %for i, filter in enumerate( ['Active', 'Deleted', 'All'] ):
- %if i > 0:
- <span>|</span>
- %endif
- %if show_filter == filter:
- <span class="filter"><a href="${h.url_for( controller='forms', action='manage', show_filter=filter )}"><b>${filter}</b></a></span>
- %else:
- <span class="filter"><a href="${h.url_for( controller='forms', action='manage', show_filter=filter )}">${filter}</a></span>
- %endif
- %endfor
- </div>
- <table class="grid">
- <thead>
- <tr>
- <th>Name</th>
- <th>Description</th>
- <th>Type</th>
- </tr>
- </thead>
- <tbody>
- %for ctr, fdc in enumerate( fdc_list ):
- <tr>
- ${render_row( fdc.latest_form, ctr )}
- </tr>
- %endfor
- </tbody>
- </table>
-%endif
diff -r 56bb85457bc1 -r ed8972386675 templates/admin/forms/show_form_read_only.mako
--- a/templates/admin/forms/show_form_read_only.mako Tue Nov 17 13:43:34 2009 -0500
+++ b/templates/admin/forms/show_form_read_only.mako Tue Nov 17 14:28:34 2009 -0500
@@ -66,14 +66,14 @@
<div class="toolFormTitle">${form.name} - <i> ${form.desc}</i> (${form.type})
<a id="form-${form.id}-popup" class="popup-arrow" style="display: none;">▼</a>
<div popupmenu="form-${form.id}-popup">
- <a class="action-button" href="${h.url_for( action='edit', form_id=form.id, show_form=True )}">Edit</a>
+ <a class="action-button" href="${h.url_for( controller='forms', action='manage', operation='Edit', id=trans.security.encode_id(form.current.id) )}">Edit</a>
</div>
</div>
%else:
<div class="toolFormTitle">${form.name} (${form.type})
<a id="form-${form.id}-popup" class="popup-arrow" style="display: none;">▼</a>
<div popupmenu="form-${form.id}-popup">
- <a class="action-button" href="${h.url_for( action='edit', form_id=form.id, show_form=True )}">Edit</a>
+ <a class="action-button" href="${h.url_for( controller='forms', action='manage', operation='Edit', id=trans.security.encode_id(form.current.id) )}">Edit</a>
</div>
</div>
%endif
diff -r 56bb85457bc1 -r ed8972386675 templates/admin/requests/create_request_type.mako
--- a/templates/admin/requests/create_request_type.mako Tue Nov 17 13:43:34 2009 -0500
+++ b/templates/admin/requests/create_request_type.mako Tue Nov 17 14:28:34 2009 -0500
@@ -6,63 +6,59 @@
${render_msg( msg, messagetype )}
%endif
+<%def name="render_state( element_count, state_name, state_desc )">
+ <div class="repeat-group-item">
+ <div class="form-row">
+ <label>${1+element_count}. State name:</label>
+ <input type="text" name="state_name_${element_count}" value="${state_name}" size="40"/>
+ <input type="submit" name="remove_state_button" value="Remove state ${1+element_count}"/>
+ </div>
+ <div class="form-row">
+ <label>Description:</label>
+ <input type="text" name="state_desc_${element_count}" value="${state_desc}" size="40"/>
+ <div class="toolParamHelp" style="clear: both;">
+ optional
+ </div>
+
+ </div>
+ <div style="clear: both"></div>
+ </div>
+</%def>
+
<div class="toolForm">
<div class="toolFormTitle">Create a new request type</div>
- %if not request_forms or not sample_forms:
+ %if not rt_info_widgets:
Create a request & sample form definition first to create a new request type.
%else:
- <div class="toolFormBody">
- <form name="create_request_type" action="${h.url_for( controller='requests_admin', action='request_type')}" method="post" >
+ <form name="create_request_type" action="${h.url_for( controller='requests_admin', action='create_request_type')}" method="post" >
+ %for rt_info in rt_info_widgets:
<div class="form-row">
- <label>Name:</label>
+ <label>${rt_info['label']}</label>
<div style="float: left; width: 250px; margin-right: 10px;">
- <input type="text" name="name" value="New Request Type" size="40"/>
+ ${rt_info['widget'].get_html()}
</div>
<div style="clear: both"></div>
</div>
- <div class="form-row">
- <label>Description:</label>
- <div style="float: left; width: 250px; margin-right: 10px;">
- <input type="text" name="description" value="" size="40"/>
- </div>
- <div style="clear: both"></div>
+ %endfor
+ <div class="toolFormTitle">Possible sample states</div>
+ %if len(rt_states_widgets):
+ %for index, info in enumerate(rt_states_widgets):
+ ${render_state( index, info[0], info[1] )}
+ %endfor
+ %endif
+ <div class="form-row">
+ <input type="submit" name="add_state_button" value="Add state"/>
+ </div>
+ <div class="form-row">
+ <div style="float: left; width: 250px; margin-right: 10px;">
+ <input type="hidden" name="new" value="submitted" size="40"/>
</div>
- <div class="form-row">
- <label>
- Request Form definition:
- </label>
- <select name="request_form_id">
- %for form in request_forms:
- <option value="${form.id}">${form.name}</option>
- %endfor
- </select>
- </div>
- <div class="form-row">
- <label>
- Sample Form definition:
- </label>
- <select name="sample_form_id">
- %for form in sample_forms:
- <option value="${form.id}">${form.name}</option>
- %endfor
- </select>
- </div>
- <div class="form-row">
- <label>Number of sample states:</label>
- <div style="float: left; width: 250px; margin-right: 10px;">
- <input type="text" size="3" name="num_states" value="1"/>
- </div>
- </div>
- <div class="form-row">
- <div style="float: left; width: 250px; margin-right: 10px;">
- <input type="hidden" name="new" value="submitted" size="40"/>
- </div>
- <div style="clear: both"></div>
- </div>
- <div class="form-row">
- <input type="submit" name="define_states_button" value="Define states"/>
- </div>
- </form>
- </div>
+ <div style="clear: both"></div>
+ </div>
+ <div class="form-row">
+ <input type="submit" name="save_request_type" value="Save"/>
+ </div>
+ </form>
+
%endif
</div>
\ No newline at end of file
diff -r 56bb85457bc1 -r ed8972386675 templates/admin/requests/grid.mako
--- a/templates/admin/requests/grid.mako Tue Nov 17 13:43:34 2009 -0500
+++ b/templates/admin/requests/grid.mako Tue Nov 17 14:28:34 2009 -0500
@@ -1,217 +1,1 @@
-<%inherit file="/base.mako"/>
-<%namespace file="/message.mako" import="render_msg" />
-
-<%def name="title()">Browse Requests</%def>
-
-%if message:
- <p>
- <div class="${message_type}message transient-message">${message}</div>
- <div style="clear: both"></div>
- </p>
-%endif
-
-<%def name="javascripts()">
- ${parent.javascripts()}
- <script type="text/javascript">
- ## TODO: generalize and move into galaxy.base.js
- $(document).ready(function() {
- $(".grid").each( function() {
- var grid = this;
- var checkboxes = $(this).find("input.grid-row-select-checkbox");
- var update = $(this).find( "span.grid-selected-count" );
- $(checkboxes).each( function() {
- $(this).change( function() {
- var n = $(checkboxes).filter("[checked]").size();
- update.text( n );
- });
- })
- });
- });
- ## Can this be moved into base.mako?
- %if refresh_frames:
- %if 'masthead' in refresh_frames:
- ## Refresh masthead == user changes (backward compatibility)
- if ( parent.user_changed ) {
- %if trans.user:
- parent.user_changed( "${trans.user.email}", ${int( app.config.is_admin_user( trans.user ) )} );
- %else:
- parent.user_changed( null, false );
- %endif
- }
- %endif
- %if 'history' in refresh_frames:
- if ( parent.frames && parent.frames.galaxy_history ) {
- parent.frames.galaxy_history.location.href="${h.url_for( controller='root', action='history')}";
- if ( parent.force_right_panel ) {
- parent.force_right_panel( 'show' );
- }
- }
- %endif
- %if 'tools' in refresh_frames:
- if ( parent.frames && parent.frames.galaxy_tools ) {
- parent.frames.galaxy_tools.location.href="${h.url_for( controller='root', action='tool_menu')}";
- if ( parent.force_left_panel ) {
- parent.force_left_panel( 'show' );
- }
- }
- %endif
- %endif
- </script>
-</%def>
-
-<%def name="stylesheets()">
- <link href="${h.url_for('/static/style/base.css')}" rel="stylesheet" type="text/css" />
- <style>
- ## Not generic to all grids -- move to base?
- .count-box {
- min-width: 1.1em;
- padding: 5px;
- border-width: 1px;
- border-style: solid;
- text-align: center;
- display: inline-block;
- }
- </style>
-</%def>
-
-<div class="grid-header">
- <h2>${grid.title}</h2>
- %if trans.sa_session.query( trans.app.model.Request ).count():
- ##<span class="title">Filter:</span>
- %for i, filter in enumerate( grid.standard_filters ):
- %if i > 0:
- <span>|</span>
- %endif
- %if grid.show_filter == filter.label:
- <span class="filter"><a href="${h.url_for( controller='requests_admin', action='list', show_filter=filter.label )}"><b>${filter.label}</b></a></span>
- %else:
- <span class="filter"><a href="${h.url_for( controller='requests_admin', action='list', show_filter=filter.label )}">${filter.label}</a></span>
- %endif
- %endfor
- %endif
-</div>
-
-<ul class="manage-table-actions">
- <li>
- <a class="action-button" href="${h.url_for( controller='requests_admin', action='new', select_request_type=True )}">
- <img src="${h.url_for('/static/images/silk/add.png')}" />
- <span>Create a new request</span></a>
- </li>
-</ul>
-
-%if not len(query.all()):
- There are no requests.
-%else:
-<form name="history_actions" action="${url()}" method="post" >
- <table class="grid">
- <thead>
- <tr>
- ##<th></th>
- %for column in grid.columns:
- %if column.visible:
- <%
- href = ""
- extra = ""
- if column.sortable:
- if sort_key == column.key:
- if sort_order == "asc":
- href = url( sort=( "-" + column.key ) )
- extra = "↓"
- else:
- href = url( sort=( column.key ) )
- extra = "↑"
- else:
- href = url( sort=column.key )
- %>
- <th\
- %if column.ncells > 1:
- colspan="${column.ncells}"
- %endif
- >
- %if href:
- <a href="${href}">${column.label}</a>
- %else:
- ${column.label}
- %endif
- <span>${extra}</span>
- </th>
- %endif
- %endfor
- <th></th>
- </tr>
- </thead>
- <tbody>
- %for i, item in enumerate( query ):
- <tr \
- %if current_item == item:
- class="current" \
- %endif
- >
- ## Item selection column
- ##<td style="width: 1.5em;">
- ## <input type="checkbox" name="id" value=${trans.security.encode_id( item.id )} class="grid-row-select-checkbox" />
- ##</td>
- ## Data columns
- %for column in grid.columns:
- %if column.visible:
- <%
- # Link
- if column.link and column.link( item ):
- href = url( **column.link( item ) )
- else:
- href = None
- # Value (coerced to list so we can loop)
- value = column.get_value( trans, grid, item )
- if column.ncells == 1:
- value = [ value ]
- %>
- %for cellnum, v in enumerate( value ):
- <%
- # Attach popup menu?
- if column.attach_popup and cellnum == 0:
- extra = '<a id="grid-%d-popup" class="popup-arrow" style="display: none;">▼</a>' % i
- else:
- extra = ""
- %>
- %if href:
- <td><a href="${href}">${v}</a> ${extra}</td>
- %else:
- <td >${v}${extra}</td>
- %endif
- </td>
- %endfor
- %endif
- %endfor
- ## Actions column
- <td>
- <div popupmenu="grid-${i}-popup">
- %for operation in grid.operations:
- %if operation.allowed( item ):
- %if operation.label == 'Submit':
- <a class="action-button" confirm="More samples cannot be added to this request once it is submitted. Click OK to submit." href="${url( operation=operation.label, id=item.id )}">${operation.label}</a>
- %else:
- <a class="action-button" href="${url( operation=operation.label, id=item.id )}">${operation.label}</a>
- %endif
- %endif
- %endfor
- </div>
- </td>
- </tr>
- %endfor
- </tbody>
-## <tfoot>
-## <tr>
-## <td></td>
-## <td colspan="100">
-## For <span class="grid-selected-count"></span> selected requests:
-## %for operation in grid.operations:
-## %if operation.allow_multiple:
-## <input type="submit" name="operation" value="${operation.label}" class="action-button">
-## %endif
-## %endfor
-## </td>
-## </tr>
-## </tfoot>
- </table>
-</form>
-%endif
\ No newline at end of file
+<%inherit file="/grid_base.mako"/>
\ No newline at end of file
diff -r 56bb85457bc1 -r ed8972386675 templates/admin/requests/manage_request_types.mako
--- a/templates/admin/requests/manage_request_types.mako Tue Nov 17 13:43:34 2009 -0500
+++ b/templates/admin/requests/manage_request_types.mako Tue Nov 17 14:28:34 2009 -0500
@@ -1,68 +1,1 @@
-<%inherit file="/base.mako"/>
-<%namespace file="/message.mako" import="render_msg" />
-
-<%def name="title()">request Types</%def>
-
-%if msg:
- ${render_msg( msg, messagetype )}
-%endif
-
-<h2>
- Request Types
-</h2>
-
-<ul class="manage-table-actions">
- <li>
- <a class="action-button" href="${h.url_for( controller='requests_admin', action='request_type', create=True )}"><span>Create a new request type</span></a>
- </li>
-</ul>
-
-<div class="grid-header">
- ##<span class="title">Filter:</span>
- %for i, filter in enumerate( ['Active', 'Deleted', 'All'] ):
- %if i > 0:
- <span>|</span>
- %endif
- %if show_filter == filter:
- <span class="filter"><a href="${h.url_for( controller='requests_admin', action='manage_request_types', show_filter=filter )}"><b>${filter}</b></a></span>
- %else:
- <span class="filter"><a href="${h.url_for( controller='requests_admin', action='manage_request_types', show_filter=filter )}">${filter}</a></span>
- %endif
- %endfor
-</div>
-%if not request_types:
- There are no request types.
-%else:
- <table class="grid">
- <thead>
- <tr>
- <th>Name</th>
- <th>Description</th>
- <th>Request Form</th>
- <th>Sample Form</th>
- </tr>
- </thead>
- <tbody>
- %for request_type in request_types:
- <tr>
- <td>
- <a href="${h.url_for( controller='requests_admin', action='request_type', view='True', id=request_type.id)}">${request_type.name}</a>
- <a id="request_type-${request_type.id}-popup" class="popup-arrow" style="display: none;">▼</a>
- %if request_type.deleted:
- <div popupmenu="request_type-${request_type.id}-popup">
- <a class="action-button" href="${h.url_for( action='undelete_request_type', request_type_id=request_type.id )}">Undelete</a>
- </div>
- %else:
- <div popupmenu="request_type-${request_type.id}-popup">
- <a class="action-button" confirm="Click OK to delete the request type ${request_type.name}." href="${h.url_for( action='delete_request_type', request_type_id=request_type.id )}">Delete</a>
- </div>
- %endif
- </td>
- <td><i>${request_type.desc}</i></td>
- <td><a href="${h.url_for( controller='forms', action='edit', form_id=request_type.request_form.id, read_only=True)}">${request_type.request_form.name}</a></td>
- <td><a href="${h.url_for( controller='forms', action='edit', form_id=request_type.sample_form.id, read_only=True)}">${request_type.sample_form.name}</a></td>
- </tr>
- %endfor
- </tbody>
- </table>
-%endif
\ No newline at end of file
+<%inherit file="/grid_base.mako"/>
\ No newline at end of file
diff -r 56bb85457bc1 -r ed8972386675 templates/admin/requests/show_request.mako
--- a/templates/admin/requests/show_request.mako Tue Nov 17 13:43:34 2009 -0500
+++ b/templates/admin/requests/show_request.mako Tue Nov 17 14:28:34 2009 -0500
@@ -127,7 +127,7 @@
<div class="form-row">
<ul class="manage-table-actions">
<li>
- <a class="action-button" href="${h.url_for( controller='requests_admin', action='edit', show=True, request_id=request.id)}">
+ <a class="action-button" href="${h.url_for( controller='requests_admin', action='list', operation='Edit', id=trans.security.encode_id(request.id))}">
<span>Edit request details</span></a>
</li>
</ul>
diff -r 56bb85457bc1 -r ed8972386675 templates/admin/requests/view_request_type.mako
--- a/templates/admin/requests/view_request_type.mako Tue Nov 17 13:43:34 2009 -0500
+++ b/templates/admin/requests/view_request_type.mako Tue Nov 17 14:28:34 2009 -0500
@@ -7,43 +7,37 @@
%endif
<div class="toolForm">
- <div class="toolFormTitle">View request type details</div>
- <div class="toolFormBody">
- <form name="library">
- <div class="form-row">
- <label>Name</label>
- ${request_type.name}
+ <div class="toolFormTitle">Request type information</div>
+ <form name="library">
+ <div class="form-row">
+ <label>Name</label>
+ ${request_type.name}
+ <div style="clear: both"></div>
+ </div>
+ <div class="form-row">
+ <label>Description</label>
+ ${request_type.desc}
+ <div style="clear: both"></div>
+ </div>
+ <div class="form-row">
+ <label>
+ Request Form definition
+ </label>
+ ${request_type.request_form.name}
+ </div>
+ <div class="form-row">
+ <label>
+ Sample Form definition
+ </label>
+ ${request_type.sample_form.name}
+ </div>
+ <div class="toolFormTitle">Possible sample states</div>
+ %for element_count, state in enumerate(states_list):
+ <div class="form-row">
+ <label>${1+element_count}. ${state.name}</label>
+ ${state.desc}
+ </div>
<div style="clear: both"></div>
- </div>
- <div class="form-row">
- <label>Description</label>
- ${request_type.desc}
- <div style="clear: both"></div>
- </div>
- <div class="form-row">
- <label>
- Request Form definition
- </label>
- ${request_type.request_form.name}
- </div>
- <div class="form-row">
- <label>
- Sample Form definition
- </label>
- ${request_type.sample_form.name}
- </div>
- <div class="form-row">
- <label>
- Possible states
- </label>
- %for element_count, state in enumerate(states_list):
- <div class="form-row">
- <label>${1+element_count}. ${state.name}</label>
- ${state.desc}
- </div>
- <div style="clear: both"></div>
- %endfor
- </div>
- </form>
- </div>
+ %endfor
+ </form>
</div>
\ No newline at end of file
diff -r 56bb85457bc1 -r ed8972386675 templates/requests/grid.mako
--- a/templates/requests/grid.mako Tue Nov 17 13:43:34 2009 -0500
+++ b/templates/requests/grid.mako Tue Nov 17 14:28:34 2009 -0500
@@ -1,217 +1,1 @@
-<%inherit file="/base.mako"/>
-<%namespace file="/message.mako" import="render_msg" />
-
-<%def name="title()">Browse Samples</%def>
-
-%if message:
- <p>
- <div class="${message_type}message transient-message">${message}</div>
- <div style="clear: both"></div>
- </p>
-%endif
-
-<%def name="javascripts()">
- ${parent.javascripts()}
- <script type="text/javascript">
- ## TODO: generalize and move into galaxy.base.js
- $(document).ready(function() {
- $(".grid").each( function() {
- var grid = this;
- var checkboxes = $(this).find("input.grid-row-select-checkbox");
- var update = $(this).find( "span.grid-selected-count" );
- $(checkboxes).each( function() {
- $(this).change( function() {
- var n = $(checkboxes).filter("[checked]").size();
- update.text( n );
- });
- })
- });
- });
- ## Can this be moved into base.mako?
- %if refresh_frames:
- %if 'masthead' in refresh_frames:
- ## Refresh masthead == user changes (backward compatibility)
- if ( parent.user_changed ) {
- %if trans.user:
- parent.user_changed( "${trans.user.email}", ${int( app.config.is_admin_user( trans.user ) )} );
- %else:
- parent.user_changed( null, false );
- %endif
- }
- %endif
- %if 'history' in refresh_frames:
- if ( parent.frames && parent.frames.galaxy_history ) {
- parent.frames.galaxy_history.location.href="${h.url_for( controller='root', action='history')}";
- if ( parent.force_right_panel ) {
- parent.force_right_panel( 'show' );
- }
- }
- %endif
- %if 'tools' in refresh_frames:
- if ( parent.frames && parent.frames.galaxy_tools ) {
- parent.frames.galaxy_tools.location.href="${h.url_for( controller='root', action='tool_menu')}";
- if ( parent.force_left_panel ) {
- parent.force_left_panel( 'show' );
- }
- }
- %endif
- %endif
- </script>
-</%def>
-
-<%def name="stylesheets()">
- <link href="${h.url_for('/static/style/base.css')}" rel="stylesheet" type="text/css" />
- <style>
- ## Not generic to all grids -- move to base?
- .count-box {
- min-width: 1.1em;
- padding: 5px;
- border-width: 1px;
- border-style: solid;
- text-align: center;
- display: inline-block;
- }
- </style>
-</%def>
-
-<div class="grid-header">
- <h2>${grid.title}</h2>
- %if len(trans.user.requests):
- ##<span class="title">Filter:</span>
- %for i, filter in enumerate( grid.standard_filters ):
- %if i > 0:
- <span>|</span>
- %endif
- %if grid.show_filter == filter.label:
- <span class="filter"><a href="${h.url_for( controller='requests', action='list', show_filter=filter.label )}"><b>${filter.label}</b></a></span>
- %else:
- <span class="filter"><a href="${h.url_for( controller='requests', action='list', show_filter=filter.label )}">${filter.label}</a></span>
- %endif
- %endfor
- %endif
-</div>
-
-<ul class="manage-table-actions">
- <li>
- <a class="action-button" href="${h.url_for( controller='requests', action='new', select_request_type=True )}">
- <img src="${h.url_for('/static/images/silk/add.png')}" />
- <span>Create a new request</span></a>
- </li>
-</ul>
-
-%if not len(query.all()):
- There are no request(s).
-%else:
-<form name="history_actions" action="${url()}" method="post" >
- <table class="grid">
- <thead>
- <tr>
- ##<th></th>
- %for column in grid.columns:
- %if column.visible:
- <%
- href = ""
- extra = ""
- if column.sortable:
- if sort_key == column.key:
- if sort_order == "asc":
- href = url( sort=( "-" + column.key ) )
- extra = "↓"
- else:
- href = url( sort=( column.key ) )
- extra = "↑"
- else:
- href = url( sort=column.key )
- %>
- <th\
- %if column.ncells > 1:
- colspan="${column.ncells}"
- %endif
- >
- %if href:
- <a href="${href}">${column.label}</a>
- %else:
- ${column.label}
- %endif
- <span>${extra}</span>
- </th>
- %endif
- %endfor
- <th></th>
- </tr>
- </thead>
- <tbody>
- %for i, item in enumerate( query ):
- <tr \
- %if current_item == item:
- class="current" \
- %endif
- >
- ## Item selection column
- ##<td style="width: 1.5em;">
- ## <input type="checkbox" name="id" value=${trans.security.encode_id( item.id )} class="grid-row-select-checkbox" />
- ##</td>
- ## Data columns
- %for column in grid.columns:
- %if column.visible:
- <%
- # Link
- if column.link and column.link( item ):
- href = url( **column.link( item ) )
- else:
- href = None
- # Value (coerced to list so we can loop)
- value = column.get_value( trans, grid, item )
- if column.ncells == 1:
- value = [ value ]
- %>
- %for cellnum, v in enumerate( value ):
- <%
- # Attach popup menu?
- if column.attach_popup and cellnum == 0:
- extra = '<a id="grid-%d-popup" class="popup-arrow" style="display: none;">▼</a>' % i
- else:
- extra = ""
- %>
- %if href:
- <td><a href="${href}">${v}</a> ${extra}</td>
- %else:
- <td >${v}${extra}</td>
- %endif
- </td>
- %endfor
- %endif
- %endfor
- ## Actions column
- <td>
- <div popupmenu="grid-${i}-popup">
- %for operation in grid.operations:
- %if operation.allowed( item ):
- %if operation.label == 'Submit':
- <a class="action-button" confirm="More samples cannot be added to this request once it is submitted. Click OK to submit." href="${url( operation=operation.label, id=item.id)}">${operation.label}</a>
- %else:
- <a class="action-button" href="${url( operation=operation.label, id=item.id )}">${operation.label}</a>
- %endif
- %endif
- %endfor
- </div>
- </td>
- </tr>
- %endfor
- </tbody>
- <tfoot>
-## <tr>
-## <td></td>
-## <td colspan="100">
-## For <span class="grid-selected-count"></span> selected requests:
-## %for operation in grid.operations:
-## %if operation.allow_multiple:
-## <input type="submit" name="operation" value="${operation.label}" class="action-button">
-## %endif
-## %endfor
-## </td>
-## </tr>
- </tfoot>
- </table>
-</form>
-%endif
+<%inherit file="/grid_base.mako"/>
\ No newline at end of file
diff -r 56bb85457bc1 -r ed8972386675 templates/requests/show_request.mako
--- a/templates/requests/show_request.mako Tue Nov 17 13:43:34 2009 -0500
+++ b/templates/requests/show_request.mako Tue Nov 17 14:28:34 2009 -0500
@@ -119,7 +119,7 @@
<div class="form-row">
<ul class="manage-table-actions">
<li>
- <a class="action-button" href="${h.url_for( controller='requests', action='edit', show=True, request_id=request.id)}">
+ <a class="action-button" href="${h.url_for( controller='requests', action='list', operation='Edit', id=trans.security.encode_id(request.id) )}">
<span>Edit request details</span></a>
</li>
</ul>
diff -r 56bb85457bc1 -r ed8972386675 test/base/twilltestcase.py
--- a/test/base/twilltestcase.py Tue Nov 17 13:43:34 2009 -0500
+++ b/test/base/twilltestcase.py Tue Nov 17 14:28:34 2009 -0500
@@ -1169,24 +1169,24 @@
self.check_page_for_string( desc )
self.check_page_for_string( formtype )
self.home()
- def edit_form( self, form_id, form_name, new_form_name="Form One's Name (Renamed)", new_form_desc="This is Form One's description (Re-described)"):
+ def edit_form( self, form_current_id, form_name, new_form_name="Form One's Name (Renamed)", new_form_desc="This is Form One's description (Re-described)"):
"""
Edit form details; name & description
"""
self.home()
- self.visit_url( "%s/forms/edit?form_id=%i&show_form=True" % (self.url, form_id) )
+ self.visit_url( "%s/forms/manage?sort=create_time&f-name=All&f-desc=All&f-deleted=False&operation=Edit&id=%s" % ( self.url, self.security.encode_id(form_current_id) ) )
self.check_page_for_string( 'Edit form definition "%s"' % form_name )
tc.fv( "1", "name", new_form_name )
tc.fv( "1", "description", new_form_desc )
tc.submit( "save_changes_button" )
self.check_page_for_string( "The form '%s' has been updated with the changes." % new_form_name )
self.home()
- def form_add_field( self, form_id, form_name, form_desc, form_type, field_index, fields):
+ def form_add_field( self, form_current_id, form_name, form_desc, form_type, field_index, fields):
"""
Add a new fields to the form definition
"""
self.home()
- self.visit_url( "%s/forms/edit?form_id=%i&show_form=True" % (self.url, form_id) )
+ self.visit_url( "%s/forms/manage?sort=create_time&f-name=All&f-desc=All&f-deleted=False&operation=Edit&id=%s" % ( self.url, self.security.encode_id(form_current_id) ) )
self.check_page_for_string( 'Edit form definition "%s"' % form_name)
for i, field in enumerate(fields):
index = i+field_index
@@ -1198,8 +1198,8 @@
if field['type'] == 'SelectField':
options = ''
for option_index, option in enumerate(field['selectlist']):
- url_str = "%s/forms/edit?description=%s&form_id=%i&form_type_selectbox=%s&addoption_%i=Add&name=%s&field_name_%i=%s&field_helptext_%i=%s&field_type_%i=%s" % \
- (self.url, form_desc.replace(" ", "+"), form_id, form_type.replace(" ", "+"),
+ url_str = "%s/forms/manage?operation=Edit&description=%s&id=%s&form_type_selectbox=%s&addoption_%i=Add&name=%s&field_name_%i=%s&field_helptext_%i=%s&field_type_%i=%s" % \
+ (self.url, form_desc.replace(" ", "+"), self.security.encode_id(form_current_id), form_type.replace(" ", "+"),
index, form_name.replace(" ", "+"), index, field['name'].replace(" ", "+"),
index, field['desc'].replace(" ", "+"), index, field['type'])
self.visit_url( url_str + options )
@@ -1214,7 +1214,7 @@
Remove a field from the form definition
"""
self.home()
- self.visit_url( "%s/forms/edit?form_id=%i&show_form=True" % (self.url, form_id) )
+ self.visit_url( "%s/forms/manage?operation=Edit&form_id=%i&show_form=True" % (self.url, form_id) )
self.check_page_for_string( 'Edit form definition "%s"' % form_name)
tc.submit( "remove_button" )
tc.submit( "save_changes_button" )
@@ -1222,18 +1222,26 @@
self.check_page_for_string( check_str )
self.home()
# Requests stuff
+ def check_request_grid(self, state, request_name, deleted=False):
+ self.home()
+ self.visit_url('%s/requests/list?sort=create_time&f-state=%s&f-deleted=%s' \
+ % (self.url, state, str(deleted)))
+ self.check_page_for_string( request_name )
+ def check_request_admin_grid(self, state, request_name, deleted=False):
+ self.home()
+ self.visit_url('%s/requests_admin/list?sort=create_time&f-state=%s&f-deleted=%s' \
+ % (self.url, state, str(deleted)))
+ self.check_page_for_string( request_name )
def create_request_type( self, name, desc, request_form_id, sample_form_id, states ):
self.home()
- self.visit_url( "%s/requests_admin/request_type?create=True" % self.url )
+ self.visit_url( "%s/requests_admin/create_request_type" % self.url )
self.check_page_for_string( 'Create a new request type' )
tc.fv( "1", "name", name )
- tc.fv( "1", "description", desc )
+ tc.fv( "1", "desc", desc )
tc.fv( "1", "request_form_id", request_form_id )
tc.fv( "1", "sample_form_id", sample_form_id )
- tc.fv( "1", "num_states", str( len( states ) ) )
- tc.submit( "define_states_button" )
- self.check_page_for_string( "Create %i states for the '%s' request type" % ( len(states), name ))
for index, state in enumerate(states):
+ tc.submit( "add_state_button" )
tc.fv("1", "state_name_%i" % index, state[0])
tc.fv("1", "state_desc_%i" % index, state[1])
tc.submit( "save_request_type" )
@@ -1255,7 +1263,7 @@
self.check_page_for_string( desc )
def edit_request( self, request_id, name, new_name, new_desc, new_library_id, new_folder_id, new_fields):
self.home()
- self.visit_url( "%s/requests/edit?request_id=%i&show=True" % (self.url, request_id) )
+ self.visit_url( "%s/requests/list?operation=Edit&id=%s" % (self.url, self.security.encode_id(request_id) ) )
self.check_page_for_string( 'Edit request "%s"' % name )
tc.fv( "1", "name", new_name )
tc.fv( "1", "desc", new_desc )
diff -r 56bb85457bc1 -r ed8972386675 test/functional/test_forms_and_requests.py
--- a/test/functional/test_forms_and_requests.py Tue Nov 17 13:43:34 2009 -0500
+++ b/test/functional/test_forms_and_requests.py Tue Nov 17 14:28:34 2009 -0500
@@ -29,6 +29,7 @@
.filter( galaxy.model.FormDefinitionCurrent.table.c.deleted==False ) \
.order_by( galaxy.model.FormDefinitionCurrent.table.c.create_time.desc() )
for fdc in fdc_list:
+ sa_session.refresh( fdc )
sa_session.refresh( fdc.latest_form )
if form_name == fdc.latest_form.name:
return fdc.latest_form
@@ -51,7 +52,7 @@
# edit form & add few more fields
new_name = "Request Form (Renamed)"
new_desc = "This is Form One's Re-described"
- self.edit_form( form_one.id, form_one.name, new_form_name=new_name, new_form_desc=new_desc )
+ self.edit_form( form_one.current.id, form_one.name, new_form_name=new_name, new_form_desc=new_desc )
self.home()
self.visit_page( 'forms/manage' )
self.check_page_for_string( new_name )
@@ -73,13 +74,13 @@
type='TextField',
required='required')]
form_one = get_latest_form(form_one_name)
- self.form_add_field(form_one.id, form_one.name, form_one.desc, form_one.type, field_index=len(form_one.fields), fields=fields)
- form_one_latest = get_latest_form(form_one_name)
+ self.form_add_field(form_one.current.id, form_one.name, form_one.desc, form_one.type, field_index=len(form_one.fields), fields=fields)
+ form_one_latest = get_latest_form(form_one_name)
assert len(form_one_latest.fields) == len(form_one.fields)+len(fields)
def test_015_create_sample_form( self ):
"""Testing creating another form (for samples)"""
global form_two_name
- desc = "This is Form One's description"
+ desc = "This is Form Two's description"
formtype = 'Sequencing Sample Form'
self.create_form( name=form_two_name, desc=desc, formtype=formtype )
self.home()
@@ -207,16 +208,12 @@
request_one.desc+' (Re-described)', library_one.id, folder_one.id, fields)
sa_session.refresh( request_one )
# check if the request is showing in the 'unsubmitted' filter
- self.home()
- self.visit_url( '%s/requests/list?show_filter=Unsubmitted' % self.url )
- self.check_page_for_string( request_one.name )
+ self.check_request_grid(state='Unsubmitted', request_name=request_one.name)
# submit the request
self.submit_request( request_one.id, request_one.name )
sa_session.refresh( request_one )
# check if the request is showing in the 'submitted' filter
- self.home()
- self.visit_url( '%s/requests/list?show_filter=Submitted' % self.url )
- self.check_page_for_string( request_one.name )
+ self.check_request_grid(state='Submitted', request_name=request_one.name)
# check if the request's state is now set to 'submitted'
assert request_one.state is not request_one.states.SUBMITTED, "The state of the request '%s' should be set to '%s'" \
% ( request_one.name, request_one.states.SUBMITTED )
@@ -225,9 +222,7 @@
# goto admin manage requests page
self.logout()
self.login( email='test(a)bx.psu.edu' )
- self.home()
- self.visit_page( 'requests_admin/list' )
- self.check_page_for_string( request_one.name )
+ self.check_request_admin_grid(state='Submitted', request_name=request_one.name)
self.visit_url( "%s/requests_admin/list?sort=-create_time&operation=show_request&id=%s" \
% ( self.url, self.security.encode_id( request_one.id ) ))
self.check_page_for_string( 'Sequencing Request "%s"' % request_one.name )
@@ -240,9 +235,10 @@
self.change_sample_state( sample.name, sample.id, request_type.states[2].id, request_type.states[2].name )
self.home()
sa_session.refresh( request_one )
+ self.logout()
+ self.login( email='test1(a)bx.psu.edu' )
# check if the request's state is now set to 'complete'
- self.visit_url('%s/requests_admin/list?show_filter=Complete' % self.url)
- self.check_page_for_string( request_one.name )
+ self.check_request_grid(state='Complete', request_name=request_one.name)
assert request_one.state is not request_one.states.COMPLETE, "The state of the request '%s' should be set to '%s'" \
% ( request_one.name, request_one.states.COMPLETE )
def test_040_admin_create_request_on_behalf_of_regular_user( self ):
@@ -262,9 +258,7 @@
galaxy.model.Request.table.c.deleted==False ) ) \
.first()
# check if the request is showing in the 'unsubmitted' filter
- self.home()
- self.visit_url( '%s/requests_admin/list?show_filter=Unsubmitted' % self.url )
- self.check_page_for_string( request_two.name )
+ self.check_request_admin_grid(state='Unsubmitted', request_name=request_two.name)
# check if the request's state is now set to 'unsubmitted'
assert request_two.state is not request_two.states.UNSUBMITTED, "The state of the request '%s' should be set to '%s'" \
% ( request_two.name, request_two.states.UNSUBMITTED )
@@ -277,17 +271,13 @@
self.submit_request_as_admin( request_two.id, request_two.name )
sa_session.refresh( request_two )
# check if the request is showing in the 'submitted' filter
- self.home()
- self.visit_url( '%s/requests_admin/list?show_filter=Submitted' % self.url )
- self.check_page_for_string( request_two.name )
+ self.check_request_admin_grid(state='Submitted', request_name=request_two.name)
# check if the request's state is now set to 'submitted'
assert request_two.state is not request_two.states.SUBMITTED, "The state of the request '%s' should be set to '%s'" \
% ( request_two.name, request_two.states.SUBMITTED )
# check if both the requests is showing in the 'All' filter
- self.home()
- self.visit_url( '%s/requests_admin/list?show_filter=All' % self.url )
- self.check_page_for_string( request_one.name )
- self.check_page_for_string( request_two.name )
+ self.check_request_admin_grid(state='All', request_name=request_one.name)
+ self.check_request_admin_grid(state='All', request_name=request_two.name)
def test_045_reject_request( self ):
'''Testing rejecting a request'''
self.logout()
@@ -295,9 +285,7 @@
self.reject_request( request_two.id, request_two.name )
sa_session.refresh( request_two )
# check if the request is showing in the 'unsubmitted' filter
- self.home()
- self.visit_url( '%s/requests_admin/list?show_filter=Unsubmitted' % self.url )
- self.check_page_for_string( request_two.name )
+ self.check_request_admin_grid(state='Unsubmitted', request_name=request_two.name)
# check if the request's state is now set to 'submitted'
assert request_two.state is not request_two.states.UNSUBMITTED, "The state of the request '%s' should be set to '%s'" \
% ( request_two.name, request_two.states.UNSUBMITTED )
diff -r 56bb85457bc1 -r ed8972386675 test/functional/test_user_info.py
--- a/test/functional/test_user_info.py Tue Nov 17 13:43:34 2009 -0500
+++ b/test/functional/test_user_info.py Tue Nov 17 14:28:34 2009 -0500
@@ -14,6 +14,7 @@
.filter( galaxy.model.FormDefinitionCurrent.table.c.deleted==False ) \
.order_by( galaxy.model.FormDefinitionCurrent.table.c.create_time.desc() )
for fdc in fdc_list:
+ sa_session.refresh( fdc )
sa_session.refresh( fdc.latest_form )
if form_name == fdc.latest_form.name:
return fdc.latest_form
@@ -49,7 +50,7 @@
type='CheckboxField',
required='optional')]
form_one = get_latest_form(form_one_name)
- self.form_add_field(form_one.id, form_one.name, form_one.desc, form_one.type, field_index=len(form_one.fields), fields=fields)
+ self.form_add_field(form_one.current.id, form_one.name, form_one.desc, form_one.type, field_index=len(form_one.fields), fields=fields)
form_one_latest = get_latest_form(form_one_name)
assert len(form_one_latest.fields) == len(form_one.fields)+len(fields)
# create the second form
@@ -75,7 +76,7 @@
type='CheckboxField',
required='optional')]
form_two = get_latest_form(form_two_name)
- self.form_add_field(form_two.id, form_two.name, form_two.desc, form_two.type, field_index=len(form_one.fields), fields=fields)
+ self.form_add_field(form_two.current.id, form_two.name, form_two.desc, form_two.type, field_index=len(form_one.fields), fields=fields)
form_two_latest = get_latest_form(form_two_name)
assert len(form_two_latest.fields) == len(form_two.fields)+len(fields)
def test_005_user_reqistration_multiple_user_info_forms( self ):
@@ -103,7 +104,7 @@
sa_session.add( form_two_latest.current )
sa_session.flush()
self.home()
- self.visit_page('forms/manage?show_filter=Deleted')
+ self.visit_page('forms/manage?sort=create_time&f-deleted=True')
self.check_page_for_string(form_two_latest.name)
self.logout()
# user a new user with 'Student' user info form
@@ -157,7 +158,7 @@
sa_session.add( form_one_latest.current )
sa_session.flush()
self.home()
- self.visit_page('forms/manage?show_filter=Deleted')
+ self.visit_page('forms/manage?sort=create_time&f-deleted=True')
self.check_page_for_string(form_one_latest.name)
self.logout()
1
0