def undelete_repository(self, trans, **kwd):
     message = escape(kwd.get('message', ''))
     status = kwd.get('status', 'done')
     id = kwd.get('id', None)
     if id:
         # Undeleting multiple items is currently not allowed (allow_multiple=False), so there will only be 1 id.
         ids = util.listify(id)
         count = 0
         undeleted_repositories = ""
         for repository_id in ids:
             repository = suc.get_repository_in_tool_shed(
                 trans.app, repository_id)
             if repository:
                 if repository.deleted:
                     # Inspect all repository_metadata records to determine those that are installable, and mark
                     # them accordingly.
                     for repository_metadata in repository.metadata_revisions:
                         metadata = repository_metadata.metadata
                         if metadata:
                             if metadata_util.is_downloadable(metadata):
                                 repository_metadata.downloadable = True
                                 trans.sa_session.add(repository_metadata)
                     # Mark the repository admin role as not deleted.
                     repository_admin_role = repository.admin_role
                     if repository_admin_role is not None:
                         repository_admin_role.deleted = False
                         trans.sa_session.add(repository_admin_role)
                     repository.deleted = False
                     trans.sa_session.add(repository)
                     trans.sa_session.flush()
                     if not repository.deprecated:
                         # Update the repository registry.
                         trans.app.repository_registry.add_entry(repository)
                     count += 1
                     undeleted_repositories += " %s" % repository.name
         if count:
             message = "Undeleted %d %s: %s" % (
                 count, inflector.cond_plural(
                     count, "repository"), undeleted_repositories)
         else:
             message = "No selected repositories were marked deleted, so they could not be undeleted."
     else:
         message = "No repository ids received for undeleting."
         status = 'error'
     trans.response.send_redirect(
         web.url_for(controller='admin',
                     action='browse_repositories',
                     message=util.sanitize_text(message),
                     status='done'))
Exemple #2
0
 def undelete_repository(self, trans, **kwd):
     message = escape(kwd.get("message", ""))
     id = kwd.get("id", None)
     if id:
         # Undeleting multiple items is currently not allowed (allow_multiple=False), so there will only be 1 id.
         ids = util.listify(id)
         count = 0
         undeleted_repositories = ""
         for repository_id in ids:
             repository = suc.get_repository_in_tool_shed(trans.app, repository_id)
             if repository:
                 if repository.deleted:
                     # Inspect all repository_metadata records to determine those that are installable, and mark
                     # them accordingly.
                     for repository_metadata in repository.metadata_revisions:
                         metadata = repository_metadata.metadata
                         if metadata:
                             if metadata_util.is_downloadable(metadata):
                                 repository_metadata.downloadable = True
                                 trans.sa_session.add(repository_metadata)
                     # Mark the repository admin role as not deleted.
                     repository_admin_role = repository.admin_role
                     if repository_admin_role is not None:
                         repository_admin_role.deleted = False
                         trans.sa_session.add(repository_admin_role)
                     repository.deleted = False
                     trans.sa_session.add(repository)
                     trans.sa_session.flush()
                     if not repository.deprecated:
                         # Update the repository registry.
                         trans.app.repository_registry.add_entry(repository)
                     count += 1
                     undeleted_repositories += " %s" % repository.name
         if count:
             message = "Undeleted %d %s: %s" % (
                 count,
                 inflector.cond_plural(count, "repository"),
                 undeleted_repositories,
             )
         else:
             message = "No selected repositories were marked deleted, so they could not be undeleted."
     else:
         message = "No repository ids received for undeleting."
     trans.response.send_redirect(
         web.url_for(
             controller="admin", action="browse_repositories", message=util.sanitize_text(message), status="done"
         )
     )
Exemple #3
0
 def undelete_repository( self, trans, **kwd ):
     message = kwd.get( 'message', ''  )
     status = kwd.get( 'status', 'done' )
     id = kwd.get( 'id', None )
     if id:
         # Undeleting multiple items is currently not allowed (allow_multiple=False), so there will only be 1 id.
         ids = util.listify( id )
         count = 0
         undeleted_repositories = ""
         for repository_id in ids:
             repository = suc.get_repository_in_tool_shed( trans, repository_id )
             if repository:
                 if repository.deleted:
                     # Inspect all repository_metadata records to determine those that are installable, and mark them accordingly.
                     for repository_metadata in repository.metadata_revisions:
                         metadata = repository_metadata.metadata
                         if metadata:
                             if metadata_util.is_downloadable( metadata ):
                                 repository_metadata.downloadable = True
                                 trans.sa_session.add( repository_metadata )
                     repository.deleted = False
                     trans.sa_session.add( repository )
                     trans.sa_session.flush()
                     count += 1
                     undeleted_repositories += " %s" % repository.name
         if count:
             message = "Undeleted %d %s: %s" % ( count, inflector.cond_plural( count, "repository" ), undeleted_repositories )
         else:
             message = "No selected repositories were marked deleted, so they could not be undeleted."
     else:
         message = "No repository ids received for undeleting."
         status = 'error'
     trans.response.send_redirect( web.url_for( controller='admin',
                                                action='browse_repositories',
                                                message=util.sanitize_text( message ),
                                                status='done' ) )