incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject [03/13] git commit: [#6482] import page for existing projects
Date Wed, 28 Aug 2013 19:30:47 GMT
[#6482] 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/f705a179
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/f705a179
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/f705a179

Branch: refs/heads/master
Commit: f705a17907a7ad196b9d19c3086b79bc94221908
Parents: 09f0290
Author: Dave Brondsema <dbrondsema@slashdotmedia.com>
Authored: Fri Aug 9 22:14:07 2013 +0000
Committer: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Committed: Tue Aug 27 17:24:58 2013 +0000

----------------------------------------------------------------------
 ForgeImporters/forgeimporters/base.py           | 45 ++++++++++++--
 .../forgeimporters/templates/list_all.html      | 62 ++++++++++++++++++++
 ForgeImporters/setup.py                         |  3 +
 3 files changed, 104 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/f705a179/ForgeImporters/forgeimporters/base.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/base.py b/ForgeImporters/forgeimporters/base.py
index 19a3d70..620097e 100644
--- a/ForgeImporters/forgeimporters/base.py
+++ b/ForgeImporters/forgeimporters/base.py
@@ -24,15 +24,17 @@ from pkg_resources import iter_entry_points
 from BeautifulSoup import BeautifulSoup
 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 webob import exc
 
 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 helpers as h
 from allura.lib import exceptions
+from allura.app import SitemapEntry
 
 from paste.deploy.converters import aslist
 
@@ -273,16 +275,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.
         """
@@ -350,3 +352,34 @@ 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'''
+
+    @with_trailing_slash
+    @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)
+        return {
+            'importers': importers
+        }
+
+    @expose()
+    def _lookup(self, name, *remainder):
+        import_tool = ToolImporter.by_name(name)
+        if import_tool:
+            return import_tool.controller(), remainder
+        else:
+            raise exc.HTTPNotFound
+
+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)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/f705a179/ForgeImporters/forgeimporters/templates/list_all.html
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/templates/list_all.html b/ForgeImporters/forgeimporters/templates/list_all.html
new file mode 100644
index 0000000..58c9f34
--- /dev/null
+++ b/ForgeImporters/forgeimporters/templates/list_all.html
@@ -0,0 +1,62 @@
+{#-
+       Licensed to the Apache Software Foundation (ASF) under one
+       or more contributor license agreements.  See the NOTICE file
+       distributed with this work for additional information
+       regarding copyright ownership.  The ASF licenses this file
+       to you under the Apache License, Version 2.0 (the
+       "License"); you may not use this file except in compliance
+       with the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+       Unless required by applicable law or agreed to in writing,
+       software distributed under the License is distributed on an
+       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+       KIND, either express or implied.  See the License for the
+       specific language governing permissions and limitations
+       under the License.
+-#}
+{% extends g.theme.master %}
+{% import 'allura:templates/jinja_master/lib.html' as lib with context %}
+
+{% block title %}{{c.project.name}} / Import{% endblock %}
+
+{% block header %}Import from external sources{% endblock %}
+
+{% block extra_css %}
+<style type="text/css">
+    .tool {
+        margin-bottom: 3em;
+    }
+    .tool img {
+        float: left;
+        margin: 0 1em;
+    }
+    .importer .descr {
+        margin: 0 2em 1em 2em;
+    }
+</style>
+{% endblock %}
+
+{% block content %}
+    {% for tool, tool_importers in importers.iteritems() %}
+        <div class="tool">
+        {% for importer_name, importer in tool_importers.iteritems() %}
+            {% if loop.first %}
+                <img src="{{ g.theme.app_icon_url(tool, 48) }}" alt="{{ tool.tool_label
}} icon">
+                <h2>{{ tool.tool_label }}</h2>
+            {% endif %}
+            <div class="importer">
+                <a href="{{importer_name}}"><h3>
+                {{importer.source}}:
+                {{importer.tool_label}}
+                </h3>
+                </a>
+                <div class="descr">
+                {{importer.tool_description}}
+                </div>
+            </div>
+        {% endfor %}
+        </div>
+    {% endfor %}
+{% endblock %}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/f705a179/ForgeImporters/setup.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/setup.py b/ForgeImporters/setup.py
index cec76b4..d070782 100644
--- a/ForgeImporters/setup.py
+++ b/ForgeImporters/setup.py
@@ -42,4 +42,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