commit/galaxy-central: greg: Add the ability to browse writable repositories in a tool shed.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/c87370c5340d/ changeset: c87370c5340d user: greg date: 2012-08-28 17:01:07 summary: Add the ability to browse writable repositories in a tool shed. affected #: 2 files diff -r 5adbc8515631847cb66378ea28e644344d890265 -r c87370c5340d359d72301234a958c138adfecd7e lib/galaxy/webapps/community/controllers/repository.py --- a/lib/galaxy/webapps/community/controllers/repository.py +++ b/lib/galaxy/webapps/community/controllers/repository.py @@ -246,6 +246,25 @@ grids.GridAction( "User preferences", dict( controller='user', action='index', cntrller='repository', webapp='community' ) ) ] +class WritableRepositoryListGrid( RepositoryListGrid ): + def build_initial_query( self, trans, **kwd ): + # TODO: improve performance by adding a db table associating users with repositories for which they have write access. + username = kwd[ 'username' ] + clause_list = [] + for repository in trans.sa_session.query( self.model_class ): + allow_push_usernames = repository.allow_push.split( ',' ) + if username in allow_push_usernames: + clause_list.append( self.model_class.table.c.id == repository.id ) + if clause_list: + return trans.sa_session.query( self.model_class ) \ + .filter( or_( *clause_list ) ) \ + .join( model.User.table ) \ + .outerjoin( model.RepositoryCategoryAssociation.table ) \ + .outerjoin( model.Category.table ) + # Return an empty query. + return trans.sa_session.query( self.model_class ) \ + .filter( self.model_class.table.c.id < 0 ) + class ValidRepositoryListGrid( RepositoryListGrid ): class CategoryColumn( grids.TextColumn ): def get_value( self, trans, grid, repository ): @@ -393,6 +412,7 @@ email_alerts_repository_list_grid = EmailAlertsRepositoryListGrid() category_list_grid = CategoryListGrid() valid_category_list_grid = ValidCategoryListGrid() + writable_repository_list_grid = WritableRepositoryListGrid() def __add_hgweb_config_entry( self, trans, repository, repository_path ): # Add an entry in the hgweb.config file for a new repository. An entry looks something like: @@ -519,12 +539,15 @@ repository_id = kwd.get( 'id', None ) repository = get_repository( trans, repository_id ) kwd[ 'f-email' ] = repository.user.email - elif operation == "my_repositories": + elif operation == "repositories_i_own": # 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 + elif operation == "writable_repositories": + kwd[ 'username' ] = trans.user.username + return self.writable_repository_list_grid( trans, **kwd ) elif operation == "repositories_by_category": # Eliminate the current filters if any exist. for k, v in kwd.items(): diff -r 5adbc8515631847cb66378ea28e644344d890265 -r c87370c5340d359d72301234a958c138adfecd7e templates/webapps/community/index.mako --- a/templates/webapps/community/index.mako +++ b/templates/webapps/community/index.mako @@ -60,34 +60,41 @@ %endif <div class="toolSectionPad"></div><div class="toolSectionTitle"> - Repositories + All Repositories </div> - <div class="toolSectionBody"> - <div class="toolSectionBg"> - <div class="toolTitle"> - <a target="galaxy_main" href="${h.url_for( controller='repository', action='browse_categories', webapp='community' )}">Browse by category</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> - <div class="toolTitle"> - <a target="galaxy_main" href="${h.url_for( controller='repository', action='browse_invalid_tools', cntrller='repository', webapp='community' )}">Browse my invalid 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> + %if trans.user: + <div class="toolSectionPad"></div> + <div class="toolSectionTitle"> + My Repositories and Tools </div> - </div> - <div class="toolSectionBody"> - <div class="toolSectionBg"> - <div class="toolTitle"> - %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 - </div> + <div class="toolTitle"> + <a target="galaxy_main" href="${h.url_for( controller='repository', action='browse_repositories', operation='repositories_i_own', webapp='community' )}">Repositories I own</a></div> - </div> + <div class="toolTitle"> + <a target="galaxy_main" href="${h.url_for( controller='repository', action='browse_repositories', operation='writable_repositories', webapp='community' )}">My writable repositories</a> + </div> + <div class="toolTitle"> + <a target="galaxy_main" href="${h.url_for( controller='repository', action='browse_invalid_tools', cntrller='repository', webapp='community' )}">My invalid tools</a> + </div> + <div class="toolSectionPad"></div> + <div class="toolSectionTitle"> + Available Actions + </div> + <div class="toolTitle"> + <a target="galaxy_main" href="${h.url_for( controller='repository', action='create_repository', webapp='community' )}">Create new repository</a> + </div> + %else: + <div class="toolSectionPad"></div> + <div class="toolSectionTitle"> + Available Actions + </div> + <div class="toolTitle"> + <a target="galaxy_main" href="${h.url_for( controller='/user', action='login', webapp='community' )}">Login to create a repository</a> + </div> + %endif </div></div></div> 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