incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [11/11] git commit: [#6480] Moved Trac wiki importer to separate package
Date Wed, 07 Aug 2013 16:48:13 GMT
[#6480] Moved Trac wiki importer to separate package

Signed-off-by: Tim Van Steenburgh <tvansteenburgh@gmail.com>


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

Branch: refs/heads/master
Commit: 04cd1ed28c73fd25791d4fa6a0ad32a5fec2f157
Parents: 85c29b9
Author: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Authored: Wed Aug 7 14:27:44 2013 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Wed Aug 7 16:47:24 2013 +0000

----------------------------------------------------------------------
 ForgeImporters/forgeimporters/google/project.py |   2 +-
 .../trac/templates/wiki/index.html              |  42 -------
 .../forgeimporters/trac/tests/test_wiki.py      | 104 -----------------
 ForgeImporters/forgeimporters/trac/wiki.py      | 117 -------------------
 ForgeImporters/setup.py                         |   1 -
 5 files changed, 1 insertion(+), 265 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/04cd1ed2/ForgeImporters/forgeimporters/google/project.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/google/project.py b/ForgeImporters/forgeimporters/google/project.py
index dda41ea..e69ac9e 100644
--- a/ForgeImporters/forgeimporters/google/project.py
+++ b/ForgeImporters/forgeimporters/google/project.py
@@ -53,7 +53,7 @@ class GoogleCodeProjectImporter(base.ProjectImporter):
 
     def after_project_create(self, project, **kw):
         project.set_tool_data('google-code', project_name=project.name)
-        tasks.import_project_info.post()
+        tasks.import_project_info.post(project.name)
 
     @with_trailing_slash
     @expose(index_template)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/04cd1ed2/ForgeImporters/forgeimporters/trac/templates/wiki/index.html
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/trac/templates/wiki/index.html b/ForgeImporters/forgeimporters/trac/templates/wiki/index.html
deleted file mode 100644
index 6083b9c..0000000
--- a/ForgeImporters/forgeimporters/trac/templates/wiki/index.html
+++ /dev/null
@@ -1,42 +0,0 @@
-{#-
-       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 %}
-
-{% block title %}
-{{c.project.name}} / Import Trac Wiki
-{% endblock %}
-
-{% block header %}
-Import wiki from Trac
-{% endblock %}
-
-{% block content %}
-<form action="create" method="post" class="pad">
-  <label for="trac_url">URL of the Trac instance</label>
-  <input name="trac_url" />
-
-  <label for="mount_label">Label</label>
-  <input name="mount_label" value="Source" />
-
-  <label for="mount_point">Mount Point</label>
-  <input name="mount_point" value="source" />
-
-  <input type="submit" />
-</form>
-{% endblock %}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/04cd1ed2/ForgeImporters/forgeimporters/trac/tests/test_wiki.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/trac/tests/test_wiki.py b/ForgeImporters/forgeimporters/trac/tests/test_wiki.py
deleted file mode 100644
index 738e49b..0000000
--- a/ForgeImporters/forgeimporters/trac/tests/test_wiki.py
+++ /dev/null
@@ -1,104 +0,0 @@
-#       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.
-
-from unittest import TestCase
-from mock import Mock, patch
-
-from allura.tests import TestController
-from allura.tests.decorators import with_wiki
-
-from forgeimporters.trac.wiki import (
-    TracWikiImporter,
-    TracWikiImportController,
-    )
-
-
-class TestWikiTicketImporter(TestCase):
-    @patch('forgeimporters.trac.wiki.session')
-    @patch('forgeimporters.trac.wiki.tempfile.NamedTemporaryFile')
-    @patch('forgeimporters.trac.wiki.g')
-    @patch('forgeimporters.trac.wiki.WikiFromTrac')
-    @patch('forgeimporters.trac.wiki.load_data')
-    @patch('forgeimporters.trac.wiki.argparse.Namespace')
-    @patch('forgeimporters.trac.wiki.WikiExporter')
-    @patch('forgeimporters.trac.wiki.ApiTicket')
-    @patch('forgeimporters.trac.wiki.datetime')
-    def test_import_tool(self, dt, ApiTicket, WikiExporter, Namespace,
-            load_data, WikiFromTrac, g, NamedTemporaryFile, session):
-        from datetime import datetime, timedelta
-        now = datetime.utcnow()
-        dt.utcnow.return_value = now
-        export_file = NamedTemporaryFile.return_value.__enter__.return_value
-        export_file.name = '/my/file'
-
-        importer = TracWikiImporter()
-        app = Mock(name='ForgeWikiApp')
-        project = Mock(name='Project', shortname='myproject')
-        project.install_app.return_value = app
-        user = Mock(name='User', _id='id')
-        res = importer.import_tool(project, user,
-                mount_point='pages',
-                mount_label='Pages',
-                trac_url='http://example.com/trac/url')
-        self.assertEqual(res, app)
-        project.install_app.assert_called_once_with(
-                'Wiki', mount_point='pages', mount_label='Pages')
-        ApiTicket.assert_called_once_with(
-                user_id=user._id,
-                capabilities={"import": ["Projects", "myproject"]},
-                expires=now + timedelta(minutes=60))
-        WikiExporter.assert_called_once_with('http://example.com/trac/url/',
-                Namespace.return_value)
-        WikiExporter.return_value.export.assert_called_once_with(export_file)
-        load_data.assert_called_once_with('/my/file',
-                WikiFromTrac.parser.return_value, Namespace.return_value)
-        g.post_event.assert_called_once_with('project_updated')
-
-
-class TestTracWikiImportController(TestController, TestCase):
-    def setUp(self):
-        """Mount Trac import controller on the Wiki admin controller"""
-        super(self.__class__, self).setUp()
-        from forgewiki.wiki_main import WikiAdminController
-        WikiAdminController._importer = TracWikiImportController()
-
-    @with_wiki
-    def test_index(self):
-        r = self.app.get('/p/test/admin/wiki/_importer/')
-        self.assertIsNotNone(r.html.find(attrs=dict(name="trac_url")))
-        self.assertIsNotNone(r.html.find(attrs=dict(name="mount_label")))
-        self.assertIsNotNone(r.html.find(attrs=dict(name="mount_point")))
-
-    @with_wiki
-    @patch('forgeimporters.trac.wiki.TracWikiImporter')
-    def test_create(self, importer):
-        from allura import model as M
-        importer = importer.return_value
-        importer.import_tool.return_value = Mock()
-        importer.import_tool.return_value.url.return_value = '/p/test/mymount'
-        params = dict(trac_url='http://example.com/trac/url',
-                mount_label='mylabel',
-                mount_point='mymount',
-                )
-        r = self.app.post('/p/test/admin/wiki/_importer/create', params,
-                status=302)
-        project = M.Project.query.get(shortname='test')
-        self.assertEqual(r.location, 'http://localhost/p/test/mymount')
-        self.assertEqual(project._id, importer.import_tool.call_args[0][0]._id)
-        self.assertEqual(u'mymount', importer.import_tool.call_args[1]['mount_point'])
-        self.assertEqual(u'mylabel', importer.import_tool.call_args[1]['mount_label'])
-        self.assertEqual(u'http://example.com/trac/url', importer.import_tool.call_args[1]['trac_url'])

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/04cd1ed2/ForgeImporters/forgeimporters/trac/wiki.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/trac/wiki.py b/ForgeImporters/forgeimporters/trac/wiki.py
deleted file mode 100644
index 300b476..0000000
--- a/ForgeImporters/forgeimporters/trac/wiki.py
+++ /dev/null
@@ -1,117 +0,0 @@
-#       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.
-
-import argparse
-from datetime import (
-        datetime,
-        timedelta,
-        )
-import tempfile
-
-import formencode as fe
-from formencode import validators as fev
-
-from ming.orm import session
-from pylons import tmpl_context as c
-from pylons import app_globals as g
-from tg import (
-        config,
-        expose,
-        redirect,
-        validate,
-        )
-from tg.decorators import (
-        with_trailing_slash,
-        without_trailing_slash,
-        )
-
-from allura.controllers import BaseController
-from allura.lib.decorators import require_post
-from allura.model import ApiTicket
-
-from forgeimporters.base import ToolImporter
-
-from forgewiki.scripts.wiki_from_trac.extractors import WikiExporter
-from forgewiki.scripts.wiki_from_trac.loaders import load_data
-from forgewiki.scripts.wiki_from_trac.wiki_from_trac import WikiFromTrac
-from forgewiki.wiki_main import ForgeWikiApp
-
-
-class TracWikiImportSchema(fe.Schema):
-    trac_url = fev.URL(not_empty=True)
-    mount_point = fev.UnicodeString()
-    mount_label = fev.UnicodeString()
-
-
-class TracWikiImportController(BaseController):
-    @with_trailing_slash
-    @expose('jinja:forgeimporters.trac:templates/wiki/index.html')
-    def index(self, **kw):
-        return {}
-
-    @without_trailing_slash
-    @expose()
-    @require_post()
-    @validate(TracWikiImportSchema(), error_handler=index)
-    def create(self, trac_url, mount_point, mount_label, **kw):
-        app = TracWikiImporter().import_tool(c.project, c.user,
-                mount_point=mount_point,
-                mount_label=mount_label,
-                trac_url=trac_url)
-        redirect(app.url())
-
-
-class TracWikiImporter(ToolImporter):
-    target_app = ForgeWikiApp
-    source = 'Trac'
-    controller = TracWikiImportController
-    tool_label = 'Trac Wiki Importer'
-    tool_description = 'Import your wiki from Trac'
-
-    def import_tool(self, project, user, project_name=None, mount_point=None,
-            mount_label=None, trac_url=None, **kw):
-        """ Import Trac wiki into a new Allura Wiki tool.
-
-        """
-        trac_url = trac_url.rstrip('/') + '/'
-        mount_point = mount_point or 'wiki'
-        app = project.install_app(
-                'Wiki',
-                mount_point=mount_point,
-                mount_label=mount_label or 'Wiki',
-                )
-        session(app.config).flush(app.config)
-        api_ticket = ApiTicket(user_id=user._id,
-                capabilities={"import": ["Projects", project.shortname]},
-                expires=datetime.utcnow() + timedelta(minutes=60))
-        session(api_ticket).flush(api_ticket)
-        options = argparse.Namespace()
-        options.api_key = api_ticket.api_key
-        options.secret_key = api_ticket.secret_key
-        options.project = project.shortname
-        options.wiki = mount_point
-        options.base_url = config['base_url']
-        options.verbose = False
-        options.converter = 'html2text'
-        options.import_opts = []
-        options.user_map_file = None
-        with tempfile.NamedTemporaryFile() as f:
-            WikiExporter(trac_url, options).export(f)
-            f.flush()
-            load_data(f.name, WikiFromTrac.parser(), options)
-        g.post_event('project_updated')
-        return app

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/04cd1ed2/ForgeImporters/setup.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/setup.py b/ForgeImporters/setup.py
index c4776ba..b19fd17 100644
--- a/ForgeImporters/setup.py
+++ b/ForgeImporters/setup.py
@@ -41,5 +41,4 @@ setup(name='ForgeImporters',
       google-code-tracker = forgeimporters.google.tracker:GoogleCodeTrackerImporter
       google-code-repo = forgeimporters.google.code:GoogleRepoImporter
       trac-tickets = forgeimporters.trac.tickets:TracTicketImporter
-      trac-wiki = forgeimporters.trac.wiki:TracWikiImporter
       """,)


Mime
View raw message