1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/23aac3b3c0e2/ Changeset: 23aac3b3c0e2 User: greg Date: 2014-05-28 18:08:04 Summary: Handle Tool Shed category administration in the Tool Shed's repository registry. Affected #: 2 files
diff -r dbc3d5c3506ed833dc453faa4f00797d95b8a8bb -r 23aac3b3c0e2cfe784d8c5dfd94cc3b6ccff7b7c lib/galaxy/webapps/tool_shed/controllers/admin.py --- a/lib/galaxy/webapps/tool_shed/controllers/admin.py +++ b/lib/galaxy/webapps/tool_shed/controllers/admin.py @@ -132,6 +132,8 @@ category = trans.app.model.Category( name=name, description=description ) trans.sa_session.add( category ) trans.sa_session.flush() + # Update the Tool Shed's repository registry. + trans.app.repository_registry.add_category_entry( category ) message = "Category '%s' has been created" % category.name status = 'done' trans.response.send_redirect( web.url_for( controller='admin', @@ -224,21 +226,32 @@ message=message, status='error' ) ) category = suc.get_category( trans, id ) + original_category_name = str( category.name ) + original_category_description = str( category.description ) if kwd.get( 'edit_category_button', False ): + flush_needed = False new_name = kwd.get( 'name', '' ).strip() new_description = kwd.get( 'description', '' ).strip() - if category.name != new_name or category.description != new_description: + if original_category_name != new_name: if not new_name: message = 'Enter a valid name' status = 'error' - elif category.name != new_name and suc.get_category_by_name( trans, new_name ): + elif original_category_name != new_name and suc.get_category_by_name( trans, new_name ): message = 'A category with that name already exists' status = 'error' else: category.name = new_name + flush_needed = True + if original_category_description != new_description: category.description = new_description + if not flus_needed: + flush_needed = True + if flush_needed: trans.sa_session.add( category ) trans.sa_session.flush() + if original_category_name != new_name: + # Update the Tool Shed's repository registry. + trans.app.repository_registry.edit_category_entry( original_category_name, new_name ) message = "The information has been saved for category '%s'" % ( category.name ) status = 'done' return trans.response.send_redirect( web.url_for( controller='admin', @@ -403,6 +416,8 @@ category.deleted = True trans.sa_session.add( category ) trans.sa_session.flush() + # Update the Tool Shed's repository registry. + trans.app.repository_registry.remove_category_entry( category ) message += " %s " % category.name else: message = "No category ids received for deleting." @@ -459,6 +474,8 @@ category.deleted = False trans.sa_session.add( category ) trans.sa_session.flush() + # Update the Tool Shed's repository registry. + trans.app.repository_registry.add_category_entry( category ) count += 1 undeleted_categories += " %s" % category.name message = "Undeleted %d categories: %s" % ( count, undeleted_categories )
diff -r dbc3d5c3506ed833dc453faa4f00797d95b8a8bb -r 23aac3b3c0e2cfe784d8c5dfd94cc3b6ccff7b7c lib/tool_shed/repository_registry.py --- a/lib/tool_shed/repository_registry.py +++ b/lib/tool_shed/repository_registry.py @@ -41,6 +41,21 @@ self.load_viewable_repositories_and_suites_by_category() self.load_repository_and_suite_tuples()
+ def add_category_entry( self, category ): + category_name = str( category.name ) + if category_name not in self.viewable_repositories_and_suites_by_category: + self.viewable_repositories_and_suites_by_category[ category_name ] = 0 + if category_name not in self.viewable_suites_by_category: + self.viewable_suites_by_category[ category_name ] = 0 + if category_name not in self.viewable_valid_repositories_and_suites_by_category: + self.viewable_valid_repositories_and_suites_by_category[ category_name ] = 0 + if category_name not in self.viewable_valid_suites_by_category: + self.viewable_valid_suites_by_category[ category_name ] = 0 + if category_name not in self.certified_level_one_viewable_repositories_and_suites_by_category: + self.certified_level_one_viewable_repositories_and_suites_by_category[ category_name ] = 0 + if category_name not in self.certified_level_one_viewable_suites_by_category: + self.certified_level_one_viewable_suites_by_category[ category_name ] = 0 + def add_entry( self, repository ): try: if repository: @@ -88,6 +103,44 @@ # will be corrected at next server start. log.exception( "Handled error adding entry to repository registry: %s." % str( e ) )
+ def edit_category_entry( self, old_name, new_name ): + if old_name in self.viewable_repositories_and_suites_by_category: + val = self.viewable_repositories_and_suites_by_category[ old_name ] + del self.viewable_repositories_and_suites_by_category[ old_name ] + self.viewable_repositories_and_suites_by_category[ new_name ] = val + else: + self.viewable_repositories_and_suites_by_category[ new_name ] = 0 + if old_name in self.viewable_valid_repositories_and_suites_by_category: + val = self.viewable_valid_repositories_and_suites_by_category[ old_name ] + del self.viewable_valid_repositories_and_suites_by_category[ old_name ] + self.viewable_valid_repositories_and_suites_by_category[ new_name ] = val + else: + self.viewable_valid_repositories_and_suites_by_category[ new_name ] = 0 + if old_name in self.viewable_suites_by_category: + val = self.viewable_suites_by_category[ old_name ] + del self.viewable_suites_by_category[ old_name ] + self.viewable_suites_by_category[ new_name ] = val + else: + self.viewable_suites_by_category[ new_name ] = 0 + if old_name in self.viewable_valid_suites_by_category: + val = self.viewable_valid_suites_by_category[ old_name ] + del self.viewable_valid_suites_by_category[ old_name ] + self.viewable_valid_suites_by_category[ new_name ] = val + else: + self.viewable_valid_suites_by_category[ new_name ] = 0 + if old_name in self.certified_level_one_viewable_repositories_and_suites_by_category: + val = self.certified_level_one_viewable_repositories_and_suites_by_category[ old_name ] + del self.certified_level_one_viewable_repositories_and_suites_by_category[ old_name ] + self.certified_level_one_viewable_repositories_and_suites_by_category[ new_name ] = val + else: + self.certified_level_one_viewable_repositories_and_suites_by_category[ new_name ] = 0 + if old_name in self.certified_level_one_viewable_suites_by_category: + val = self.certified_level_one_viewable_suites_by_category[ old_name ] + del self.certified_level_one_viewable_suites_by_category[ old_name ] + self.certified_level_one_viewable_suites_by_category[ new_name ] = val + else: + self.certified_level_one_viewable_suites_by_category[ new_name ] = 0 + def get_certified_level_one_clause_list( self ): certified_level_one_tuples = [] clause_list = [] @@ -266,6 +319,21 @@ if repository.type in [ rt_util.REPOSITORY_SUITE_DEFINITION ]: self.certified_level_one_viewable_suites_by_category[ category_name ] += 1
+ def remove_category_entry( self, category ): + catgeory_name = str( category.name ) + if catgeory_name in self.viewable_repositories_and_suites_by_category: + del self.viewable_repositories_and_suites_by_category[ catgeory_name ] + if catgeory_name in self.viewable_valid_repositories_and_suites_by_category: + del self.viewable_valid_repositories_and_suites_by_category[ catgeory_name ] + if catgeory_name in self.viewable_suites_by_category: + del self.viewable_suites_by_category[ catgeory_name ] + if catgeory_name in self.viewable_valid_suites_by_category: + del self.viewable_valid_suites_by_category[ catgeory_name ] + if catgeory_name in self.certified_level_one_viewable_repositories_and_suites_by_category: + del self.certified_level_one_viewable_repositories_and_suites_by_category[ catgeory_name ] + if catgeory_name in self.certified_level_one_viewable_suites_by_category: + del self.certified_level_one_viewable_suites_by_category[ catgeory_name ] + def remove_entry( self, repository ): try: if repository:
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.
galaxy-commits@lists.galaxyproject.org