incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [2/2] git commit: [#6482] start on import page for existing projects
Date Fri, 09 Aug 2013 22:14:16 GMT
[#6482] start on import page for existing projects


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/db0bacbd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/db0bacbd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/db0bacbd

Branch: refs/heads/db/6482
Commit: db0bacbd2b771ecf45316c0826242d16b793e200
Parents: 2c2c3b4
Author: Dave Brondsema <dbrondsema@slashdotmedia.com>
Authored: Fri Aug 9 22:14:07 2013 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Fri Aug 9 22:14:07 2013 +0000

----------------------------------------------------------------------
 ForgeImporters/forgeimporters/base.py | 35 +++++++++++++++++++++++++-----
 ForgeImporters/setup.py               |  3 +++
 2 files changed, 32 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/db0bacbd/ForgeImporters/forgeimporters/base.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/base.py b/ForgeImporters/forgeimporters/base.py
index 8cc3b52..99fc2d7 100644
--- a/ForgeImporters/forgeimporters/base.py
+++ b/ForgeImporters/forgeimporters/base.py
@@ -21,14 +21,15 @@ from pkg_resources import iter_entry_points
 
 from tg import expose, validate, flash, redirect, config
 from tg.decorators import with_trailing_slash
-from pylons import tmpl_context as c
+from pylons import tmpl_context as c, app_globals as g
 from formencode import validators as fev, schema
 
 from allura.lib.decorators import require_post
 from allura.lib.decorators import task
 from allura.lib.security import require_access
-from allura.lib.plugin import ProjectRegistrationProvider
+from allura.lib.plugin import ProjectRegistrationProvider, AdminExtension
 from allura.lib import exceptions
+from allura.app import SitemapEntry
 
 from paste.deploy.converters import aslist
 
@@ -189,16 +190,16 @@ class ToolImporter(object):
     source = None  # string description of source, must match project importer
     controller = None
 
-    @classmethod
-    def by_name(self, name):
+    @staticmethod
+    def by_name(name):
         """
         Return a ToolImporter subclass instance given its entry-point name.
         """
         for ep in iter_entry_points('allura.importers', name):
             return ep.load()()
 
-    @classmethod
-    def by_app(self, app):
+    @staticmethod
+    def by_app(app):
         """
         Return a ToolImporter subclass instance given its target_app class.
         """
@@ -266,3 +267,25 @@ class ToolsValidator(fev.Set):
             pl = 's' if len(invalid) > 1 else ''
             raise fev.Invalid('Invalid tool%s selected: %s' % (pl, ', '.join(invalid)), value,
state)
         return valid
+
+class ProjectToolsImportController(object):
+    '''List all importers available'''
+
+    @expose('jinja:forgeimporters:templates/list_all.html')
+    def index(self, *a, **kw):
+        importers = {}
+        for app_name, app in g.entry_points['tool'].iteritems():
+            importers[app] = ToolImporter.by_app(app).values()
+        return {
+            'importers': importers
+        }
+
+class ImportAdminExtension(AdminExtension):
+    '''Add import link to project admin sidebar'''
+
+    project_admin_controllers = {'import': ProjectToolsImportController}
+
+    def update_project_sidebar_menu(self, sidebar_links):
+        base_url = c.project.url() + 'admin/ext/'
+        link = SitemapEntry('Import', base_url+'import')
+        sidebar_links.append(link)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/db0bacbd/ForgeImporters/setup.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/setup.py b/ForgeImporters/setup.py
index b19fd17..d9af953 100644
--- a/ForgeImporters/setup.py
+++ b/ForgeImporters/setup.py
@@ -41,4 +41,7 @@ setup(name='ForgeImporters',
       google-code-tracker = forgeimporters.google.tracker:GoogleCodeTrackerImporter
       google-code-repo = forgeimporters.google.code:GoogleRepoImporter
       trac-tickets = forgeimporters.trac.tickets:TracTicketImporter
+
+      [allura.admin]
+      importers = forgeimporters.base:ImportAdminExtension
       """,)


Mime
View raw message