allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [08/17] allura git commit: [#7999] ticket:856 Add link to delete projects from /nf/admin/new_projects
Date Wed, 25 Nov 2015 19:38:02 GMT
[#7999] ticket:856 Add link to delete projects from /nf/admin/new_projects


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

Branch: refs/heads/master
Commit: 0d1a63f56d0263c67da11a26cfe3e21e528cb4d1
Parents: 045e8c4
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Mon Nov 2 16:15:23 2015 +0200
Committer: Dave Brondsema <dave@brondsema.net>
Committed: Wed Nov 25 14:37:42 2015 -0500

----------------------------------------------------------------------
 Allura/allura/controllers/site_admin.py              |  2 +-
 .../allura/public/nf/js/site_admin_new_projects.js   | 15 +++++++++++++++
 .../allura/templates/site_admin_delete_projects.html |  2 +-
 Allura/allura/templates/site_admin_new_projects.html |  3 ++-
 Allura/allura/tests/functional/test_site_admin.py    | 11 ++++++++++-
 5 files changed, 29 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/0d1a63f5/Allura/allura/controllers/site_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/site_admin.py b/Allura/allura/controllers/site_admin.py
index b4b0496..5587148 100644
--- a/Allura/allura/controllers/site_admin.py
+++ b/Allura/allura/controllers/site_admin.py
@@ -337,7 +337,7 @@ class SiteAdminController(object):
             DeleteProjects.post(task_params)
             flash(u'Delete scheduled for %s' % projects, 'ok')
             redirect('delete_projects')
-        return {}
+        return {'projects': u'\n'.join(projects.split()) if projects else u''}
 
     @without_trailing_slash
     @expose('jinja:allura:templates/site_admin_search.html')

http://git-wip-us.apache.org/repos/asf/allura/blob/0d1a63f5/Allura/allura/public/nf/js/site_admin_new_projects.js
----------------------------------------------------------------------
diff --git a/Allura/allura/public/nf/js/site_admin_new_projects.js b/Allura/allura/public/nf/js/site_admin_new_projects.js
index d27322e..148e3de 100644
--- a/Allura/allura/public/nf/js/site_admin_new_projects.js
+++ b/Allura/allura/public/nf/js/site_admin_new_projects.js
@@ -18,6 +18,20 @@
 */
 
 $(document).ready(function() {
+  function rebuild_delete_url() {
+    var urls = [];
+    $('.js-select-project:checked').each(function(idx, val) {
+      urls.push($(val).attr('data-url'));
+    });
+    if (urls.length > 0) {
+      var url = '/nf/admin/delete_projects?projects=' + urls.join(' ');
+      var url = $('<a>Delete selected projects</a>').attr('href', url);
+      $('#delete-projects-url').html(url);
+    } else {
+      $('#delete-projects-url').text('');
+    }
+  }
+
   $('.js-select-project').change(function() {
     var shortname = $(this).attr('data-shortname');
     if ($(this).is(':checked')) {
@@ -30,6 +44,7 @@ $(document).ready(function() {
       shortnames.splice(i, 1);
       $('#selected-projects').text(shortnames.join(' '));
     }
+    rebuild_delete_url();
   });
 
   $('tr').click(function(event) {

http://git-wip-us.apache.org/repos/asf/allura/blob/0d1a63f5/Allura/allura/templates/site_admin_delete_projects.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/site_admin_delete_projects.html b/Allura/allura/templates/site_admin_delete_projects.html
index 4b92892..ddf85b9 100644
--- a/Allura/allura/templates/site_admin_delete_projects.html
+++ b/Allura/allura/templates/site_admin_delete_projects.html
@@ -30,7 +30,7 @@
     <p class="warning">Be carefull. This will delete all projects data!</p>
     <form action="delete_projects" method="POST">
       <div class="grid-18">
-        <textarea id="projects-to-delete" name="projects"></textarea>
+        <textarea id="projects-to-delete" name="projects">{{ projects }}</textarea>
       </div>
       <div class="grid-18">
         <input type="submit" value="Delete">

http://git-wip-us.apache.org/repos/asf/allura/blob/0d1a63f5/Allura/allura/templates/site_admin_new_projects.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/site_admin_new_projects.html b/Allura/allura/templates/site_admin_new_projects.html
index 9013c5d..415c709 100644
--- a/Allura/allura/templates/site_admin_new_projects.html
+++ b/Allura/allura/templates/site_admin_new_projects.html
@@ -56,7 +56,7 @@
     {% for p in projects %}
     <tr>
       <td class="narrow">
-        <input type="checkbox" class="js-select-project" data-shortname="{{ p.shortname
}}" />
+        <input type="checkbox" class="js-select-project" data-shortname="{{ p.shortname
}}" data-url="{{ p.url() }}" />
       </td>
       <td class="narrow">
         <small>{{ p._id.generation_time.strftime('%Y-%m-%d %H:%M:%S') }}</small>
@@ -72,6 +72,7 @@
   </table>
   {{ _paging() }}
   <div id="selected-projects"></div>
+  <div id="delete-projects-url" class="grid-19"></div>
 {% endblock %}
 
 {% block extra_css %}

http://git-wip-us.apache.org/repos/asf/allura/blob/0d1a63f5/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 40066b0..0918a0f 100644
--- a/Allura/allura/tests/functional/test_site_admin.py
+++ b/Allura/allura/tests/functional/test_site_admin.py
@@ -567,10 +567,19 @@ To reset your password on %s, please visit the following URL:
 
 class TestDeleteProjects(TestController):
 
+    def form(self, r):
+        return self.find_form(r, lambda f: f.action == 'delete_projects')
+
+    def test_projects_populated_from_get_params(self):
+        r = self.app.get('/nf/admin/delete_projects')
+        assert_equal(self.form(r)['projects'].value, u'')
+        r = self.app.get('/nf/admin/delete_projects?projects=/p/test/+/adobe/adobe-1/%20/p/test2/')
+        assert_equal(self.form(r)['projects'].value, u'/p/test/\n/adobe/adobe-1/\n/p/test2/')
+
     @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 = self.form(r)
         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')


Mime
View raw message