incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [04/50] git commit: [#3154] ticket:386 Check export status in UI
Date Fri, 23 Aug 2013 16:58:04 GMT
[#3154] ticket:386 Check export status in UI


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

Branch: refs/heads/cj/6530
Commit: 88bfef18130b98482000697379f90484e531893e
Parents: 8e3dfa2
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Thu Jul 4 16:00:36 2013 +0300
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Thu Aug 22 20:04:40 2013 +0000

----------------------------------------------------------------------
 Allura/allura/ext/admin/admin_main.py         |  8 +++++++-
 Allura/allura/ext/admin/templates/export.html | 10 ++++++++++
 Allura/allura/tests/functional/test_admin.py  | 16 ++++++++++++++++
 3 files changed, 33 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/88bfef18/Allura/allura/ext/admin/admin_main.py
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/admin_main.py b/Allura/allura/ext/admin/admin_main.py
index 6b39c35..ee59e1d 100644
--- a/Allura/allura/ext/admin/admin_main.py
+++ b/Allura/allura/ext/admin/admin_main.py
@@ -646,10 +646,16 @@ class ProjectAdminController(BaseController):
             if not set(tools).issubset(allowed):
                 flash('Wrong tools in input data', 'error')
                 redirect('export')
+            if c.project.bulk_export_status() == 'busy':
+                flash('Export for project %s already running' % c.project.shortname, 'info')
+                redirect('export')
             export_tasks.bulk_export.post(c.project.shortname, tools)
             flash('Export scheduled', 'ok')
             redirect('export')
-        return {'tools': exportable_tools}
+        return {
+            'tools': exportable_tools,
+            'status': c.project.bulk_export_status()
+        }
 
 
 class PermissionsController(BaseController):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/88bfef18/Allura/allura/ext/admin/templates/export.html
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/templates/export.html b/Allura/allura/ext/admin/templates/export.html
index 6b69fdc..eff9d5a 100644
--- a/Allura/allura/ext/admin/templates/export.html
+++ b/Allura/allura/ext/admin/templates/export.html
@@ -23,6 +23,16 @@
 {% block header %}Project Export{% endblock %}
 
 {% block content %}
+
+{% if status == 'ready' %}
+<div class="error">
+  <h2>Careful!</h2>
+  This project has been exported already.
+  Follow instructions in notification email to get the exported data.
+  If you run export again previous exported data will be lost.
+</div>
+{% endif %}
+
 <div class="grid-19">
   {% if tools %}
     <form method="POST" action="">

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/88bfef18/Allura/allura/tests/functional/test_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_admin.py b/Allura/allura/tests/functional/test_admin.py
index fd8d791..8e205b5 100644
--- a/Allura/allura/tests/functional/test_admin.py
+++ b/Allura/allura/tests/functional/test_admin.py
@@ -17,6 +17,7 @@
 
 import re
 import os, allura
+import shutil
 import pkg_resources
 import StringIO
 from contextlib import contextmanager
@@ -827,3 +828,18 @@ class TestExport(TestController):
         assert_in('ok', self.webflash(r))
         export_tasks.bulk_export.post.assert_called_once_with(
             'test', [u'wiki', u'wiki2'])
+
+    @patch('allura.ext.admin.admin_main.export_tasks')
+    def test_export_in_progress(self, export_tasks):
+        p = M.Project.query.get(shortname='test')
+        tmpdir = os.path.join(p.bulk_export_path(), p.shortname)
+        shutil.rmtree(tmpdir, ignore_errors=True)
+        os.makedirs(tmpdir)
+        r = self.app.post('/admin/export', {'tools': [u'wiki', u'wiki2']})
+        assert_in('info', self.webflash(r))
+        assert_equals(export_tasks.bulk_export.post.call_count, 0)
+        shutil.rmtree(tmpdir, ignore_errors=True)
+
+    def test_export_done(self):
+        r = self.app.get('/admin/export')
+        assert_in('<h2>Careful!</h2>', r)


Mime
View raw message