commit/galaxy-central: greg: Eliminate all suport for tool / tool suite archives from the tool shed. Yikes!
1 new changeset in galaxy-central: http://bitbucket.org/galaxy/galaxy-central/changeset/b02edf5334bf/ changeset: b02edf5334bf branches: user: greg date: 2011-06-02 21:18:35 summary: Eliminate all suport for tool / tool suite archives from the tool shed. Yikes! affected #: 25 files (61.6 KB) --- a/community_wsgi.ini.sample Thu Jun 02 14:18:34 2011 -0400 +++ b/community_wsgi.ini.sample Thu Jun 02 15:18:35 2011 -0400 @@ -12,9 +12,6 @@ [app:main] -# Enable next-gen tool shed features -#enable_next_gen_tool_shed = True - # Specifies the factory for the universe WSGI application paste.app_factory = galaxy.webapps.community.buildapp:app_factory log_level = DEBUG --- a/lib/galaxy/web/base/controller.py Thu Jun 02 14:18:34 2011 -0400 +++ b/lib/galaxy/web/base/controller.py Thu Jun 02 15:18:35 2011 -0400 @@ -2026,16 +2026,6 @@ **kwd ) ) elif operation == "manage roles and groups": return self.manage_roles_and_groups_for_user( trans, **kwd ) - elif operation == "tools_by_user": - # This option is called via the ToolsColumn link in a grid subclass, - # so we need to add user_id to kwd since id in the subclass is tool.id, - # and update the current sort filter, using the grid subclass's default - # sort filter instead of this class's. - kwd[ 'user_id' ] = kwd[ 'id' ] - kwd[ 'sort' ] = 'name' - return trans.response.send_redirect( web.url_for( controller='admin', - action='browse_tools', - **kwd ) ) # Render the list view return self.user_list_grid( trans, **kwd ) @web.expose --- a/lib/galaxy/webapps/community/app.py Thu Jun 02 14:18:34 2011 -0400 +++ b/lib/galaxy/webapps/community/app.py Thu Jun 02 15:18:35 2011 -0400 @@ -11,14 +11,6 @@ self.config = config.Configuration( **kwargs ) self.config.check() config.configure_logging( self.config ) - if self.config.enable_next_gen_tool_shed: - # We don't need a datatypes_registry since we have no datatypes - pass - else: - import galaxy.webapps.community.datatypes - # Set up datatypes registry - self.datatypes_registry = galaxy.webapps.community.datatypes.Registry( self.config.root, self.config.datatypes_config ) - galaxy.model.set_datatypes_registry( self.datatypes_registry ) # Determine the database url if self.config.database_connection: db_url = self.config.database_connection @@ -29,8 +21,7 @@ create_or_verify_database( db_url, self.config.database_engine_options ) # Setup the database engine and ORM from galaxy.webapps.community.model import mapping - self.model = mapping.init( self.config.enable_next_gen_tool_shed, - self.config.file_path, + self.model = mapping.init( self.config.file_path, db_url, self.config.database_engine_options ) # Security helper --- a/lib/galaxy/webapps/community/buildapp.py Thu Jun 02 14:18:34 2011 -0400 +++ b/lib/galaxy/webapps/community/buildapp.py Thu Jun 02 15:18:35 2011 -0400 @@ -31,12 +31,6 @@ controller_dir = galaxy.webapps.community.controllers.__path__[0] for fname in os.listdir( controller_dir ): if not fname.startswith( "_" ) and fname.endswith( ".py" ): - if app.config.enable_next_gen_tool_shed and fname.startswith( 'tool_upload' ): - # The tool_upload controller is for the old version of the tool shed - continue - if not app.config.enable_next_gen_tool_shed and fname.startswith( 'upload' ): - # The upload controller is for the next gen tool shed - continue name = fname[:-3] module_name = "galaxy.webapps.community.controllers." + name module = __import__( module_name ) @@ -81,11 +75,8 @@ webapp = galaxy.web.framework.WebApplication( app, session_cookie='galaxycommunitysession' ) add_controllers( webapp, app ) webapp.add_route( '/:controller/:action', action='index' ) - if app.config.enable_next_gen_tool_shed: - webapp.add_route( '/:action', controller='repository', action='index' ) - webapp.add_route( '/repos/*path_info', controller='hg', action='handle_request', path_info='/' ) - else: - webapp.add_route( '/:action', controller='tool', action='index' ) + webapp.add_route( '/:action', controller='repository', action='index' ) + webapp.add_route( '/repos/*path_info', controller='hg', action='handle_request', path_info='/' ) webapp.finalize_config() # Wrap the webapp in some useful middleware if kwargs.get( 'middleware', True ): --- a/lib/galaxy/webapps/community/config.py Thu Jun 02 14:18:34 2011 -0400 +++ b/lib/galaxy/webapps/community/config.py Thu Jun 02 15:18:35 2011 -0400 @@ -47,7 +47,6 @@ self.require_login = string_as_bool( kwargs.get( "require_login", "False" ) ) self.allow_user_creation = string_as_bool( kwargs.get( "allow_user_creation", "True" ) ) self.enable_openid = string_as_bool( kwargs.get( 'enable_openid', False ) ) - self.enable_next_gen_tool_shed = string_as_bool( kwargs.get( 'enable_next_gen_tool_shed', False ) ) self.template_path = resolve_path( kwargs.get( "template_path", "templates" ), self.root ) self.template_cache = resolve_path( kwargs.get( "template_cache_path", "database/compiled_templates/community" ), self.root ) self.admin_users = kwargs.get( "admin_users", "" ) --- a/lib/galaxy/webapps/community/controllers/admin.py Thu Jun 02 14:18:34 2011 -0400 +++ b/lib/galaxy/webapps/community/controllers/admin.py Thu Jun 02 15:18:35 2011 -0400 @@ -2,14 +2,14 @@ from galaxy.webapps.community import model from galaxy.model.orm import * from galaxy.web.framework.helpers import time_ago, iff, grids -from common import ToolListGrid, CategoryListGrid, get_category, get_event, get_tool, get_versions -from repository import RepositoryListGrid, RepositoryCategoryListGrid +from common import get_category, get_repository +from repository import RepositoryListGrid, CategoryListGrid import logging log = logging.getLogger( __name__ ) class UserListGrid( grids.Grid ): # TODO: move this to an admin_common controller since it is virtually the same - # in the galaxy webapp. NOTE the additional ToolsColumn in this grid though... + # in the galaxy webapp. class UserLoginColumn( grids.TextColumn ): def get_value( self, trans, grid, user ): return user.email @@ -282,58 +282,6 @@ preserve_state = False use_paging = True -class AdminToolListGrid( ToolListGrid ): - class StateColumn( grids.TextColumn ): - def get_value( self, trans, grid, tool ): - state = tool.state - if state == 'approved': - state_color = 'ok' - elif state == 'rejected': - state_color = 'error' - elif state == 'archived': - state_color = 'upload' - else: - state_color = state - return '<div class="count-box state-color-%s">%s</div>' % ( state_color, state ) - class ToolStateColumn( grids.StateColumn ): - def filter( self, trans, user, query, column_filter ): - """Modify query to filter by state.""" - if column_filter == "All": - pass - elif column_filter in [ v for k, v in self.model_class.states.items() ]: - # Get all of the latest ToolEventAssociation ids - tea_ids = [ tea_id_tup[0] for tea_id_tup in trans.sa_session.query( func.max( model.ToolEventAssociation.table.c.id ) ) \ - .group_by( model.ToolEventAssociation.table.c.tool_id ) ] - # Get all of the Event ids associated with the latest ToolEventAssociation ids - event_ids = [ event_id_tup[0] for event_id_tup in trans.sa_session.query( model.ToolEventAssociation.table.c.event_id ) \ - .filter( model.ToolEventAssociation.table.c.id.in_( tea_ids ) ) ] - # Filter our query by state and event ids - return query.filter( and_( model.Event.table.c.state == column_filter, - model.Event.table.c.id.in_( event_ids ) ) ) - return query - - columns = [ col for col in ToolListGrid.columns ] - columns.append( - StateColumn( "Status", - model_class=model.Tool, - link=( lambda item: dict( operation="tools_by_state", id=item.id, webapp="community" ) ), - attach_popup=False ), - ) - columns.append( - # Columns that are valid for filtering but are not visible. - ToolStateColumn( "State", - key="state", - model_class=model.Tool, - visible=False, - filterable="advanced" ) - ) - operations = [ - grids.GridOperation( "Edit information", - condition=( lambda item: not item.deleted ), - allow_multiple=False, - url_args=dict( controller="common", action="edit_tool", cntrller="admin", webapp="community" ) ) - ] - class AdminCategoryListGrid( CategoryListGrid ): # Override standard filters standard_filters = [ @@ -374,83 +322,20 @@ role_list_grid = RoleListGrid() group_list_grid = GroupListGrid() manage_category_list_grid = ManageCategoryListGrid() - tool_category_list_grid = AdminCategoryListGrid() - tool_list_grid = AdminToolListGrid() repository_list_grid = RepositoryListGrid() - repository_category_list_grid = RepositoryCategoryListGrid() + category_list_grid = CategoryListGrid() @web.expose @web.require_admin - def browse_tools( self, trans, **kwd ): - # We add params to the keyword dict in this method in order to rename the param - # with an "f-" prefix, simulating filtering by clicking a search link. We have - # to take this approach because the "-" character is illegal in HTTP requests. - if 'operation' in kwd: - operation = kwd['operation'].lower() - if operation == "edit_tool": - return trans.response.send_redirect( web.url_for( controller='common', - action='edit_tool', - cntrller='admin', - **kwd ) ) - elif operation == "view_tool": - return trans.response.send_redirect( web.url_for( controller='common', - action='view_tool', - cntrller='admin', - **kwd ) ) - elif operation == 'tool_history': - return trans.response.send_redirect( web.url_for( controller='common', - cntrller='admin', - action='events', - **kwd ) ) - elif operation == "tools_by_user": - # Eliminate the current filters if any exist. - for k, v in kwd.items(): - if k.startswith( 'f-' ): - del kwd[ k ] - if 'user_id' in kwd: - user = get_user( trans, kwd[ 'user_id' ] ) - kwd[ 'f-email' ] = user.email - del kwd[ 'user_id' ] - else: - # The received id is the tool id, so we need to get the id of the user - # that uploaded the tool. - tool_id = kwd.get( 'id', None ) - tool = get_tool( trans, tool_id ) - kwd[ 'f-email' ] = tool.user.email - elif operation == "tools_by_state": - # Eliminate the current filters if any exist. - for k, v in kwd.items(): - if k.startswith( 'f-' ): - del kwd[ k ] - if 'state' in kwd: - # Called from the Admin menu - kwd[ 'f-state' ] = kwd[ 'state' ] - else: - # Called from the ToolStateColumn link - tool_id = kwd.get( 'id', None ) - tool = get_tool( trans, tool_id ) - kwd[ 'f-state' ] = tool.state - elif operation == "tools_by_category": - # Eliminate the current filters if any exist. - for k, v in kwd.items(): - if k.startswith( 'f-' ): - del kwd[ k ] - category_id = kwd.get( 'id', None ) - category = get_category( trans, category_id ) - kwd[ 'f-Category.name' ] = category.name - # Render the list view - return self.tool_list_grid( trans, **kwd ) - @web.expose - @web.require_admin def browse_repositories( self, trans, **kwd ): # We add params to the keyword dict in this method in order to rename the param # with an "f-" prefix, simulating filtering by clicking a search link. We have # to take this approach because the "-" character is illegal in HTTP requests. if 'operation' in kwd: operation = kwd['operation'].lower() - if operation == "view_repository": + if operation == "view_or_manage_repository": return trans.response.send_redirect( web.url_for( controller='repository', - action='view_repository', + action='browse_repositories', **kwd ) ) elif operation == "edit_repository": return trans.response.send_redirect( web.url_for( controller='repository', @@ -485,29 +370,16 @@ @web.require_admin def browse_categories( self, trans, **kwd ): if 'operation' in kwd: - operation = kwd['operation'].lower() - if trans.app.config.enable_next_gen_tool_shed: - if operation in [ "repositories_by_category", "repositories_by_user" ]: - # Eliminate the current filters if any exist. - for k, v in kwd.items(): - if k.startswith( 'f-' ): - del kwd[ k ] - return trans.response.send_redirect( web.url_for( controller='admin', - action='browse_repositories', - **kwd ) ) - else: - if operation in [ "tools_by_category", "tools_by_state", "tools_by_user" ]: - # Eliminate the current filters if any exist. - for k, v in kwd.items(): - if k.startswith( 'f-' ): - del kwd[ k ] - return trans.response.send_redirect( web.url_for( controller='admin', - action='browse_tools', - **kwd ) ) - if trans.app.config.enable_next_gen_tool_shed: - return self.repository_category_list_grid( trans, **kwd ) - else: - return self.tool_category_list_grid( trans, **kwd ) + operation = kwd[ 'operation' ].lower() + if operation in [ "repositories_by_category", "repositories_by_user" ]: + # Eliminate the current filters if any exist. + for k, v in kwd.items(): + if k.startswith( 'f-' ): + del kwd[ k ] + return trans.response.send_redirect( web.url_for( controller='admin', + action='browse_repositories', + **kwd ) ) + return self.category_list_grid( trans, **kwd ) @web.expose @web.require_admin def manage_categories( self, trans, **kwd ): @@ -573,140 +445,6 @@ status=status ) @web.expose @web.require_admin - def set_tool_state( self, trans, state, **kwd ): - params = util.Params( kwd ) - message = util.restore_text( params.get( 'message', '' ) ) - status = params.get( 'status', 'done' ) - comments = util.restore_text( params.get( 'comments', '' ) ) - id = params.get( 'id', None ) - if not id: - message = "No tool id received for setting status" - status = 'error' - else: - tool = get_tool( trans, id ) - if state == trans.app.model.Tool.states.APPROVED: - # If we're approving a tool, all previously approved versions must be set to archived - for version in get_versions( tool ): - # TODO: get latest approved version instead of all versions - if version != tool and version.is_approved: - # Create an event with state ARCHIVED for the previously approved version of this tool - self.__create_tool_event( trans, - version, - trans.app.model.Tool.states.ARCHIVED ) - # Create an event with state APPROVED for this tool - self.__create_tool_event( trans, tool, state, comments ) - elif state == trans.app.model.Tool.states.REJECTED: - # If we're rejecting a tool, comments about why are necessary. - return trans.fill_template( '/webapps/community/admin/reject_tool.mako', - tool=tool, - cntrller='admin' ) - message = "State of tool '%s' is now %s" % ( tool.name, state ) - trans.response.send_redirect( web.url_for( controller='admin', - action='browse_tools', - message=message, - status=status ) ) - @web.expose - @web.require_admin - def reject_tool( self, trans, **kwd ): - params = util.Params( kwd ) - if params.get( 'cancel_reject_button', False ): - # Fix up the keyword dict to include params to view the current tool - # since that is the page from which we originated. - del kwd[ 'cancel_reject_button' ] - del kwd[ 'comments' ] - kwd[ 'webapp' ] = 'community' - kwd[ 'operation' ] = 'view_tool' - message = 'Tool rejection cancelled' - status = 'done' - return trans.response.send_redirect( web.url_for( controller='admin', - action='browse_tools', - message=message, - status=status, - **kwd ) ) - id = params.get( 'id', None ) - if not id: - return trans.response.send_redirect( web.url_for( controller=cntrller, - action='browse_tools', - message='No tool id received for rejecting', - status='error' ) ) - tool = get_tool( trans, id ) - if not trans.app.security_agent.can_approve_or_reject( trans.user, trans.user_is_admin(), 'admin', tool ): - return trans.response.send_redirect( web.url_for( controller='admin', - action='browse_tools', - message='You are not allowed to reject this tool', - status='error' ) ) - # Comments are required when rejecting a tool. - comments = util.restore_text( params.get( 'comments', '' ) ) - if not comments: - message = 'The reason for rejection is required when rejecting a tool.' - return trans.fill_template( '/webapps/community/admin/reject_tool.mako', - tool=tool, - cntrller='admin', - message=message, - status='error' ) - # Create an event with state REJECTED for this tool - self.__create_tool_event( trans, tool, trans.app.model.Tool.states.REJECTED, comments ) - message = 'The tool "%s" has been rejected.' % tool.name - return trans.response.send_redirect( web.url_for( controller='admin', - action='browse_tools', - operation='tools_by_state', - state='rejected', - message=message, - status='done' ) ) - def __create_tool_event( self, trans, tool, state, comments='' ): - event = trans.model.Event( state, comments ) - # Flush so we can get an id - trans.sa_session.add( event ) - trans.sa_session.flush() - tea = trans.model.ToolEventAssociation( tool, event ) - trans.sa_session.add( tea ) - trans.sa_session.flush() - @web.expose - @web.require_admin - def purge_tool( self, trans, **kwd ): - # This method completely removes a tool record and all associated foreign key rows - # from the database, so it must be used carefully. - # This method should only be called for a tool that has previously been deleted. - # Purging a deleted tool deletes all of the following from the database: - # - ToolCategoryAssociations - # - ToolEventAssociations and associated Events - # TODO: when we add tagging for tools, we'll have to purge them as well - params = util.Params( kwd ) - id = kwd.get( 'id', None ) - if not id: - message = "No tool ids received for purging" - trans.response.send_redirect( web.url_for( controller='admin', - action='browse_tools', - message=util.sanitize_text( message ), - status='error' ) ) - ids = util.listify( id ) - message = "Purged %d tools: " % len( ids ) - for tool_id in ids: - tool = get_tool( trans, tool_id ) - message += " %s " % tool.name - if not tool.deleted: - message = "Tool '%s' has not been deleted, so it cannot be purged." % tool.name - trans.response.send_redirect( web.url_for( controller='admin', - action='browse_tools', - message=util.sanitize_text( message ), - status='error' ) ) - # Delete ToolCategoryAssociations - for tca in tool.categories: - trans.sa_session.delete( tca ) - # Delete ToolEventAssociations and associated events - for tea in tool.events: - event = tea.event - trans.sa_session.delete( event ) - trans.sa_session.delete( tea ) - # Delete the tool - trans.sa_session.delete( tool ) - trans.sa_session.flush() - trans.response.send_redirect( web.url_for( controller='admin', - action='browse_tools', - message=util.sanitize_text( message ), - status='done' ) ) - @web.expose - @web.require_admin def edit_category( self, trans, **kwd ): params = util.Params( kwd ) message = util.restore_text( params.get( 'message', '' ) ) @@ -804,10 +542,7 @@ def purge_category( self, trans, **kwd ): # This method should only be called for a Category that has previously been deleted. # Purging a deleted Category deletes all of the following from the database: - # If trans.app.config.enable_next_gen_tool_shed: # - RepoitoryCategoryAssociations where category_id == Category.id - # Otherwise: - # - ToolCategoryAssociations where category_id == Category.id params = util.Params( kwd ) id = kwd.get( 'id', None ) if not id: @@ -826,14 +561,9 @@ action='manage_categories', message=util.sanitize_text( message ), status='error' ) ) - if trans.app.config.enable_next_gen_tool_shed: - # Delete RepositoryCategoryAssociations - for rca in category.repositories: - trans.sa_session.delete( rca ) - else: - # Delete ToolCategoryAssociations - for tca in category.tools: - trans.sa_session.delete( tca ) + # Delete RepositoryCategoryAssociations + for rca in category.repositories: + trans.sa_session.delete( rca ) trans.sa_session.flush() message += " %s " % category.name trans.response.send_redirect( web.url_for( controller='admin', --- a/lib/galaxy/webapps/community/controllers/common.py Thu Jun 02 14:18:34 2011 -0400 +++ b/lib/galaxy/webapps/community/controllers/common.py Thu Jun 02 15:18:35 2011 -0400 @@ -34,508 +34,8 @@ trans.sa_session.flush() return item_rating -class ToolListGrid( grids.Grid ): - class NameColumn( grids.TextColumn ): - def get_value( self, trans, grid, tool ): - return tool.name - class TypeColumn( grids.BooleanColumn ): - def get_value( self, trans, grid, tool ): - if tool.is_suite: - return 'Suite' - return 'Tool' - class VersionColumn( grids.TextColumn ): - def get_value( self, trans, grid, tool ): - return tool.version - class DescriptionColumn( grids.TextColumn ): - def get_value( self, trans, grid, tool ): - return tool.description - class CategoryColumn( grids.TextColumn ): - def get_value( self, trans, grid, tool ): - rval = '<ul>' - if tool.categories: - for tca in tool.categories: - rval += '<li><a href="browse_tools?operation=tools_by_category&id=%s&webapp=community">%s</a></li>' \ - % ( trans.security.encode_id( tca.category.id ), tca.category.name ) - else: - rval += '<li>not set</li>' - rval += '</ul>' - return rval - class ToolCategoryColumn( grids.GridColumn ): - def filter( self, trans, user, query, column_filter ): - """Modify query to filter by category.""" - if column_filter == "All": - pass - return query.filter( model.Category.name == column_filter ) - class UserColumn( grids.TextColumn ): - def get_value( self, trans, grid, tool ): - if tool.user: - return tool.user.username - return 'no user' - class EmailColumn( grids.TextColumn ): - def filter( self, trans, user, query, column_filter ): - if column_filter == 'All': - return query - return query.filter( and_( model.Tool.table.c.user_id == model.User.table.c.id, - model.User.table.c.email == column_filter ) ) - # Grid definition - title = "Tools" - model_class = model.Tool - template='/webapps/community/tool/grid.mako' - default_sort_key = "name" - columns = [ - NameColumn( "Name", - key="Tool.name", - link=( lambda item: dict( operation="view_tool", id=item.id, webapp="community" ) ), - attach_popup=False ), - DescriptionColumn( "Description", - key="description", - attach_popup=False ), - VersionColumn( "Version", - key="version", - attach_popup=False, - filterable="advanced" ), - CategoryColumn( "Category", - model_class=model.Category, - key="Category.name", - attach_popup=False ), - UserColumn( "Uploaded By", - model_class=model.User, - link=( lambda item: dict( operation="tools_by_user", id=item.id, webapp="community" ) ), - attach_popup=False, - key="username" ), - TypeColumn( "Type", - key="suite", - attach_popup=False ), - grids.CommunityRatingColumn( "Average Rating", - key="rating" ), - # Columns that are valid for filtering but are not visible. - EmailColumn( "Email", - model_class=model.User, - key="email", - visible=False ), - ToolCategoryColumn( "Category", - model_class=model.Category, - key="Category.name", - visible=False ) - ] - columns.append( grids.MulticolFilterColumn( "Search tool name, description, version", - cols_to_filter=[ columns[0], columns[1], columns[2] ], - key="free-text-search", - visible=False, - filterable="standard" ) ) - operations = [] - standard_filters = [] - default_filter = {} - num_rows_per_page = 50 - preserve_state = False - use_paging = True - def build_initial_query( self, trans, **kwd ): - return trans.sa_session.query( self.model_class ) \ - .join( model.User.table ) \ - .join( model.ToolEventAssociation.table ) \ - .join( model.Event.table ) \ - .outerjoin( model.ToolCategoryAssociation.table ) \ - .outerjoin( model.Category.table ) - -class CategoryListGrid( grids.Grid ): - class NameColumn( grids.TextColumn ): - def get_value( self, trans, grid, category ): - return category.name - class DescriptionColumn( grids.TextColumn ): - def get_value( self, trans, grid, category ): - return category.description - class ToolsColumn( grids.TextColumn ): - def get_value( self, trans, grid, category ): - if category.tools: - viewable_tools = 0 - for tca in category.tools: - viewable_tools += 1 - return viewable_tools - return 0 - - # Grid definition - webapp = "community" - title = "Categories" - model_class = model.Category - template='/webapps/community/category/grid.mako' - default_sort_key = "name" - columns = [ - NameColumn( "Name", - key="name", - link=( lambda item: dict( operation="tools_by_category", id=item.id, webapp="community" ) ), - attach_popup=False, - filterable="advanced" ), - DescriptionColumn( "Description", - key="description", - attach_popup=False, - filterable="advanced" ), - # Columns that are valid for filtering but are not visible. - grids.DeletedColumn( "Deleted", - key="deleted", - visible=False, - filterable="advanced" ), - ToolsColumn( "Tools", - model_class=model.Tool, - attach_popup=False ) - ] - columns.append( grids.MulticolFilterColumn( "Search category name, description", - cols_to_filter=[ columns[0], columns[1] ], - key="free-text-search", - visible=False, - filterable="standard" ) ) - - # Override these - global_actions = [] - operations = [] - standard_filters = [] - num_rows_per_page = 50 - preserve_state = False - use_paging = True - -class CommonController( BaseController, ItemRatings ): - @web.expose - def edit_tool( self, trans, cntrller, **kwd ): - params = util.Params( kwd ) - message = util.restore_text( params.get( 'message', '' ) ) - status = params.get( 'status', 'done' ) - id = params.get( 'id', None ) - if not id: - return trans.response.send_redirect( web.url_for( controller=cntrller, - action='browse_tools', - cntrller=cntrller, - message='Select a tool to edit', - status='error' ) ) - tool = get_tool( trans, id ) - can_edit = trans.app.security_agent.can_edit( trans.user, trans.user_is_admin(), cntrller, tool ) - if not can_edit: - return trans.response.send_redirect( web.url_for( controller=cntrller, - action='browse_tools', - cntrller=cntrller, - message='You are not allowed to edit this tool', - status='error' ) ) - if params.get( 'edit_tool_button', False ): - if params.get( 'in_categories', False ): - in_categories = [ trans.sa_session.query( trans.app.model.Category ).get( x ) for x in util.listify( params.in_categories ) ] - trans.app.security_agent.set_entity_category_associations( tools=[ tool ], categories=in_categories ) - else: - # There must not be any categories associated with the tool - trans.app.security_agent.set_entity_category_associations( tools=[ tool ], categories=[] ) - user_description = util.restore_text( params.get( 'user_description', '' ) ) - if user_description: - tool.user_description = user_description - else: - tool.user_description = '' - trans.sa_session.add( tool ) - trans.sa_session.flush() - message = "Tool '%s' description and category associations have been saved" % tool.name - return trans.response.send_redirect( web.url_for( controller='common', - action='edit_tool', - cntrller=cntrller, - id=id, - message=message, - status='done' ) ) - elif params.get( 'approval_button', False ): - user_description = util.restore_text( params.get( 'user_description', '' ) ) - if user_description: - tool.user_description = user_description - if params.get( 'in_categories', False ): - in_categories = [ trans.sa_session.query( trans.app.model.Category ).get( x ) for x in util.listify( params.in_categories ) ] - trans.app.security_agent.set_entity_category_associations( tools=[ tool ], categories=in_categories ) - else: - # There must not be any categories associated with the tool - trans.app.security_agent.set_entity_category_associations( tools=[ tool ], categories=[] ) - trans.sa_session.add( tool ) - trans.sa_session.flush() - # Move the state from NEW to WAITING - event = trans.app.model.Event( state=trans.app.model.Tool.states.WAITING ) - tea = trans.app.model.ToolEventAssociation( tool, event ) - trans.sa_session.add_all( ( event, tea ) ) - trans.sa_session.flush() - message = "Tool '%s' has been submitted for approval and can no longer be modified" % ( tool.name ) - return trans.response.send_redirect( web.url_for( controller='common', - action='view_tool', - cntrller=cntrller, - id=id, - message=message, - status='done' ) ) - else: - # The user_description field is required when submitting for approval - message = 'A user description is required prior to approval.' - status = 'error' - in_categories = [] - out_categories = [] - for category in get_categories( trans ): - if category in [ x.category for x in tool.categories ]: - in_categories.append( ( category.id, category.name ) ) - else: - out_categories.append( ( category.id, category.name ) ) - if tool.is_rejected: - # Include the comments regarding the reason for rejection - reason_for_rejection = tool.latest_event.comment - else: - reason_for_rejection = '' - can_approve_or_reject = trans.app.security_agent.can_approve_or_reject( trans.user, trans.user_is_admin(), cntrller, tool ) - can_delete = trans.app.security_agent.can_delete( trans.user, trans.user_is_admin(), cntrller, tool ) - can_download = trans.app.security_agent.can_download( trans.user, trans.user_is_admin(), cntrller, tool ) - can_purge = trans.app.security_agent.can_purge( trans.user, trans.user_is_admin(), cntrller ) - can_upload_new_version = trans.app.security_agent.can_upload_new_version( trans.user, tool ) - can_view = trans.app.security_agent.can_view( trans.user, trans.user_is_admin(), cntrller, tool ) - return trans.fill_template( '/webapps/community/tool/edit_tool.mako', - cntrller=cntrller, - tool=tool, - id=id, - in_categories=in_categories, - out_categories=out_categories, - can_approve_or_reject=can_approve_or_reject, - can_delete=can_delete, - can_download=can_download, - can_edit=can_edit, - can_purge=can_purge, - can_upload_new_version=can_upload_new_version, - can_view=can_view, - reason_for_rejection=reason_for_rejection, - message=message, - status=status ) - @web.expose - def view_tool( self, trans, cntrller, **kwd ): - params = util.Params( kwd ) - message = util.restore_text( params.get( 'message', '' ) ) - status = params.get( 'status', 'done' ) - id = params.get( 'id', None ) - if not id: - return trans.response.send_redirect( web.url_for( controller=cntrller, - action='browse_tools', - cntrller=cntrller, - message='Select a tool to view', - status='error' ) ) - tool = get_tool( trans, id ) - can_view = trans.app.security_agent.can_view( trans.user, trans.user_is_admin(), cntrller, tool ) - if not can_view: - return trans.response.send_redirect( web.url_for( controller=cntrller, - action='browse_tools', - cntrller=cntrller, - message='You are not allowed to view this tool', - status='error' ) ) - avg_rating, num_ratings = self.get_ave_item_rating_data( trans.sa_session, tool, webapp_model=trans.model ) - can_approve_or_reject = trans.app.security_agent.can_approve_or_reject( trans.user, trans.user_is_admin(), cntrller, tool ) - can_delete = trans.app.security_agent.can_delete( trans.user, trans.user_is_admin(), cntrller, tool ) - can_download = trans.app.security_agent.can_download( trans.user, trans.user_is_admin(), cntrller, tool ) - can_edit = trans.app.security_agent.can_edit( trans.user, trans.user_is_admin(), cntrller, tool ) - can_purge = trans.app.security_agent.can_purge( trans.user, trans.user_is_admin(), cntrller ) - can_rate = trans.app.security_agent.can_rate( trans.user, trans.user_is_admin(), cntrller, tool ) - can_upload_new_version = trans.app.security_agent.can_upload_new_version( trans.user, tool ) - categories = [ tca.category for tca in tool.categories ] - display_reviews = util.string_as_bool( params.get( 'display_reviews', False ) ) - tool_file_contents = tarfile.open( tool.file_name, 'r' ).getnames() - tra = self.get_user_item_rating( trans.sa_session, trans.user, tool, webapp_model=trans.model ) - visible_versions = trans.app.security_agent.get_visible_versions( trans.user, trans.user_is_admin(), cntrller, tool ) - if tool.is_rejected: - # Include the comments regarding the reason for rejection - reason_for_rejection = tool.latest_event.comment - else: - reason_for_rejection = '' - return trans.fill_template( '/webapps/community/tool/view_tool.mako', - avg_rating=avg_rating, - categories=categories, - can_approve_or_reject=can_approve_or_reject, - can_delete=can_delete, - can_download=can_download, - can_edit=can_edit, - can_purge=can_purge, - can_rate=can_rate, - can_upload_new_version=can_upload_new_version, - can_view=can_view, - cntrller=cntrller, - display_reviews=display_reviews, - num_ratings=num_ratings, - reason_for_rejection=reason_for_rejection, - tool=tool, - tool_file_contents=tool_file_contents, - tra=tra, - visible_versions=visible_versions, - message=message, - status=status ) - @web.expose - def delete_tool( self, trans, cntrller, **kwd ): - params = util.Params( kwd ) - message = util.restore_text( params.get( 'message', '' ) ) - status = params.get( 'status', 'done' ) - id = params.get( 'id', None ) - if not id: - message='Select a tool to delete' - status='error' - else: - tool = get_tool( trans, id ) - if not trans.app.security_agent.can_delete( trans.user, trans.user_is_admin(), cntrller, tool ): - return trans.response.send_redirect( web.url_for( controller=cntrller, - action='browse_tools', - cntrller=cntrller, - message='You are not allowed to delete this tool', - status='error' ) ) - # Create a new event - event = trans.model.Event( state=trans.model.Tool.states.DELETED ) - # Flush so we can get an event id - trans.sa_session.add( event ) - trans.sa_session.flush() - # Associate the tool with the event - tea = trans.model.ToolEventAssociation( tool=tool, event=event ) - # Delete the tool, keeping state for categories, events and versions - tool.deleted = True - trans.sa_session.add_all( ( tool, tea ) ) - trans.sa_session.flush() - # TODO: What if the tool has versions, should they all be deleted? - message = "Tool '%s' version %s has been marked deleted" % ( tool.name, tool.version ) - status = 'done' - return trans.response.send_redirect( web.url_for( controller=cntrller, - action='browse_tools', - cntrller=cntrller, - message=message, - status=status ) ) - @web.expose - def download_tool( self, trans, cntrller, **kwd ): - params = util.Params( kwd ) - id = params.get( 'id', None ) - if not id: - return trans.response.send_redirect( web.url_for( controller='tool', - action='browse_tools', - cntrller=cntrller, - message='Select a tool to download', - status='error' ) ) - tool = get_tool( trans, id ) - if not trans.app.security_agent.can_download( trans.user, trans.user_is_admin(), cntrller, tool ): - return trans.response.send_redirect( web.url_for( controller=cntrller, - action='browse_tools', - cntrller=cntrller, - message='You are not allowed to download this tool', - status='error' ) ) - trans.response.set_content_type( tool.mimetype ) - trans.response.headers['Content-Length'] = int( os.stat( tool.file_name ).st_size ) - trans.response.headers['Content-Disposition'] = 'attachment; filename=%s' % tool.download_file_name - return open( tool.file_name ) - @web.expose - def upload_new_tool_version( self, trans, cntrller, **kwd ): - params = util.Params( kwd ) - message = util.restore_text( params.get( 'message', '' ) ) - status = params.get( 'status', 'done' ) - id = params.get( 'id', None ) - if not id: - return trans.response.send_redirect( web.url_for( controller=cntrller, - action='browse_tools', - cntrller=cntrller, - message='Select a tool to upload a new version', - status='error' ) ) - tool = get_tool( trans, id ) - if not trans.app.security_agent.can_upload_new_version( trans.user, tool ): - return trans.response.send_redirect( web.url_for( controller=cntrller, - action='browse_tools', - cntrller=cntrller, - message='You are not allowed to upload a new version of this tool', - status='error' ) ) - return trans.response.send_redirect( web.url_for( controller='tool_upload', - action='upload', - message=message, - status=status, - replace_id=id ) ) - @web.expose - @web.require_login( "view tool history" ) - def view_tool_history( self, trans, cntrller, **kwd ): - params = util.Params( kwd ) - message = util.restore_text( params.get( 'message', '' ) ) - status = params.get( 'status', 'done' ) - id = params.get( 'id', None ) - if not id: - return trans.response.send_redirect( web.url_for( controller=cntrller, - action='browse_tools', - cntrller=cntrller, - message='Select a tool to view its history', - status='error' ) ) - tool = get_tool( trans, id ) - can_view = trans.app.security_agent.can_view( trans.user, trans.user_is_admin(), cntrller, tool ) - if not can_view: - return trans.response.send_redirect( web.url_for( controller=cntrller, - action='browse_tools', - cntrller=cntrller, - message="You are not allowed to view this tool's history", - status='error' ) ) - can_approve_or_reject = trans.app.security_agent.can_approve_or_reject( trans.user, trans.user_is_admin(), cntrller, tool ) - can_edit = trans.app.security_agent.can_edit( trans.user, trans.user_is_admin(), cntrller, tool ) - can_delete = trans.app.security_agent.can_delete( trans.user, trans.user_is_admin(), cntrller, tool ) - can_download = trans.app.security_agent.can_download( trans.user, trans.user_is_admin(), cntrller, tool ) - events = [ tea.event for tea in tool.events ] - events = [ ( event.state, time_ago( event.update_time ), event.comment ) for event in events ] - return trans.fill_template( '/webapps/community/common/view_tool_history.mako', - cntrller=cntrller, - events=events, - tool=tool, - can_approve_or_reject=can_approve_or_reject, - can_edit=can_edit, - can_delete=can_delete, - can_download=can_download, - can_view=can_view, - message=message, - status=status ) - @web.expose - @web.require_login( "rate tools" ) - def rate_tool( self, trans, cntrller, **kwd ): - """ Rate a tool and return updated rating data. """ - params = util.Params( kwd ) - message = util.restore_text( params.get( 'message', '' ) ) - status = params.get( 'status', 'done' ) - id = params.get( 'id', None ) - if not id: - return trans.response.send_redirect( web.url_for( controller=cntrller, - action='browse_tools', - cntrller=cntrller, - message='Select a tool to rate', - status='error' ) ) - tool = get_tool( trans, id ) - can_rate = trans.app.security_agent.can_rate( trans.user, trans.user_is_admin(), cntrller, tool ) - if not can_rate: - return trans.response.send_redirect( web.url_for( controller=cntrller, - action='browse_tools', - cntrller=cntrller, - message="You are not allowed to rate this tool", - status='error' ) ) - if params.get( 'rate_button', False ): - rating = int( params.get( 'rating', '0' ) ) - comment = util.restore_text( params.get( 'comment', '' ) ) - rating = self.rate_item( trans, trans.user, tool, rating, comment ) - avg_rating, num_ratings = self.get_ave_item_rating_data( trans.sa_session, tool, webapp_model=trans.model ) - can_approve_or_reject = trans.app.security_agent.can_approve_or_reject( trans.user, trans.user_is_admin(), cntrller, tool ) - can_edit = trans.app.security_agent.can_edit( trans.user, trans.user_is_admin(), cntrller, tool ) - can_delete = trans.app.security_agent.can_delete( trans.user, trans.user_is_admin(), cntrller, tool ) - can_download = trans.app.security_agent.can_download( trans.user, trans.user_is_admin(), cntrller, tool ) - display_reviews = util.string_as_bool( params.get( 'display_reviews', False ) ) - tra = self.get_user_item_rating( trans.sa_session, trans.user, tool, webapp_model=trans.model ) - return trans.fill_template( '/webapps/community/common/rate_tool.mako', - cntrller=cntrller, - tool=tool, - avg_rating=avg_rating, - can_approve_or_reject=can_approve_or_reject, - can_edit=can_edit, - can_delete=can_delete, - can_download=can_download, - can_rate=can_rate, - display_reviews=display_reviews, - num_ratings=num_ratings, - tra=tra, - message=message, - status=status ) - ## ---- Utility methods ------------------------------------------------------- -def get_versions( item ): - """Get all versions of item""" - versions = [ item ] - this_item = item - while item.newer_version: - versions.insert( 0, item.newer_version ) - item = item.newer_version - item = this_item - while item.older_version: - versions.append( item.older_version[ 0 ] ) - item = item.older_version[ 0 ] - return versions def get_categories( trans ): """Get all categories from the database""" return trans.sa_session.query( trans.model.Category ) \ @@ -544,28 +44,6 @@ def get_category( trans, id ): """Get a category from the database""" return trans.sa_session.query( trans.model.Category ).get( trans.security.decode_id( id ) ) -def get_tool( trans, id ): - """Get a tool from the database""" - return trans.sa_session.query( trans.model.Tool ).get( trans.security.decode_id( id ) ) -def get_latest_versions_of_tools( trans ): - """Get only the latest version of each tool from the database""" - return trans.sa_session.query( trans.model.Tool ) \ - .filter( trans.model.Tool.table.c.newer_version_id == None ) \ - .order_by( trans.model.Tool.table.c.name ) -def get_latest_versions_of_tools_by_state( trans, state ): - """Get only the latest version of each tool whose state is the received state from the database""" - tools = [] - for tool in trans.sa_session.query( trans.model.Tool ) \ - .order_by( trans.model.Tool.table.c.name ): - if tool.state == state: - tools.append( tool ) - return tools -def get_event( trans, id ): - """Get an event from the databse""" - return trans.sa_session.query( trans.model.Event ).get( trans.security.decode_id( id ) ) -def get_user( trans, id ): - """Get a user from the database""" - return trans.sa_session.query( trans.model.User ).get( trans.security.decode_id( id ) ) def get_repository( trans, id ): """Get a repository from the database via id""" return trans.sa_session.query( trans.model.Repository ).get( trans.security.decode_id( id ) ) @@ -577,3 +55,6 @@ tip_changeset = repository.changelog.tip() tip_ctx = repository.changectx( tip_changeset ) return "%s:%s" % ( str( tip_ctx.rev() ), tip_ctx.parents()[0] ) +def get_user( trans, id ): + """Get a user from the database""" + return trans.sa_session.query( trans.model.User ).get( trans.security.decode_id( id ) ) --- a/lib/galaxy/webapps/community/controllers/repository.py Thu Jun 02 14:18:34 2011 -0400 +++ b/lib/galaxy/webapps/community/controllers/repository.py Thu Jun 02 15:18:35 2011 -0400 @@ -15,7 +15,7 @@ VALID_REPOSITORYNAME_RE = re.compile( "^[a-z0-9\_]+$" ) -class RepositoryCategoryListGrid( grids.Grid ): +class CategoryListGrid( grids.Grid ): # TODO rename this class to be categoryListGrid when we eliminate all the tools stuff. class NameColumn( grids.TextColumn ): def get_value( self, trans, grid, category ): @@ -166,7 +166,7 @@ class RepositoryController( BaseController, ItemRatings ): repository_list_grid = RepositoryListGrid() - category_list_grid = RepositoryCategoryListGrid() + category_list_grid = CategoryListGrid() @web.expose def index( self, trans, **kwd ): --- a/lib/galaxy/webapps/community/controllers/tool.py Thu Jun 02 14:18:34 2011 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,214 +0,0 @@ -import os, logging, urllib, tarfile - -from galaxy.web.base.controller import * -from galaxy.webapps.community import model -from galaxy.web.framework.helpers import time_ago, iff, grids -from galaxy.model.orm import * -# TODO: the following is bad because it imports the common controller. -from common import * - -log = logging.getLogger( __name__ ) - -class StateColumn( grids.StateColumn ): - def get_value( self, trans, grid, tool ): - state = tool.state - if state == trans.model.Tool.states.APPROVED: - state_color = 'ok' - elif state == trans.model.Tool.states.REJECTED: - state_color = 'error' - elif state == trans.model.Tool.states.ARCHIVED: - state_color = 'upload' - else: - state_color = state - return '<div class="count-box state-color-%s">%s</div>' % ( state_color, state ) - -class ToolStateColumn( grids.StateColumn ): - def filter( self, trans, user, query, column_filter ): - """Modify query to filter self.model_class by state.""" - if column_filter == "All": - pass - elif column_filter in [ v for k, v in self.model_class.states.items() ]: - # Get all of the latest Events associated with the current version of each tool - latest_event_id_for_current_versions_of_tools = [ tool.latest_event.id for tool in get_latest_versions_of_tools_by_state( trans, column_filter ) ] - # Filter query by the latest state for the current version of each tool - return query.filter( and_( model.Event.table.c.state == column_filter, - model.Event.table.c.id.in_( latest_event_id_for_current_versions_of_tools ) ) ) - return query - -class ApprovedToolListGrid( ToolListGrid ): - columns = [ col for col in ToolListGrid.columns ] - columns.append( - StateColumn( "Status", - link=( lambda item: dict( operation="tools_by_state", id=item.id, webapp="community" ) ), - visible=False, - attach_popup=False ) - ) - columns.append( - ToolStateColumn( "State", - key="state", - visible=False, - filterable="advanced" ) - ) - -class MyToolsListGrid( ApprovedToolListGrid ): - columns = [ col for col in ToolListGrid.columns ] - columns.append( - StateColumn( "Status", - link=( lambda item: dict( operation="tools_by_state", id=item.id, webapp="community" ) ), - visible=True, - attach_popup=False ) - ) - columns.append( - ToolStateColumn( "State", - key="state", - visible=False, - filterable="advanced" ) - ) - -class ToolCategoryListGrid( CategoryListGrid ): - """ - Replaces the tools column in the Category grid with a similar column, - but displaying the number of APPROVED tools in the category. - """ - class ToolsColumn( grids.TextColumn ): - def get_value( self, trans, grid, category ): - if category.tools: - viewable_tools = 0 - for tca in category.tools: - tool = tca.tool - if tool.is_approved: - viewable_tools += 1 - return viewable_tools - return 0 - - columns = [] - for col in CategoryListGrid.columns: - if not isinstance( col, CategoryListGrid.ToolsColumn ): - columns.append( col ) - columns.append( - ToolsColumn( "Tools", - model_class=model.Tool, - attach_popup=False ) - ) - -class ToolController( BaseController ): - - tool_list_grid = ApprovedToolListGrid() - my_tools_list_grid = MyToolsListGrid() - category_list_grid = ToolCategoryListGrid() - - @web.expose - def index( self, trans, **kwd ): - params = util.Params( kwd ) - message = util.restore_text( params.get( 'message', '' ) ) - status = params.get( 'status', 'done' ) - return trans.fill_template( '/webapps/community/index.mako', message=message, status=status ) - @web.expose - def browse_categories( self, trans, **kwd ): - if 'operation' in kwd: - operation = kwd['operation'].lower() - if operation in [ "tools_by_category", "tools_by_state", "tools_by_user" ]: - # Eliminate the current filters if any exist. - for k, v in kwd.items(): - if k.startswith( 'f-' ): - del kwd[ k ] - return trans.response.send_redirect( web.url_for( controller='tool', - action='browse_tools', - cntrller='tool', - **kwd ) ) - # Render the list view - return self.category_list_grid( trans, **kwd ) - @web.expose - def browse_tools( self, trans, **kwd ): - # We add params to the keyword dict in this method in order to rename the param - # with an "f-" prefix, simulating filtering by clicking a search link. We have - # to take this approach because the "-" character is illegal in HTTP requests. - if 'operation' not in kwd: - # We may have been redirected here after performing an action. If we were - # redirected from the tool controller, we have to add the default tools_by_category - # operation to kwd so only tools we should see are displayed. This implies that - # all redirectes from the tool controller added the cntrller value to kwd when - # redirecting. - cntrller = kwd.get( 'cntrller', None ) - if cntrller == 'tool': - kwd[ 'operation' ] = 'approved_tools' - if 'operation' in kwd: - operation = kwd['operation'].lower() - if operation == "view_tool": - return trans.response.send_redirect( web.url_for( controller='common', - action='view_tool', - cntrller='tool', - **kwd ) ) - elif operation == "edit_tool": - return trans.response.send_redirect( web.url_for( controller='common', - action='edit_tool', - cntrller='tool', - **kwd ) ) - elif operation == "download tool": - return trans.response.send_redirect( web.url_for( controller='common', - action='download_tool', - cntrller='tool', - **kwd ) ) - elif operation == "tools_by_user": - # Eliminate the current filters if any exist. - for k, v in kwd.items(): - if k.startswith( 'f-' ): - del kwd[ k ] - if 'user_id' in kwd: - user = get_user( trans, kwd[ 'user_id' ] ) - kwd[ 'f-email' ] = user.email - del kwd[ 'user_id' ] - else: - # The received id is the tool id, so we need to get the id of the user - # that uploaded the tool. - tool_id = kwd.get( 'id', None ) - tool = get_tool( trans, tool_id ) - kwd[ 'f-email' ] = tool.user.email - elif operation == "my_tools": - # Eliminate the current filters if any exist. - for k, v in kwd.items(): - if k.startswith( 'f-' ): - del kwd[ k ] - kwd[ 'f-email' ] = trans.user.email - return self.my_tools_list_grid( trans, **kwd ) - elif operation == "approved_tools": - # Eliminate the current filters if any exist. - for k, v in kwd.items(): - if k.startswith( 'f-' ): - del kwd[ k ] - # Make sure only the latest version of a tool whose state is APPROVED are displayed. - kwd[ 'f-state' ] = trans.model.Tool.states.APPROVED - return self.tool_list_grid( trans, **kwd ) - elif operation == "tools_by_category": - # Eliminate the current filters if any exist. - for k, v in kwd.items(): - if k.startswith( 'f-' ): - del kwd[ k ] - category_id = kwd.get( 'id', None ) - category = get_category( trans, category_id ) - kwd[ 'f-Category.name' ] = category.name - # Make sure only the latest version of a tool whose state is APPROVED are displayed. - kwd[ 'f-state' ] = trans.model.Tool.states.APPROVED - # Render the list view - return self.tool_list_grid( trans, **kwd ) - @web.expose - def view_tool_file( self, trans, **kwd ): - params = util.Params( kwd ) - id = params.get( 'id', None ) - if not id: - return trans.response.send_redirect( web.url_for( controller='tool', - action='browse_tools', - cntrller='tool', - message='Select a tool to download', - status='error' ) ) - tool = get_tool( trans, id ) - tool_file_name = urllib.unquote_plus( kwd['file_name'] ) - tool_file = tarfile.open( tool.file_name ).extractfile( tool_file_name ) - trans.response.set_content_type( 'text/plain' ) - return tool_file - @web.expose - def help( self, trans, **kwd ): - params = util.Params( kwd ) - message = util.restore_text( params.get( 'message', '' ) ) - status = params.get( 'status', 'done' ) - return trans.fill_template( '/webapps/community/tool/help.mako', message=message, status=status, **kwd ) --- a/lib/galaxy/webapps/community/controllers/tool_upload.py Thu Jun 02 14:18:34 2011 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,183 +0,0 @@ -import sys, os, shutil, logging, urllib2 -from galaxy.web.base.controller import * -from galaxy.web.framework.helpers import time_ago, iff, grids -from galaxy.model.orm import * -from galaxy.web.form_builder import SelectField, build_select_field -from galaxy.webapps.community import datatypes -from common import get_categories, get_category, get_versions - -log = logging.getLogger( __name__ ) - -# States for passing messages -SUCCESS, INFO, WARNING, ERROR = "done", "info", "warning", "error" - -class UploadError( Exception ): - pass - -class ToolUploadController( BaseController ): - - @web.expose - @web.require_login( 'upload', use_panels=True, webapp='community' ) - def upload( self, trans, **kwd ): - params = util.Params( kwd ) - message = util.restore_text( params.get( 'message', '' ) ) - status = params.get( 'status', 'done' ) - category_ids = util.listify( params.get( 'category_id', '' ) ) - replace_id = params.get( 'replace_id', None ) - if replace_id: - replace_version = trans.sa_session.query( trans.app.model.Tool ).get( trans.security.decode_id( replace_id ) ) - upload_type = replace_version.type - else: - replace_version = None - upload_type = params.get( 'upload_type', 'tool' ) - uploaded_file = None - categories = get_categories( trans ) - if not categories: - message = 'No categories have been configured in this instance of the Galaxy Tool Shed. ' + \ - 'An administrator needs to create some via the Administrator control panel before anything can be uploaded', - status = 'error' - return trans.response.send_redirect( web.url_for( controller='tool', - action='browse_tools', - cntrller='tool', - message=message, - status=status ) ) - if params.get( 'upload_button', False ): - url_paste = params.get( 'url', '' ).strip() - file_data = params.get( 'file_data', '' ) - if file_data == '' and url_paste == '': - message = 'No files were entered on the upload form.' - status = 'error' - elif file_data == '': - try: - uploaded_file = urllib2.urlopen( url_paste ) - except ( ValueError, urllib2.HTTPError ), e: - message = 'An error occurred trying to retrieve the URL entered on the upload form: %s' % str( e ) - status = 'error' - except urllib2.URLError, e: - message = 'An error occurred trying to retrieve the URL entered on the upload form: %s' % e.reason - status = 'error' - elif file_data not in ( '', None ): - uploaded_file = file_data.file - if uploaded_file: - datatype = trans.app.datatypes_registry.get_datatype_by_extension( upload_type ) - if datatype is None: - message = 'An unknown file type was selected. This should not be possible, please report the error.' - status = 'error' - else: - try: - # Initialize the tool object - meta = datatype.verify( uploaded_file ) - meta.user = trans.user - meta.guid = trans.app.security.get_new_guid() - meta.suite = upload_type == 'toolsuite' - obj = datatype.create_model_object( meta ) - trans.sa_session.add( obj ) - if isinstance( obj, trans.app.model.Tool ): - existing = trans.sa_session.query( trans.app.model.Tool ) \ - .filter_by( tool_id = meta.id ) \ - .first() - if existing and not replace_id: - raise UploadError( 'A %s with the same Id already exists. If you are trying to update this %s to a new version, use the upload form on the "Edit Tool" page. Otherwise, change the Id in the %s config.' % \ - ( obj.label, obj.label, obj.label ) ) - elif replace_id and not existing: - raise UploadError( 'The new %s id (%s) does not match the old %s id (%s). Check the %s config files.' % \ - ( obj.label, str( meta.id ), obj.label, str( replace_version.tool_id ), obj.label ) ) - elif existing and replace_id: - if replace_version.newer_version: - # If the user has picked an old version, switch to the newest version - replace_version = get_versions( replace_version )[0] - if replace_version.tool_id != meta.id: - raise UploadError( 'The new %s id (%s) does not match the old %s id (%s). Check the %s config files.' % \ - ( obj.label, str( meta.id ), obj.label, str( replace_version.tool_id ), obj.label ) ) - for old_version in get_versions( replace_version ): - if old_version.version == meta.version: - raise UploadError( 'The new version (%s) matches an old version. Check your version in the %s config file.' % \ - ( str( meta.version ), obj.label ) ) - if old_version.is_new: - raise UploadError( 'There is an existing version of this %s which has not yet been submitted for approval, so either <a href="%s">submit it or delete it</a> before uploading a new version.' % \ - ( obj.label, - url_for( controller='common', - action='view_tool', - cntrller='tool', - id=trans.security.encode_id( old_version.id ) ) ) ) - if old_version.is_waiting: - raise UploadError( 'There is an existing version of this %s which is waiting for administrative approval, so contact an administrator for help.' % \ - obj.label ) - # Defer setting the id since the newer version id doesn't exist until the new Tool object is flushed - if category_ids: - for category_id in category_ids: - category = trans.app.model.Category.get( trans.security.decode_id( category_id ) ) - # Initialize the tool category - tca = trans.app.model.ToolCategoryAssociation( obj, category ) - trans.sa_session.add( tca ) - # Initialize the tool event - event = trans.app.model.Event( state=trans.app.model.Tool.states.NEW ) - # Flush to get an event id - trans.sa_session.add( event ) - trans.sa_session.flush() - tea = trans.app.model.ToolEventAssociation( obj, event ) - trans.sa_session.add( tea ) - if replace_version and replace_id: - replace_version.newer_version_id = obj.id - trans.sa_session.add( replace_version ) - # TODO: should the state be changed to archived? We'll leave it alone for now - # because if the newer version is deleted, we'll need to add logic to reset the - # the older version back to it's previous state ( possible approved ). - comment = "Replaced by new version %s" % obj.version - event = trans.app.model.Event( state=replace_version.state, comment=comment ) - # Flush to get an event id - trans.sa_session.add( event ) - trans.sa_session.flush() - tea = trans.app.model.ToolEventAssociation( replace_version, event ) - trans.sa_session.flush() - try: - os.link( uploaded_file.name, obj.file_name ) - except OSError: - shutil.copy( uploaded_file.name, obj.file_name ) - # We're setting cntrller to 'tool' since that is the only controller from which we can upload - # TODO: this will need tweaking when we can upload histories or workflows - return trans.response.send_redirect( web.url_for( controller='common', - action='edit_tool', - cntrller='tool', - id=trans.app.security.encode_id( obj.id ), - message='Uploaded %s' % meta.message, - status='done' ) ) - except ( datatypes.DatatypeVerificationError, UploadError ), e: - message = str( e ) - status = 'error' - uploaded_file.close() - elif replace_id is not None: - old_version = None - for old_version in get_versions( replace_version ): - if old_version.is_new: - message = 'There is an existing version of this tool which has not been submitted for approval, so either submit or delete it before uploading a new version.' - break - if old_version.is_waiting: - message = 'There is an existing version of this tool which is waiting for administrative approval, so contact an administrator for help.' - break - else: - old_version = None - if old_version is not None: - return trans.response.send_redirect( web.url_for( controller='common', - action='view_tool', - cntrller='tool', - id=trans.app.security.encode_id( old_version.id ), - message=message, - status='error' ) ) - selected_categories = [ trans.security.decode_id( id ) for id in category_ids ] - datatype_extensions = trans.app.datatypes_registry.get_datatype_extensions() - upload_type_select_list = build_select_field( trans, - objs=datatype_extensions, - label_attr='self', - select_field_name='upload_type', - initial_value=upload_type, - selected_value=upload_type, - refresh_on_change=True ) - return trans.fill_template( '/webapps/community/upload/upload.mako', - message=message, - status=status, - selected_upload_type=upload_type, - upload_type_select_list=upload_type_select_list, - replace_id=replace_id, - selected_categories=selected_categories, - categories=get_categories( trans ) ) --- a/lib/galaxy/webapps/community/model/mapping.py Thu Jun 02 14:18:34 2011 -0400 +++ b/lib/galaxy/webapps/community/model/mapping.py Thu Jun 02 15:18:35 2011 -0400 @@ -122,22 +122,6 @@ Column( "repository_id", Integer, ForeignKey( "repository.id" ), index=True ), Column( "category_id", Integer, ForeignKey( "category.id" ), index=True ) ) -Tool.table = Table( "tool", metadata, - Column( "id", Integer, primary_key=True ), - Column( "guid", TrimmedString( 255 ), index=True, unique=True ), - Column( "tool_id", TrimmedString( 255 ), index=True ), - Column( "create_time", DateTime, default=now ), - Column( "update_time", DateTime, default=now, onupdate=now ), - Column( "newer_version_id", Integer, ForeignKey( "tool.id" ), nullable=True ), - Column( "name", TrimmedString( 255 ), index=True ), - Column( "description" , TEXT ), - Column( "user_description" , TEXT ), - Column( "version", TrimmedString( 255 ) ), - Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), index=True ), - Column( "external_filename" , TEXT ), - Column( "deleted", Boolean, index=True, default=False ), - Column( "suite", Boolean, default=False, index=True ) ) - Category.table = Table( "category", metadata, Column( "id", Integer, primary_key=True ), Column( "create_time", DateTime, default=now ), @@ -146,32 +130,6 @@ Column( "description" , TEXT ), Column( "deleted", Boolean, index=True, default=False ) ) -ToolCategoryAssociation.table = Table( "tool_category_association", metadata, - Column( "id", Integer, primary_key=True ), - Column( "tool_id", Integer, ForeignKey( "tool.id" ), index=True ), - Column( "category_id", Integer, ForeignKey( "category.id" ), index=True ) ) - -Event.table = Table( 'event', metadata, - Column( "id", Integer, primary_key=True ), - Column( "create_time", DateTime, default=now ), - Column( "update_time", DateTime, default=now, onupdate=now ), - Column( "state", TrimmedString( 255 ), index=True ), - Column( "comment", TEXT ) ) - -ToolEventAssociation.table = Table( "tool_event_association", metadata, - Column( "id", Integer, primary_key=True ), - Column( "tool_id", Integer, ForeignKey( "tool.id" ), index=True ), - Column( "event_id", Integer, ForeignKey( "event.id" ), index=True ) ) - -ToolRatingAssociation.table = Table( "tool_rating_association", metadata, - Column( "id", Integer, primary_key=True ), - Column( "create_time", DateTime, default=now ), - Column( "update_time", DateTime, default=now, onupdate=now ), - Column( "tool_id", Integer, ForeignKey( "tool.id" ), index=True ), - Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), index=True ), - Column( "rating", Integer, index=True ), - Column( "comment", TEXT ) ) - Tag.table = Table( "tag", metadata, Column( "id", Integer, primary_key=True ), Column( "type", Integer ), @@ -179,27 +137,10 @@ Column( "name", TrimmedString(255) ), UniqueConstraint( "name" ) ) -ToolTagAssociation.table = Table( "tool_tag_association", metadata, - Column( "id", Integer, primary_key=True ), - Column( "tool_id", Integer, ForeignKey( "tool.id" ), index=True ), - Column( "tag_id", Integer, ForeignKey( "tag.id" ), index=True ), - Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), index=True ), - Column( "user_tname", TrimmedString(255), index=True), - Column( "value", TrimmedString(255), index=True), - Column( "user_value", TrimmedString(255), index=True) ) - -ToolAnnotationAssociation.table = Table( "tool_annotation_association", metadata, - Column( "id", Integer, primary_key=True ), - Column( "tool_id", Integer, ForeignKey( "tool.id" ), index=True ), - Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), index=True ), - Column( "annotation", TEXT, index=True) ) - # With the tables defined we can define the mappers and setup the # relationships between the model objects. assign_mapper( context, User, User.table, - properties=dict( tools=relation( Tool, primaryjoin=( Tool.table.c.user_id == User.table.c.id ), order_by=( Tool.table.c.name ) ), - active_tools=relation( Tool, primaryjoin=( ( Tool.table.c.user_id == User.table.c.id ) & ( not_( Tool.table.c.deleted ) ) ), order_by=( Tool.table.c.name ) ), - active_repositories=relation( Repository, primaryjoin=( ( Repository.table.c.user_id == User.table.c.id ) & ( not_( Repository.table.c.deleted ) ) ), order_by=( Repository.table.c.name ) ), + properties=dict( active_repositories=relation( Repository, primaryjoin=( ( Repository.table.c.user_id == User.table.c.id ) & ( not_( Repository.table.c.deleted ) ) ), order_by=( Repository.table.c.name ) ), galaxy_sessions=relation( GalaxySession, order_by=desc( GalaxySession.table.c.update_time ) ) ) ) assign_mapper( context, Group, Group.table, @@ -233,49 +174,8 @@ assign_mapper( context, Tag, Tag.table, properties=dict( children=relation(Tag, backref=backref( 'parent', remote_side=[Tag.table.c.id] ) ) ) ) -assign_mapper( context, ToolTagAssociation, ToolTagAssociation.table, - properties=dict( tag=relation(Tag, backref="tagged_tools"), user=relation( User ) ) ) - -assign_mapper( context, ToolAnnotationAssociation, ToolAnnotationAssociation.table, - properties=dict( tool=relation( Tool ), user=relation( User ) ) ) - -assign_mapper( context, Tool, Tool.table, - properties = dict( - categories=relation( ToolCategoryAssociation ), - events=relation( ToolEventAssociation, secondary=Event.table, - primaryjoin=( Tool.table.c.id==ToolEventAssociation.table.c.tool_id ), - secondaryjoin=( ToolEventAssociation.table.c.event_id==Event.table.c.id ), - order_by=desc( Event.table.c.update_time ), - viewonly=True, - uselist=True ), - ratings=relation( ToolRatingAssociation, order_by=desc( ToolRatingAssociation.table.c.update_time ), backref="tools" ), - user=relation( User.mapper ), - older_version=relation( - Tool, - primaryjoin=( Tool.table.c.newer_version_id == Tool.table.c.id ), - backref=backref( "newer_version", primaryjoin=( Tool.table.c.newer_version_id == Tool.table.c.id ), remote_side=[Tool.table.c.id] ) ) - ) ) - - -assign_mapper( context, ToolCategoryAssociation, ToolCategoryAssociation.table, - properties=dict( - category=relation( Category ), - tool=relation( Tool ) ) ) - -assign_mapper( context, ToolRatingAssociation, ToolRatingAssociation.table, - properties=dict( tool=relation( Tool ), user=relation( User ) ) ) - -assign_mapper( context, Event, Event.table, - properties=None ) - -assign_mapper( context, ToolEventAssociation, ToolEventAssociation.table, - properties=dict( - tool=relation( Tool ), - event=relation( Event ) ) ) - assign_mapper( context, Category, Category.table, - properties=dict( tools=relation( ToolCategoryAssociation ), - repositories=relation( RepositoryCategoryAssociation ) ) ) + properties=dict( repositories=relation( RepositoryCategoryAssociation ) ) ) assign_mapper( context, Repository, Repository.table, properties = dict( @@ -309,11 +209,8 @@ # Let this go, it could possibly work with db's we don't support log.error( "database_connection contains an unknown SQLAlchemy database dialect: %s" % dialect ) -def init( enable_next_gen_tool_shed, file_path, url, engine_options={}, create_tables=False ): +def init( file_path, url, engine_options={}, create_tables=False ): """Connect mappings to the database""" - if not enable_next_gen_tool_shed: - # Connect tool archive location to the file path - Tool.file_path = file_path # Load the appropriate db module load_egg_for_url( url ) # Create the database engine --- a/lib/galaxy/webapps/community/security/__init__.py Thu Jun 02 14:18:34 2011 -0400 +++ b/lib/galaxy/webapps/community/security/__init__.py Thu Jun 02 15:18:35 2011 -0400 @@ -6,7 +6,6 @@ from galaxy.util.bunch import Bunch from galaxy.util import listify from galaxy.model.orm import * -from galaxy.webapps.community.controllers.common import get_versions log = logging.getLogger(__name__) @@ -77,8 +76,6 @@ elif 'role' in kwd: if 'group' in kwd: return self.associate_group_role( kwd['group'], kwd['role'] ) - elif 'tool' in kwd: - return self.associate_tool_category( kwd['tool'], kwd['category'] ) elif 'repository' in kwd: return self.associate_repository_category( kwd[ 'repository' ], kwd[ 'category' ] ) raise 'No valid method of associating provided components: %s' % kwd @@ -97,11 +94,6 @@ self.sa_session.add( assoc ) self.sa_session.flush() return assoc - def associate_tool_category( self, tool, category ): - assoc = self.model.ToolCategoryAssociation( tool, category ) - self.sa_session.add( assoc ) - self.sa_session.flush() - return assoc def associate_repository_category( self, repository, category ): assoc = self.model.RepositoryCategoryAssociation( repository, category ) self.sa_session.add( assoc ) @@ -162,77 +154,6 @@ self.associate_components( user=user, role=role ) for group in groups: self.associate_components( user=user, group=group ) - def set_entity_category_associations( self, tools=[], categories=[], delete_existing_assocs=True ): - for tool in tools: - if delete_existing_assocs: - for a in tool.categories: - self.sa_session.delete( a ) - self.sa_session.flush() - self.sa_session.refresh( tool ) - for category in categories: - self.associate_components( tool=tool, category=category ) - def can_rate( self, user, user_is_admin, cntrller, item ): - # The current user can rate and review the item if they are an admin or if - # they did not upload the item and the item is approved or archived. - if user and user_is_admin and cntrller == 'admin': - return True - if cntrller in [ 'tool' ] and ( item.is_approved or item.is_archived ) and user != item.user: - return True - return False - def can_approve_or_reject( self, user, user_is_admin, cntrller, item ): - # The current user can approve or reject the item if the user - # is an admin, and the item's state is WAITING. - return user and user_is_admin and cntrller=='admin' and item.is_waiting - def can_delete( self, user, user_is_admin, cntrller, item ): - # The current user can delete the item if they are an admin or if they uploaded the - # item and in either case the item's state is not DELETED. - if user and user_is_admin and cntrller == 'admin': - can_delete = not item.is_deleted - elif cntrller in [ 'tool' ]: - can_delete = user==item.user and not item.is_deleted - else: - can_delete = False - return can_delete - def can_download( self, user, user_is_admin, cntrller, item ): - # The current user can download the item if they are an admin or if the - # item's state is not one of: NEW, WAITING. - if user and user_is_admin and cntrller == 'admin': - return True - elif cntrller in [ 'tool' ]: - can_download = not( item.is_new or item.is_waiting ) - else: - can_download = False - return can_download - def can_edit( self, user, user_is_admin, cntrller, item ): - # The current user can edit the item if they are an admin or if they uploaded the item - # and the item's state is one of: NEW, REJECTED. - if user and user_is_admin and cntrller == 'admin': - return True - if cntrller in [ 'tool' ]: - return user and user==item.user and ( item.is_new or item.is_rejected ) - return False - def can_purge( self, user, user_is_admin, cntrller ): - # The current user can purge the item if they are an admin. - return user and user_is_admin and cntrller == 'admin' - def can_upload_new_version( self, user, item ): - # The current user can upload a new version as long as the item's state is not NEW or WAITING. - if not user: - return False - versions = get_versions( item ) - state_ok = True - for version in versions: - if version.is_new or version.is_waiting: - state_ok = False - break - return state_ok - def can_view( self, user, user_is_admin, cntrller, item ): - # The current user can view the item if they are an admin or if they uploaded the item - # or if the item's state is APPROVED. - if user and user_is_admin and cntrller == 'admin': - return True - if cntrller in [ 'tool' ] and item.is_approved or item.is_archived or item.is_deleted: - return True - return user and user==item.user def can_push( self, user, repository ): # TODO: handle this via the mercurial api. if not user: @@ -246,29 +167,6 @@ allowed = config.get( "web", option ) return user.username in allowed return False - def get_all_action_permissions( self, user, user_is_admin, cntrller, item ): - """Get all permitted actions on item for the current user""" - can_edit = self.can_edit( cntrller, user, user_is_admin, item ) - can_view = self.can_view( cntrller, user, user_is_admin, item ) - can_upload_new_version = self.can_upload_new_version( user, item ) - visible_versions = self.get_visible_versions( user, user_is_admin, cntrller, item ) - can_approve_or_reject = self.can_approve_or_reject( user, user_is_admin, cntrller, item ) - can_delete = self.can_delete( user, user_is_admin, cntrller, item ) - return can_edit, can_view, can_upload_new_version, can_delete, visible_versions, can_approve_or_reject - def get_visible_versions( self, user, user_is_admin, cntrller, item ): - # All previous versions of item can be displayed if the current user is an admin - # or they uploaded item. Otherwise, only versions whose state is APPROVED or - # ARCHIVED will be displayed. - if user and user_is_admin and cntrller == 'admin': - visible_versions = get_versions( item ) - elif cntrller in [ 'tool' ]: - visible_versions = [] - for version in get_versions( item ): - if version.is_approved or version.is_archived or version.user == user: - visible_versions.append( version ) - else: - visible_versions = [] - return visible_versions def get_permitted_actions( filter=None ): '''Utility method to return a subset of RBACAgent's permitted actions''' --- a/scripts/tool_shed/migrate_tools_to_repositories.py Thu Jun 02 14:18:34 2011 -0400 +++ b/scripts/tool_shed/migrate_tools_to_repositories.py Thu Jun 02 15:18:35 2011 -0400 @@ -8,6 +8,8 @@ ====== CRITICAL ======= +0. This script must be run on a repo updated to changeset: 5621:4618be57481b + 1. Before running this script, make sure the following config setting is set in community_wsgi.ini # Enable next-gen tool shed features @@ -16,10 +18,6 @@ 2. This script requires the Galaxy instance to use Postgres for database storage. To run this script, use "sh migrate_tools_to_repositories.sh" from this directory - -TODO: This script currently creates hg repos under the name of the user running the script. When -we get the hgweb stuff working, see if we can correct this, creating repos under the user name of the -user that uploaded the tool archive. ''' import sys, os, subprocess, ConfigParser, shutil, tarfile, tempfile --- a/templates/webapps/community/admin/center.mako Thu Jun 02 14:18:34 2011 -0400 +++ b/templates/webapps/community/admin/center.mako Thu Jun 02 15:18:35 2011 -0400 @@ -6,26 +6,6 @@ <p>The menu on the left provides the following features</p><ul> - %if not trans.app.config.enable_next_gen_tool_shed: - <li> - <strong>Tools</strong> - <p/> - <ul> - <li> - <strong>Tools awaiting approval</strong> - </li> - <p/> - <li> - <strong>Browse by category</strong> - </li> - <p/> - <li> - <strong>Browse all tools</strong> - </li> - <p/> - </ul> - </li> - %endif <li><strong>Categories</strong><p/> --- a/templates/webapps/community/admin/index.mako Thu Jun 02 14:18:34 2011 -0400 +++ b/templates/webapps/community/admin/index.mako Thu Jun 02 15:18:35 2011 -0400 @@ -43,22 +43,8 @@ <div class="page-container" style="padding: 10px;"><div class="toolMenu"><div class="toolSectionList"> - %if trans.app.config.enable_next_gen_tool_shed: - <div class="toolTitle"><a target="galaxy_main" href="${h.url_for( controller='admin', action='browse_categories', webapp='community' )}">Browse by category</a></div> - <div class="toolTitle"><a target="galaxy_main" href="${h.url_for( controller='admin', action='browse_repositories', webapp='community' )}">Browse all repositories</a></div> - %else: - <div class="toolSectionTitle"> - <span>Tools</span> - </div> - <div class="toolSectionBody"> - <div class="toolSectionBg"> - <div class="toolTitle"><a target="galaxy_main" href="${h.url_for( controller='admin', action='browse_tools', operation='tools_by_state', state=trans.model.Tool.states.WAITING, webapp='community' )}">Tools awaiting approval</a></div> - <div class="toolTitle"><a target="galaxy_main" href="${h.url_for( controller='admin', action='browse_categories', webapp='community' )}">Browse by category</a></div> - <div class="toolTitle"><a target="galaxy_main" href="${h.url_for( controller='admin', action='browse_tools', webapp='community' )}">Browse all tools</a></div> - </div> - </div> - <div class="toolSectionPad"></div> - %endif + <div class="toolTitle"><a target="galaxy_main" href="${h.url_for( controller='admin', action='browse_categories', webapp='community' )}">Browse by category</a></div> + <div class="toolTitle"><a target="galaxy_main" href="${h.url_for( controller='admin', action='browse_repositories', webapp='community' )}">Browse all repositories</a></div><div class="toolSectionTitle"> Categories </div> --- a/templates/webapps/community/admin/reject_tool.mako Thu Jun 02 14:18:34 2011 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -<%namespace file="/message.mako" import="render_msg" /> - -<%! - def inherit(context): - if context.get('use_panels'): - return '/webapps/community/base_panels.mako' - else: - return '/base.mako' -%> -<%inherit file="${inherit(context)}"/> - -<%def name="title()">Reject Tool</%def> - -<h2>Reject Tool</h2> - -<ul class="manage-table-actions"> - <li><a class="action-button" id="tool-${tool.id}-popup" class="menubutton">Tool Actions</a></li> - <div popupmenu="tool-${tool.id}-popup"> - <a class="action-button" href="${h.url_for( controller='common', action='view_tool', id=trans.app.security.encode_id( tool.id ), cntrller=cntrller )}">View tool</a> - <a class="action-button" href="${h.url_for( controller='common', action='view_tool_history', id=trans.security.encode_id( tool.id ), cntrller=cntrller )}">Tool history</a> - <a class="action-button" href="${h.url_for( controller='common', action='download_tool', id=trans.security.encode_id( tool.id ), cntrller=cntrller )}">Download tool</a> - </div> -</ul> - -%if message: - ${render_msg( message, status )} -%endif - -<div class="toolForm"> - <div class="toolFormTitle">${tool.name}</div> - <form name="reject_tool" action="${h.url_for( controller='admin', action='reject_tool', id=trans.security.encode_id( tool.id ) )}" method="post" > - <div class="form-row"> - <label>Tool id:</label> - ${tool.tool_id} - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>Version:</label> - ${tool.version} - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>Description:</label> - ${tool.description} - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>User description:</label> - ${tool.user_description} - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>Uploaded by:</label> - ${tool.user.username} - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>Reason for rejection</label> - <textarea name="comments" rows="5" cols="40"></textarea> - <div class="toolParamHelp" style="clear: both;"> - Required - </div> - </div> - <div class="form-row"> - <input type="submit" name="reject_button" value="Reject"/> - <input type="submit" name="cancel_reject_button" value="Cancel"/> - </div> - </form> - </div> -</div> --- a/templates/webapps/community/base_panels.mako Thu Jun 02 14:18:34 2011 -0400 +++ b/templates/webapps/community/base_panels.mako Thu Jun 02 15:18:35 2011 -0400 @@ -26,11 +26,7 @@ <td class="${cls}" style="${style}"><a target="${target}" href="${href}">${display}</a></td></%def> - %if trans.app.config.enable_next_gen_tool_shed: - ${tab( "repositories", "Repositories", h.url_for( controller='/repository', action='index', webapp='community' ) )} - %else: - ${tab( "tools", "Tools", h.url_for( controller='/tool', action='index', webapp='community' ) )} - %endif + ${tab( "repositories", "Repositories", h.url_for( controller='/repository', action='index', webapp='community' ) )} ${tab( "admin", "Admin", h.url_for( controller='/admin', action='index', webapp='community' ), extra_class="admin-only", visible=( trans.user and app.config.is_admin_user( trans.user ) ) )} <td class="tab"> --- a/templates/webapps/community/common/rate_tool.mako Thu Jun 02 14:18:34 2011 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,212 +0,0 @@ -<%namespace file="/message.mako" import="render_msg" /> -<%namespace file="/webapps/community/common/common.mako" import="*" /> - -<% - from galaxy.web.framework.helpers import time_ago - from urllib import quote_plus - - if cntrller in [ 'tool' ] and can_edit: - menu_label = 'Edit information or submit for approval' - else: - menu_label = 'Edit information' -%> - -<%! - def inherit(context): - if context.get('use_panels'): - return '/webapps/community/base_panels.mako' - else: - return '/base.mako' -%> -<%inherit file="${inherit(context)}"/> - -<%def name="stylesheets()"> - ${parent.stylesheets()} - ${h.css( "jquery.rating" )} - <style type="text/css"> - ul.fileBrowser, - ul.toolFile { - margin-left: 0; - padding-left: 0; - list-style: none; - } - ul.fileBrowser { - margin-left: 20px; - } - .fileBrowser li, - .toolFile li { - padding-left: 20px; - background-repeat: no-repeat; - background-position: 0; - min-height: 20px; - } - .toolFile li { - background-image: url( ${h.url_for( '/static/images/silk/page_white_compressed.png' )} ); - } - .fileBrowser li { - background-image: url( ${h.url_for( '/static/images/silk/page_white.png' )} ); - } - </style> -</%def> - -<%def name="javascripts()"> - ${parent.javascripts()} - ${h.js( "jquery.rating" )} -</%def> - -<%def name="title()">Rate Tool</%def> - -<h2>Rate Tool</h2> - -${tool.get_state_message()} -<p/> - -<ul class="manage-table-actions"> - %if can_approve_or_reject: - <li><a class="action-button" href="${h.url_for( controller='admin', action='set_tool_state', state=trans.model.Tool.states.APPROVED, id=trans.security.encode_id( tool.id ), cntrller=cntrller )}">Approve</a></li> - <li><a class="action-button" href="${h.url_for( controller='admin', action='set_tool_state', state=trans.model.Tool.states.REJECTED, id=trans.security.encode_id( tool.id ), cntrller=cntrller )}">Reject</a></li> - %endif - <li><a class="action-button" id="tool-${tool.id}-popup" class="menubutton">Tool Actions</a></li> - <div popupmenu="tool-${tool.id}-popup"> - %if can_edit: - <a class="action-button" href="${h.url_for( controller='common', action='edit_tool', id=trans.app.security.encode_id( tool.id ), cntrller=cntrller )}">${menu_label}</a> - %endif - <a class="action-button" href="${h.url_for( controller='common', action='view_tool_history', id=trans.security.encode_id( tool.id ), cntrller=cntrller )}">Tool history</a> - %if can_download: - <a class="action-button" href="${h.url_for( controller='common', action='download_tool', id=trans.app.security.encode_id( tool.id ), cntrller=cntrller )}">Download tool</a> - %endif - %if can_delete: - <a class="action-button" href="${h.url_for( controller='common', action='delete_tool', id=trans.app.security.encode_id( tool.id ), cntrller=cntrller )}" confirm="Are you sure you want to delete this tool?">Delete tool</a> - %endif - %if can_upload_new_version: - <a class="action-button" href="${h.url_for( controller='common', action='upload_new_tool_version', id=trans.app.security.encode_id( tool.id ), cntrller=cntrller )}">Upload a new version</a> - %endif - %if can_purge: - <li><a class="action-button" href="${h.url_for( controller='admin', action='purge_tool', id=trans.security.encode_id( tool.id ), cntrller=cntrller )}" confirm="Purging removes records from the database, are you sure you want to purge this tool?">Purge tool</a></li> - %endif - </div> -</ul> - -%if message: - ${render_msg( message, status )} -%endif - -%if can_rate: - <div class="toolForm"> - <div class="toolFormTitle">${tool.name}</div> - <div class="toolFormBody"> - <div class="form-row"> - <label>Tool Id:</label> - ${tool.tool_id} - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>Version:</label> - ${tool.version} - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>Description:</label> - ${tool.description} - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>User Description:</label> - %if tool.user_description: - <pre>${tool.user_description}</pre> - %endif - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>Uploaded By:</label> - ${tool.user.username} - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>Date Uploaded:</label> - ${time_ago( tool.create_time )} - <div style="clear: both"></div> - </div> - </div> - </div> - <p/> - <div class="toolForm"> - <div class="toolFormTitle">Rate and Review</div> - <div class="toolFormBody"> - <form id="rate_tool" name="rate_tool" action="${h.url_for( controller='common', action='rate_tool', id=trans.security.encode_id( tool.id ), cntrller=cntrller )}" method="post"> - <div class="form-row"> - <label>Times Rated:</label> - ${num_ratings} - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>Average Rating:</label> - ${render_star_rating( 'avg_rating', avg_rating, disabled=True )} - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>Your Rating:</label> - <% - if tra and tra.rating: - rating = tra.rating - else: - rating = 0 - %> - ${render_star_rating( 'rating', rating )} - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>Review:</label> - %if tra and tra.comment: - <div class="form-row-input"><textarea name="comment" rows="5" cols="35">${tra.comment}</textarea></div> - %else: - <div class="form-row-input"><textarea name="comment" rows="5" cols="35"></textarea></div> - %endif - <div style="clear: both"></div> - </div> - <div class="form-row"> - <input type="submit" name="rate_button" id="rate_button" value="Submit" /> - </div> - </form> - </div> - </div> - <p/> - %if tool.ratings and ( len( tool.ratings ) > 1 or tool.ratings[0] != tra ): - <div class="toolForm"> - <div class="toolFormBody"> - %if display_reviews: - <div class="form-row"> - <a href="${h.url_for( controller='common', action='rate_tool', id=trans.security.encode_id( tool.id ), cntrller=cntrller, display_reviews=False )}"><label>Hide Reviews</label></a> - </div> - <table class="grid"> - <thead> - <tr> - <th>Rating</th> - <th>Comments</th> - <th>Reviewed</th> - <th>User</th> - </tr> - </thead> - <% count = 0 %> - %for review in tool.ratings: - <% - count += 1 - name = 'rating%d' % count - %> - <tr> - <td>${render_star_rating( name, review.rating, disabled=True )}</td> - <td>${review.comment}</td> - <td>${time_ago( review.update_time )}</td> - <td>${review.user.username}</td> - </tr> - %endfor - </table> - %else: - <div class="form-row"> - <a href="${h.url_for( controller='common', action='rate_tool', id=trans.security.encode_id( tool.id ), cntrller=cntrller, display_reviews=True )}"><label>Display Reviews</label></a> - </div> - %endif - </div> - </div> - %endif -%endif --- a/templates/webapps/community/common/view_tool_history.mako Thu Jun 02 14:18:34 2011 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,92 +0,0 @@ -<%namespace file="/message.mako" import="render_msg" /> - -<% - if cntrller in [ 'tool' ] and can_edit: - menu_label = 'Edit information or submit for approval' - else: - menu_label = 'Edit information' -%> - -<%! - def inherit(context): - if context.get('use_panels'): - return '/webapps/community/base_panels.mako' - else: - return '/base.mako' -%> -<%inherit file="${inherit(context)}"/> - -<h2>Tool history</h2> -<ul class="manage-table-actions"> - %if can_approve_or_reject: - <li><a class="action-button" href="${h.url_for( controller='admin', action='set_tool_state', state=trans.model.Tool.states.APPROVED, id=trans.security.encode_id( tool.id ), cntrller=cntrller )}">Approve</a></li> - <li><a class="action-button" href="${h.url_for( controller='admin', action='set_tool_state', state=trans.model.Tool.states.REJECTED, id=trans.security.encode_id( tool.id ), cntrller=cntrller )}">Reject</a></li> - %endif - <li><a class="action-button" id="tool-${tool.id}-popup" class="menubutton">Tool Actions</a></li> - <div popupmenu="tool-${tool.id}-popup"> - %if can_edit: - <a class="action-button" href="${h.url_for( controller='common', action='edit_tool', id=trans.app.security.encode_id( tool.id ), cntrller=cntrller )}">${menu_label}</a> - %endif - %if can_view: - <a class="action-button" href="${h.url_for( controller='common', action='view_tool', id=trans.app.security.encode_id( tool.id ), cntrller=cntrller )}">View tool</a> - %endif - %if can_delete: - <a class="action-button" href="${h.url_for( controller='common', action='delete_tool', id=trans.app.security.encode_id( tool.id ), cntrller=cntrller )}" confirm="Are you sure you want to delete this tool?">Delete tool</a> - %endif - %if can_download: - <a class="action-button" href="${h.url_for( controller='common', action='download_tool', id=trans.app.security.encode_id( tool.id ), cntrller=cntrller )}">Download tool</a> - %endif - </div> -</ul> - -%if message: - ${render_msg( message, status )} -%endif - -<div class="toolForm"> - <div class="toolFormTitle">${tool.name}</div> - <div class="form-row"> - <label>Tool id:</label> - ${tool.tool_id} - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>Version:</label> - ${tool.version} - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>Description:</label> - ${tool.description} - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>User description:</label> - ${tool.user_description} - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>Uploaded by:</label> - ${tool.user.username} - <div style="clear: both"></div> - </div> -</div> -<p/> -<table class="grid"> - <thead> - <tr> - <th>State</th> - <th>Last Update</th> - <th>Comments</th> - </tr> - </thead> - <tbody> - %for state, updated, comments in events: - <tr class="libraryRow libraryOrFolderRow" id="libraryRow"> - <td><b><a>${state}</a></b></td> - <td><a>${updated}</a></td> - <td><a>${comments}</a></td> - </tr> - %endfor - </tbody> -</table> --- a/templates/webapps/community/index.mako Thu Jun 02 14:18:34 2011 -0400 +++ b/templates/webapps/community/index.mako Thu Jun 02 15:18:35 2011 -0400 @@ -45,45 +45,23 @@ <div class="toolMenu"><div class="toolSectionList"><div class="toolSectionPad"></div> - <div class="toolSectionTitle"> - %if trans.app.config.enable_next_gen_tool_shed: - Repositories - %else: - Tools - %endif - </div> + <div class="toolSectionTitle">Repositories</div><div class="toolSectionBody"><div class="toolSectionBg"> - %if trans.app.config.enable_next_gen_tool_shed: - <div class="toolTitle"><a target="galaxy_main" href="${h.url_for( controller='repository', action='browse_categories', webapp='community' )}">Browse by category</a></div> - <div class="toolTitle"><a target="galaxy_main" href="${h.url_for( controller='repository', action='browse_repositories', webapp='community' )}">Browse all repositories</a></div> - %if trans.user: - <div class="toolTitle"><a target="galaxy_main" href="${h.url_for( controller='repository', action='browse_repositories', operation='my_repositories', webapp='community' )}">Browse your repositories</a></div> - %endif - %else: - <div class="toolTitle"><a target="galaxy_main" href="${h.url_for( controller='tool', action='browse_categories', webapp='community' )}">Browse by category</a></div> - <div class="toolTitle"><a target="galaxy_main" href="${h.url_for( controller='tool', action='browse_tools', operation='approved_tools', webapp='community' )}">Browse all tools</a></div> - %if trans.user: - <div class="toolTitle"><a target="galaxy_main" href="${h.url_for( controller='tool', action='browse_tools', operation='my_tools', webapp='community' )}">Browse your tools</a></div> - %endif + <div class="toolTitle"><a target="galaxy_main" href="${h.url_for( controller='repository', action='browse_categories', webapp='community' )}">Browse by category</a></div> + <div class="toolTitle"><a target="galaxy_main" href="${h.url_for( controller='repository', action='browse_repositories', webapp='community' )}">Browse all repositories</a></div> + %if trans.user: + <div class="toolTitle"><a target="galaxy_main" href="${h.url_for( controller='repository', action='browse_repositories', operation='my_repositories', webapp='community' )}">Browse my repositories</a></div> %endif </div></div><div class="toolSectionBody"><div class="toolSectionBg"><div class="toolTitle"> - %if trans.app.config.enable_next_gen_tool_shed: - %if trans.user: - <a target="galaxy_main" href="${h.url_for( controller='repository', action='create_repository', webapp='community' )}">Create new repository</a> - %else: - <a target="galaxy_main" href="${h.url_for( controller='/user', action='login', webapp='community' )}">Login to create a repository</a> - %endif + %if trans.user: + <a target="galaxy_main" href="${h.url_for( controller='repository', action='create_repository', webapp='community' )}">Create new repository</a> %else: - %if trans.user: - <a target="galaxy_main" href="${h.url_for( controller='tool_upload', action='upload', type='tool', webapp='community' )}">Upload a tool</a> - %else: - <a target="galaxy_main" href="${h.url_for( controller='/user', action='login', webapp='community' )}">Login to upload</a> - %endif + <a target="galaxy_main" href="${h.url_for( controller='/user', action='login', webapp='community' )}">Login to create a repository</a> %endif </div></div> @@ -97,10 +75,8 @@ <% if trans.app.config.require_login and not trans.user: center_url = h.url_for( controller='user', action='login', message=message, status=status, webapp='community' ) - elif trans.app.config.enable_next_gen_tool_shed: + else: center_url = h.url_for( controller='repository', action='browse_categories', message=message, status=status, webapp='community' ) - else: - center_url = h.url_for( controller='tool', action='browse_categories', message=message, status=status, webapp='community' ) %><iframe name="galaxy_main" id="galaxy_main" frameborder="0" style="position: absolute; width: 100%; height: 100%;" src="${center_url}"></iframe></%def> --- a/templates/webapps/community/tool/edit_tool.mako Thu Jun 02 14:18:34 2011 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,192 +0,0 @@ -<%inherit file="/base.mako"/> -<%namespace file="/message.mako" import="render_msg" /> - -<% - from galaxy.web.framework.helpers import time_ago -%> - -<%! - def inherit(context): - if context.get('use_panels'): - return '/webapps/community/base_panels.mako' - else: - return '/base.mako' -%> -<%inherit file="${inherit(context)}"/> - -<%def name="javascripts()"> - ${parent.javascripts()} - <script type="text/javascript"> - $(function(){ - $("input:text:first").focus(); - }) - function confirmSubmit() { - if ( confirm( "Make sure you have filled in the User Description field. After you have submitted your tool to be published, you will no longer be able to modify it. Click OK to submit it." ) ) { - return true; - } else { - return false; - } - } - </script> -</%def> - -<%def name="render_select( name, options )"> - <select name="${name}" id="${name}" style="min-width: 250px; height: 150px;" multiple> - %for option in options: - <option value="${option[0]}">${option[1]}</option> - %endfor - </select> -</%def> - -<script type="text/javascript"> -$().ready(function() { - $('#categories_add_button').click(function() { - return !$('#out_categories option:selected').remove().appendTo('#in_categories'); - }); - $('#categories_remove_button').click(function() { - return !$('#in_categories option:selected').remove().appendTo('#out_categories'); - }); - $('form#edit_tool').submit(function() { - $('#in_categories option').each(function(i) { - $(this).attr("selected", "selected"); - }); - }); -}); -</script> - -<%def name="title()">Edit Tool</%def> - -<h2>Edit Tool</h2> - -${tool.get_state_message()} -<p/> - -<ul class="manage-table-actions"> - %if can_approve_or_reject: - <li><a class="action-button" href="${h.url_for( controller='admin', action='set_tool_state', state=trans.model.Tool.states.APPROVED, id=trans.security.encode_id( tool.id ), cntrller=cntrller )}">Approve</a></li> - <li><a class="action-button" href="${h.url_for( controller='admin', action='set_tool_state', state=trans.model.Tool.states.REJECTED, id=trans.security.encode_id( tool.id ), cntrller=cntrller )}">Reject</a></li> - %endif - <li><a class="action-button" id="tool-${tool.id}-popup" class="menubutton">Tool Actions</a></li> - <div popupmenu="tool-${tool.id}-popup"> - %if can_view: - <a class="action-button" href="${h.url_for( controller='common', action='view_tool_history', id=trans.app.security.encode_id( tool.id ), cntrller=cntrller )}">Tool history</a> - <a class="action-button" href="${h.url_for( controller='common', action='view_tool', id=trans.app.security.encode_id( tool.id ), cntrller=cntrller )}">View tool</a> - %endif - %if can_download: - <a class="action-button" href="${h.url_for( controller='common', action='download_tool', id=trans.app.security.encode_id( tool.id ), cntrller=cntrller )}">Download tool</a> - %endif - %if can_delete: - <a class="action-button" href="${h.url_for( controller='common', action='delete_tool', id=trans.app.security.encode_id( tool.id ), cntrller=cntrller )}" confirm="Are you sure you want to delete this tool?">Delete tool</a> - %endif - %if can_upload_new_version: - <a class="action-button" href="${h.url_for( controller='common', action='upload_new_tool_version', id=trans.app.security.encode_id( tool.id ), cntrller=cntrller )}">Upload a new version</a> - %endif - %if can_purge: - <li><a class="action-button" href="${h.url_for( controller='admin', action='purge_tool', id=trans.security.encode_id( tool.id ), cntrller=cntrller )}" confirm="Purging removes records from the database, are you sure you want to purge this tool?">Purge tool</a></li> - %endif - </div> -</ul> - -%if message: - ${render_msg( message, status )} -%endif - -%if can_edit: - <form id="edit_tool" name="edit_tool" action="${h.url_for( controller='common', action='edit_tool' )}" method="post"> - %if tool.is_rejected: - <div class="toolForm"> - <div class="toolFormTitle">Reason for rejection</div> - <div class="toolFormBody"> - <div class="form-row"> - ${reason_for_rejection} - <div style="clear: both"></div> - </div> - </div> - </div> - <p/> - %endif - <div class="toolForm"> - <div class="toolFormTitle">${tool.name}</div> - <div class="toolFormBody"> - <input type="hidden" name="id" value="${trans.app.security.encode_id( tool.id )}"/> - <input type="hidden" name="cntrller" value="${cntrller}"/> - <div class="form-row"> - <label>Tool Id:</label> - ${tool.tool_id} - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>Version:</label> - ${tool.version} - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>Description:</label> - ${tool.description} - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>User Description:</label> - %if tool.user_description: - <div class="form-row-input"><pre><textarea name="user_description" rows="5" cols="35">${tool.user_description}</textarea></pre></div> - %else: - <div class="form-row-input"><textarea name="user_description" rows="5" cols="35"></textarea></div> - %endif - <div class="toolParamHelp" style="clear: both;">Required when submitting for approval</div> - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>Uploaded by:</label> - ${tool.user.username} - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>Date uploaded:</label> - ${time_ago( tool.create_time )} - <div style="clear: both"></div> - </div> - </div> - </div> - <p/> - <div class="toolForm"> - <div class="toolFormTitle">Manage categories</div> - <div class="toolFormBody"> - <div class="form-row"> - <div style="float: left; margin-right: 10px;"> - <label>Categories associated with '${tool.name}'</label> - ${render_select( "in_categories", in_categories )}<br/> - <input type="submit" id="categories_remove_button" value=">>"/> - </div> - <div> - <label>Categories not associated with '${tool.name}'</label> - ${render_select( "out_categories", out_categories )}<br/> - <input type="submit" id="categories_add_button" value="<<"/> - </div> - </div> - <div class="form-row"> - <input type="submit" id="edit_tool_button" name="edit_tool_button" value="Save"/> - </div> - </div> - </div> - <p/> - %if tool.is_new or tool.is_rejected: - <div class="toolForm"> - <div class="toolFormTitle">Get approval for publishing</div> - <div class="toolFormBody"> - <div class="form-row"> - <input type="submit" name="approval_button" id="approval_button" value="Submit for approval" onClick="return confirmSubmit()" /> - </div> - <div class="form-row"> - <div class="toolParamHelp" style="clear: both;"> - Tools must be approved before they are made available to others in the community. After you have submitted - your tool to be published, you will no longer be able to modify it, so make sure the information above is - correct before submitting for approval. - </div> - </div> - </div> - </div> - %endif - </form> -%else: - ${render_msg( "You are not allowed to edit this tool", "error" )} -%endif --- a/templates/webapps/community/tool/grid.mako Thu Jun 02 14:18:34 2011 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -<%inherit file="/grid_base.mako"/> --- a/templates/webapps/community/tool/help.mako Thu Jun 02 14:18:34 2011 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,166 +0,0 @@ -<%namespace file="/message.mako" import="render_msg" /> - -<%! - def inherit(context): - if context.get('use_panels'): - return '/webapps/community/base_panels.mako' - else: - return '/base.mako' -%> -<%inherit file="${inherit(context)}"/> - -<%def name="title()">Tool Help</%def> - -<h2>Tool Help</h2> - -%if message: - ${render_msg( message, status )} -%endif - -<p/> -<div class="toolFormTitle">Creating an archive containing a tool or a suite of tools</div> -<p> - A tool or tool suite archive is a tar-format file (bzipped or gzipped tar are valid) - containing all the files necessary to load the tool(s) into a Galaxy instance. -</p> -<h3>Tool Suite Archive</h3> -<p> - A tools suite must include a file named <code>suite_config.xml</code> which provides information about the id, name, - version and description of the tool suite, as well as the id, name, version and description of each tool - in the suite. Here is an example <code>suite_config.xml</code> file. -</p> -<p> -<pre> - <suite id="lastz_toolsuite" name="Suite of Lastz tools" version="1.0.0"> - <description>This suite contains all of my Lastz tools for Galaxy</description> - <tool id="lastz_wrapper_2" name="Lastz" version="1.1.0"> - <description> map short reads against reference sequence</description> - </tool> - <tool id="lastz_paired_reads_wrapper" name="Lastz paired reads" version="1.0.0"> - <description> map short paired reads against reference sequence</description> - </tool> - </suite> -</pre> -</p> -</p> -<p> - New versions of the suite can be uploaded, replacing an older version of the suite, but the version attribute - of the <suite> tag must be altered the same way that the version attribute of a single tool config must be altered - if uploading a new version of a tool. -</p> -<p> - The id, name and version attributes of each <tool> tag in the <code>suite_config.xml</code> file must exactly match the same - attributes in each associated tool config in the archive or you will not be allowed to upload the archive. -</p> -<p> - In addition to the <code>suite_config.xml</code> file, the archive must include all - <a href="http://bitbucket.org/galaxy/galaxy-central/wiki/ToolConfigSyntax" target="_blank">tool config files</a>, - executables, functional test data (if your tool config includes functional tests) and other files needed for each - of the tools in your suite to function within Galaxy. See the information about single tool archives below for - additional hints to enable ease-of-use when others download your suite of tools. -</p> -<p> - For example, to package the above Lastz suite of tools: -<pre> - user@host:~% tar jcvf ~/Desktop/galaxy_lastz_toolsuite.tar.bz2 lastzsuite - lastzsuite/ - lastzsuite/README - lastzsuite/suite_config.xml - lastzsuite/lastz_paired_reads_wrapper.py - lastzsuite/lastz_paired_reads_wrapper.xml - lastzsuite/lastz_wrapper.py - lastzsuite/lastz_wrapper.xml - lastzsuite/lastz-distrib-1.02.00/ - lastzsuite/lastz-distrib-1.02.00/src/ - lastzsuite/lastz-distrib-1.02.00/src/Makefile - lastzsuite/lastz-distrib-1.02.00/src/version.mak - lastzsuite/lastz-distrib-1.02.00/src/lastz.c - lastzsuite/lastz-distrib-1.02.00/src/lastz.h - ... -</pre> - ~/Desktop/galaxy_lastz_tool.tar.bz2 is now ready to be uploaded. -</p> -<h3>Single Tool Archive</h3> -<p> - A single tool archive must include a - <a href="http://bitbucket.org/galaxy/galaxy-central/wiki/ToolConfigSyntax" target="_blank">tool config file</a> - and will probably also include a tool script. If any steps are necessary to install your tool beyond the basic - instructions below, include a README file to provide details. If the tool (or parts of it) are written in C, - the source code can be included (or put links to the source in the README). Do not include pre-compiled binaries - without source since Galaxy is run on a wide variety of platforms. Also, if you are only wrapping or providing a - Galaxy config for a tool that is not your own, be sure the license allows for redistribution before including any - part of that tool in the archive. -</p> -<p> - There are no requirements about the directory structure inside the archive, but for ease of use it's generally - a good idea to put everything inside a sub-directory, instead of directly at the top level. -</p> -<p> - For example, to package the Lastz tool's config file, Galaxy wrapper, and the C source: -<pre> - user@host:~% tar jcvf ~/Desktop/galaxy_lastz_tool.tar.bz2 lastz - lastz/ - lastz/README - lastz/lastz_wrapper.py - lastz/lastz_wrapper.xml - lastz/lastz-distrib-1.02.00/ - lastz/lastz-distrib-1.02.00/src/ - lastz/lastz-distrib-1.02.00/src/Makefile - lastz/lastz-distrib-1.02.00/src/version.mak - lastz/lastz-distrib-1.02.00/src/lastz.c - lastz/lastz-distrib-1.02.00/src/lastz.h - ... -</pre> - ~/Desktop/galaxy_lastz_tool.tar.bz2 is now ready to be uploaded. -</p> -<h3>Editing Information, Categories, and Submitting For Approval</h3> -<p> - Simply uploading a tool to the Galaxy too shed will not allow other users to find and download your tool. It will - need to be approved by an administrator before it appears in the tool list. -</p> -<p> - After your archive has successfully uploaded, you will be redirected to the Edit Tool page. Provide a detailed - description of what the tool does - this will be used by administrators to understand the tool before approving it - for display on the site. Once approved, this information will be displayed to users who view your tool. In addition, - the site administrators will have configured a number of categories with which you can associate your tool to make it - easy to find by users looking to solve specific problems. Associate as many categories as are relevant to your tool. - You may change the description and associated categories as often as you'd like until you click the "<strong>Submit for - approval</strong>" button. Once submitted, the tool will be approved or rejected by an administrator. If the tool is - rejected, you will see information about why it was rejected, and you can make appropriate changes to the archive and - re-submit it for approval. When it is approved, your archive will be visible to everyone. At that point, the description - and associated categories can only be changed by an administrator. -</p> -<p> - When the tool has been approved or rejected, you may upload a new version by browsing to the tool's "View Tool" page, - clicking the "Tool actions" menu in the upper right corner of the page, and selecting "Upload a new version" from the - menu. -</p> -<hr/> -<h3>Downloading and Installing Tools</h3> -<p> - A tool's download link will send you the tool archive. Once downloaded, unpack the tool on your local Galaxy instance's server: -<pre> - user@host:~% tar xvf galaxy_lastz_tool.tar - ... - user@host:~% tar zxvf galaxy_lastz_tool.tar.gz - ... - user@host:~% tar jxvf galaxy_lastz_tool.tar.bz2 - ... -</pre> - If the archive includes a README file, consult it for installation instructions. If not, follow these basic steps: - <ol> - <li>Create a directory under <code>galaxy_dist/tools/</code> to house downloaded tool(s).</li> - <li>In the new directory, place the XML and any script file(s) which were contained in the archive.</li> - <li> - If the tool includes binaries, you'll need to copy them to a directory on your <code>$PATH</code>. If the tool depends on - C binaries but does not come with them (only source), you'll need to compile the source first. - </li> - <li>Add the tool to <code>galaxy_dist/tool_conf.xml</code>.</li> - <li>Restart your Galaxy server process.</li> - </ol> -</p> -<p> - In the near future, we plan to implement a more direct method to install tools via the Galaxy administrator user interface instead - of placing files on the filesystem and manually managing the <code>tool_conf.xml</code> file. -</p> - --- a/templates/webapps/community/tool/view_tool.mako Thu Jun 02 14:18:34 2011 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,247 +0,0 @@ -<%namespace file="/message.mako" import="render_msg" /> -<%namespace file="/webapps/community/common/common.mako" import="*" /> - -<% - from galaxy.web.framework.helpers import time_ago - from urllib import quote_plus - - if cntrller in [ 'tool' ] and can_edit: - menu_label = 'Edit information or submit for approval' - else: - menu_label = 'Edit information' -%> - -<%! - def inherit(context): - if context.get('use_panels'): - return '/webapps/community/base_panels.mako' - else: - return '/base.mako' -%> -<%inherit file="${inherit(context)}"/> - -<%def name="stylesheets()"> - ${parent.stylesheets()} - ${h.css( "jquery.rating" )} - <style type="text/css"> - ul.fileBrowser, - ul.toolFile { - margin-left: 0; - padding-left: 0; - list-style: none; - } - ul.fileBrowser { - margin-left: 20px; - } - .fileBrowser li, - .toolFile li { - padding-left: 20px; - background-repeat: no-repeat; - background-position: 0; - min-height: 20px; - } - .toolFile li { - background-image: url( ${h.url_for( '/static/images/silk/page_white_compressed.png' )} ); - } - .fileBrowser li { - background-image: url( ${h.url_for( '/static/images/silk/page_white.png' )} ); - } - </style> -</%def> - -<%def name="javascripts()"> - ${parent.javascripts()} - ${h.js( "jquery.rating" )} -</%def> - -<%def name="title()">View Tool</%def> - -<h2>View Tool</h2> - -${tool.get_state_message()} -<p/> - -<ul class="manage-table-actions"> - %if can_approve_or_reject: - <li><a class="action-button" href="${h.url_for( controller='admin', action='set_tool_state', state=trans.model.Tool.states.APPROVED, id=trans.security.encode_id( tool.id ), cntrller=cntrller )}">Approve</a></li> - <li><a class="action-button" href="${h.url_for( controller='admin', action='set_tool_state', state=trans.model.Tool.states.REJECTED, id=trans.security.encode_id( tool.id ), cntrller=cntrller )}">Reject</a></li> - %endif - <li><a class="action-button" id="tool-${tool.id}-popup" class="menubutton">Tool Actions</a></li> - <div popupmenu="tool-${tool.id}-popup"> - %if can_edit: - <a class="action-button" href="${h.url_for( controller='common', action='edit_tool', id=trans.app.security.encode_id( tool.id ), cntrller=cntrller )}">${menu_label}</a> - %endif - <a class="action-button" href="${h.url_for( controller='common', action='view_tool_history', id=trans.security.encode_id( tool.id ), cntrller=cntrller )}">Tool history</a> - %if can_download: - <a class="action-button" href="${h.url_for( controller='common', action='download_tool', id=trans.app.security.encode_id( tool.id ), cntrller=cntrller )}">Download tool</a> - %endif - %if can_rate: - <a class="action-button" href="${h.url_for( controller='common', action='rate_tool', id=trans.app.security.encode_id( tool.id ), cntrller=cntrller )}">Rate tool</a> - %endif - %if can_delete: - <a class="action-button" href="${h.url_for( controller='common', action='delete_tool', id=trans.app.security.encode_id( tool.id ), cntrller=cntrller )}" confirm="Are you sure you want to delete this tool?">Delete tool</a> - %endif - %if can_upload_new_version: - <a class="action-button" href="${h.url_for( controller='common', action='upload_new_tool_version', id=trans.app.security.encode_id( tool.id ), cntrller=cntrller )}">Upload a new version</a> - %endif - %if can_purge: - <li><a class="action-button" href="${h.url_for( controller='admin', action='purge_tool', id=trans.security.encode_id( tool.id ), cntrller=cntrller )}" confirm="Purging removes records from the database, are you sure you want to purge this tool?">Purge tool</a></li> - %endif - </div> -</ul> - -%if message: - ${render_msg( message, status )} -%endif - -%if can_view: - %if tool.is_rejected: - <div class="toolForm"> - <div class="toolFormTitle">Reason for rejection</div> - <div class="toolFormBody"> - <div class="form-row"> - ${reason_for_rejection} - <div style="clear: both"></div> - </div> - </div> - </div> - <p/> - %endif - <div class="toolForm"> - <div class="toolFormTitle">${tool.name}</div> - <div class="toolFormBody"> - <div class="form-row"> - <label>Tool Id:</label> - ${tool.tool_id} - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>Version:</label> - ${tool.version} - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>Description:</label> - ${tool.description} - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>User Description:</label> - %if tool.user_description: - <pre>${tool.user_description}</pre> - %endif - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>Uploaded by:</label> - ${tool.user.username} - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>Date uploaded:</label> - ${time_ago( tool.create_time )} - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>Categories:</label> - %if categories: - <ul> - %for category in categories: - <li>${category.name}</li> - %endfor - </ul> - %else: - none set - %endif - <div style="clear: both"></div> - </div> - %if len( visible_versions ) > 1: - <div class="form-row"> - <label>All Versions:</label> - <ul> - %for version in visible_versions: - %if version == tool: - <li><strong>${version.version} (this version)</strong></li> - %else: - <li><a href="${h.url_for( controller='common', action='view_tool', id=trans.app.security.encode_id( version.id ), cntrller=cntrller )}">${version.version}</a></li> - %endif - %endfor - </ul> - <div style="clear: both"></div> - </div> - %endif - </div> - </div> - <p/> - <div class="toolForm"> - <div class="toolFormTitle">Tool Contents</div> - <div class="toolFormBody"> - <div class="form-row"> - <ul class="toolFile"> - <li><a href="${h.url_for( controller='common', action='download_tool', id=trans.app.security.encode_id( tool.id ), cntrller=cntrller )}">${tool.download_file_name}</a></li> - <ul class="fileBrowser"> - %for name in tool_file_contents: - <li><a href="${h.url_for( controller='tool', action='view_tool_file', id=trans.app.security.encode_id( tool.id ), file_name=quote_plus( name ) )}">${name}</a></li> - %endfor - </ul> - </ul> - </div> - </div> - </div> - <p/> - %if tool.ratings: - <div class="toolForm"> - <div class="toolFormTitle">Rating</div> - <div class="toolFormBody"> - <div class="form-row"> - <label>Times Rated:</label> - ${num_ratings} - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>Average Rating:</label> - ${render_star_rating( 'avg_rating', avg_rating, disabled=True )} - <div style="clear: both"></div> - </div> - </div> - </div> - <p/> - <div class="toolForm"> - <div class="toolFormBody"> - %if display_reviews: - <div class="form-row"> - <a href="${h.url_for( controller='common', action='view_tool', id=trans.security.encode_id( tool.id ), cntrller=cntrller, display_reviews=False )}"><label>Hide Reviews</label></a> - </div> - <table class="grid"> - <thead> - <tr> - <th>Rating</th> - <th>Comments</th> - <th>Reviewed</th> - <th>User</th> - </tr> - </thead> - <% count = 0 %> - %for review in tool.ratings: - <% - count += 1 - name = 'rating%d' % count - %> - <tr> - <td>${render_star_rating( name, review.rating, disabled=True )}</td> - <td>${review.comment}</td> - <td>${time_ago( review.update_time )}</td> - <td>${review.user.username}</td> - </tr> - %endfor - </table> - %else: - <div class="form-row"> - <a href="${h.url_for( controller='common', action='view_tool', id=trans.security.encode_id( tool.id ), cntrller=cntrller, display_reviews=True )}"><label>Display Reviews</label></a> - </div> - %endif - </div> - </div> - %endif - <p/> -%endif Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
Bitbucket