allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [01/17] allura git commit: [#7999] ticket:855 Fire task to delete projects from controller
Date Wed, 25 Nov 2015 19:37:55 GMT
Repository: allura
Updated Branches:
  refs/heads/master e7b50b500 -> b2b53d0c1


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

Branch: refs/heads/master
Commit: 7fc38c470c1b2811af325f010965a71f21887ce8
Parents: 948777c
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Mon Nov 2 14:31:06 2015 +0200
Committer: Dave Brondsema <dave@brondsema.net>
Committed: Wed Nov 25 14:37:41 2015 -0500

----------------------------------------------------------------------
 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/7fc38c47/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/7fc38c47/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