allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jetm...@apache.org
Subject [3/8] allura git commit: [#7999] ticket:855 Fire task to delete projects from controller
Date Wed, 04 Nov 2015 17:20:21 GMT
[#7999] ticket:855 Fire task to delete projects from controller


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

Branch: refs/heads/ib/7999
Commit: de85b467096f8c82f7ff10885f8e25019bda5b7d
Parents: 91552e1
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Mon Nov 2 14:31:06 2015 +0200
Committer: Igor Bondarenko <jetmind2@gmail.com>
Committed: Mon Nov 2 14:31:06 2015 +0200

----------------------------------------------------------------------
 Allura/allura/controllers/site_admin.py           |  5 ++++-
 Allura/allura/tests/functional/test_site_admin.py | 11 +++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/de85b467/Allura/allura/controllers/site_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/site_admin.py b/Allura/allura/controllers/site_admin.py
index 621963c..b4b0496 100644
--- a/Allura/allura/controllers/site_admin.py
+++ b/Allura/allura/controllers/site_admin.py
@@ -42,6 +42,7 @@ from allura.ext.admin.widgets import AuditLog
 from allura.lib.widgets import forms
 from allura import model as M
 from allura.command.show_models import dfs, build_model_inheritance_graph
+from allura.scripts.delete_projects import DeleteProjects
 import allura
 
 from urlparse import urlparse
@@ -331,7 +332,9 @@ class SiteAdminController(object):
             projects = [provider.project_from_url(p.strip()) for p in projects]
             projects = [p for p in projects if p]
             log.info('Parsed projects: %s', projects)
-            # TODO: fire delete project task
+            task_params = [u'{}/{}'.format(n.strip('/'), p) for (n, p) in projects]
+            task_params = u' '.join(task_params)
+            DeleteProjects.post(task_params)
             flash(u'Delete scheduled for %s' % projects, 'ok')
             redirect('delete_projects')
         return {}

http://git-wip-us.apache.org/repos/asf/allura/blob/de85b467/Allura/allura/tests/functional/test_site_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_site_admin.py b/Allura/allura/tests/functional/test_site_admin.py
index e89b9fd..40066b0 100644
--- a/Allura/allura/tests/functional/test_site_admin.py
+++ b/Allura/allura/tests/functional/test_site_admin.py
@@ -565,6 +565,17 @@ To reset your password on %s, please visit the following URL:
             text=text)
 
 
+class TestDeleteProjects(TestController):
+
+    @patch('allura.controllers.site_admin.DeleteProjects', autospec=True)
+    def test_task_fires(self, dp):
+        r = self.app.get('/nf/admin/delete_projects')
+        form = self.find_form(r, lambda f: f.action == 'delete_projects')
+        form['projects'] = '/p/test http://localhost:8080/adobe/adobe-1 p/test2'
+        form.submit()
+        dp.post.assert_called_once_with('p/test adobe/adobe-1 p/test2')
+
+
 @task
 def test_task(*args, **kw):
     """test_task doc string"""


Mime
View raw message