incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject [48/50] git commit: [#6670] Send post-import email
Date Fri, 04 Oct 2013 23:23:54 GMT
[#6670] Send post-import email

- Sends email to all project admins after import completes (successfully)
- Doesn't send email for repo imports since they already send an email

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/92daca53
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/92daca53
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/92daca53

Branch: refs/heads/tv/6670
Commit: 92daca534d980e2d7ccd2b2be41c5d4bd9109e3a
Parents: 74b7854
Author: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Authored: Mon Sep 23 21:47:02 2013 +0000
Committer: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Committed: Fri Oct 4 21:31:03 2013 +0000

----------------------------------------------------------------------
 ForgeImporters/forgeimporters/base.py                | 15 ++++++++++++---
 ForgeImporters/forgeimporters/forge/tracker.py       |  5 +++--
 ForgeImporters/forgeimporters/github/code.py         |  5 +++--
 ForgeImporters/forgeimporters/github/tracker.py      |  5 +++--
 ForgeImporters/forgeimporters/google/code.py         |  5 +++--
 ForgeImporters/forgeimporters/google/tracker.py      |  5 +++--
 .../forgeimporters/templates/importer_base.html      |  6 ++++++
 .../forgeimporters/templates/project_base.html       |  5 +++++
 ForgeImporters/forgeimporters/trac/tickets.py        |  5 +++--
 9 files changed, 41 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/92daca53/ForgeImporters/forgeimporters/base.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/base.py b/ForgeImporters/forgeimporters/base.py
index 616fcd8..d2a006a 100644
--- a/ForgeImporters/forgeimporters/base.py
+++ b/ForgeImporters/forgeimporters/base.py
@@ -45,6 +45,7 @@ from allura.lib import helpers as h
 from allura.lib import exceptions
 from allura.lib import validators as v
 from allura.app import SitemapEntry
+from allura.tasks.mail_tasks import sendmail
 from allura import model as M
 
 from paste.deploy.converters import aslist
@@ -82,7 +83,7 @@ class ImportErrorHandler(object):
         self.project = project
 
     def __enter__(self):
-        pass
+        return self
 
     def __exit__(self, exc_type, exc_val, exc_tb):
         self.importer.clear_pending(self.project)
@@ -95,13 +96,21 @@ class ImportErrorHandler(object):
                 project_name=self.project_name,
                 )
 
+    def success(self, app):
+        with h.push_config(c, project=self.project, app=app):
+            g.post_event('import_tool_task_succeeded',
+                    self.importer.source,
+                    self.importer.tool_label,
+                    )
+
 
 @task(notifications_disabled=True)
 def import_tool(importer_name, project_name=None, mount_point=None, mount_label=None, **kw):
     importer = ToolImporter.by_name(importer_name)
-    with ImportErrorHandler(importer, project_name, c.project):
-        importer.import_tool(c.project, c.user, project_name=project_name,
+    with ImportErrorHandler(importer, project_name, c.project) as handler:
+        app = importer.import_tool(c.project, c.user, project_name=project_name,
                 mount_point=mount_point, mount_label=mount_label, **kw)
+        handler.success(app)
 
 
 class ProjectExtractor(object):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/92daca53/ForgeImporters/forgeimporters/forge/tracker.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/forge/tracker.py b/ForgeImporters/forgeimporters/forge/tracker.py
index f6fe907..819bf8c 100644
--- a/ForgeImporters/forgeimporters/forge/tracker.py
+++ b/ForgeImporters/forgeimporters/forge/tracker.py
@@ -59,8 +59,9 @@ from forgeimporters.base import (
 @task(notifications_disabled=True)
 def import_tool(**kw):
     importer = ForgeTrackerImporter()
-    with ImportErrorHandler(importer, kw.get('project_name'), c.project):
-        importer.import_tool(c.project, c.user, **kw)
+    with ImportErrorHandler(importer, kw.get('project_name'), c.project) as handler:
+        app = importer.import_tool(c.project, c.user, **kw)
+        handler.success(app)
 
 
 class ForgeTrackerImportForm(ToolImportForm):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/92daca53/ForgeImporters/forgeimporters/github/code.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/code.py b/ForgeImporters/forgeimporters/github/code.py
index aa5fe7d..2b7883d 100644
--- a/ForgeImporters/forgeimporters/github/code.py
+++ b/ForgeImporters/forgeimporters/github/code.py
@@ -45,8 +45,9 @@ from forgeimporters.github import GitHubProjectExtractor
 @task(notifications_disabled=True)
 def import_tool(**kw):
     importer = GitHubRepoImporter()
-    with ImportErrorHandler(importer, kw.get('project_name'), c.project):
-        importer.import_tool(c.project, c.user, **kw)
+    with ImportErrorHandler(importer, kw.get('project_name'), c.project) as handler:
+        app = importer.import_tool(c.project, c.user, **kw)
+        handler.success(app)
 
 
 class GitHubRepoImportForm(ToolImportForm):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/92daca53/ForgeImporters/forgeimporters/github/tracker.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/tracker.py b/ForgeImporters/forgeimporters/github/tracker.py
index 60543cc..e3e8536 100644
--- a/ForgeImporters/forgeimporters/github/tracker.py
+++ b/ForgeImporters/forgeimporters/github/tracker.py
@@ -53,8 +53,9 @@ from forgeimporters.base import ToolImportForm, ImportErrorHandler
 @task(notifications_disabled=True)
 def import_tool(**kw):
     importer = GitHubTrackerImporter()
-    with ImportErrorHandler(importer, kw.get('project_name'), c.project):
-        importer.import_tool(c.project, c.user, **kw)
+    with ImportErrorHandler(importer, kw.get('project_name'), c.project) as handler:
+        app = importer.import_tool(c.project, c.user, **kw)
+        handler.success(app)
 
 
 class GitHubTrackerImportForm(ToolImportForm):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/92daca53/ForgeImporters/forgeimporters/google/code.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/google/code.py b/ForgeImporters/forgeimporters/google/code.py
index f8e42b3..2a6b7f1 100644
--- a/ForgeImporters/forgeimporters/google/code.py
+++ b/ForgeImporters/forgeimporters/google/code.py
@@ -88,8 +88,9 @@ def get_repo_class(type_):
 @task(notifications_disabled=True)
 def import_tool(**kw):
     importer = GoogleRepoImporter()
-    with ImportErrorHandler(importer, kw.get('project_name'), c.project):
-        importer.import_tool(c.project, c.user, **kw)
+    with ImportErrorHandler(importer, kw.get('project_name'), c.project) as handler:
+        app = importer.import_tool(c.project, c.user, **kw)
+        handler.success(app)
 
 
 class GoogleRepoImportForm(fe.schema.Schema):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/92daca53/ForgeImporters/forgeimporters/google/tracker.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/google/tracker.py b/ForgeImporters/forgeimporters/google/tracker.py
index d52945e..0802354 100644
--- a/ForgeImporters/forgeimporters/google/tracker.py
+++ b/ForgeImporters/forgeimporters/google/tracker.py
@@ -54,8 +54,9 @@ from forgeimporters.base import (
 @task(notifications_disabled=True)
 def import_tool(**kw):
     importer = GoogleCodeTrackerImporter()
-    with ImportErrorHandler(importer, kw.get('project_name'), c.project):
-        importer.import_tool(c.project, c.user, **kw)
+    with ImportErrorHandler(importer, kw.get('project_name'), c.project) as handler:
+        app = importer.import_tool(c.project, c.user, **kw)
+        handler.success(app)
 
 
 class GoogleCodeTrackerImportForm(ToolImportForm):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/92daca53/ForgeImporters/forgeimporters/templates/importer_base.html
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/templates/importer_base.html b/ForgeImporters/forgeimporters/templates/importer_base.html
index 544f5f0..29ab0a9 100644
--- a/ForgeImporters/forgeimporters/templates/importer_base.html
+++ b/ForgeImporters/forgeimporters/templates/importer_base.html
@@ -83,6 +83,12 @@
       {{ error('mount_point') }}
   </div>
   {% endif %}
+
+  <div>
+    You'll receive an email when the import is finished.
+    Import time varies depending on the amount of data being imported.
+  </div>
+
   <input type="submit" value="Import"/>
 </form>
 {% endblock %}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/92daca53/ForgeImporters/forgeimporters/templates/project_base.html
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/templates/project_base.html b/ForgeImporters/forgeimporters/templates/project_base.html
index 1417a6d..d849601 100644
--- a/ForgeImporters/forgeimporters/templates/project_base.html
+++ b/ForgeImporters/forgeimporters/templates/project_base.html
@@ -137,6 +137,11 @@
         {% endfor %}
     </fieldset>
 
+    <div style="margin:5px">
+      You'll receive an email after each tool import finishes.
+      Import time varies depending on the amount of data being imported.
+    </div>
+
     <input type="submit" value="Import"/>
 </form>
 {% endblock %}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/92daca53/ForgeImporters/forgeimporters/trac/tickets.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/trac/tickets.py b/ForgeImporters/forgeimporters/trac/tickets.py
index 6b2600a..7361373 100644
--- a/ForgeImporters/forgeimporters/trac/tickets.py
+++ b/ForgeImporters/forgeimporters/trac/tickets.py
@@ -61,8 +61,9 @@ from forgetracker.scripts.import_tracker import import_tracker
 @task(notifications_disabled=True)
 def import_tool(**kw):
     importer = TracTicketImporter()
-    with ImportErrorHandler(importer, kw.get('trac_url'), c.project):
-        importer.import_tool(c.project, c.user, **kw)
+    with ImportErrorHandler(importer, kw.get('trac_url'), c.project) as handler:
+        app = importer.import_tool(c.project, c.user, **kw)
+        handler.success(app)
 
 
 class TracTicketImportForm(ToolImportForm):


Mime
View raw message