incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [08/22] git commit: [#5656] ticket:301 Bulk move tickets
Date Tue, 28 May 2013 19:27:42 GMT
[#5656] ticket:301 Bulk move tickets


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

Branch: refs/heads/cj/6218
Commit: ffb9e7f685be99e9935e5315fc6fb02456b77f78
Parents: a087f64
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Wed May 1 08:48:35 2013 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Fri May 24 18:35:51 2013 +0000

----------------------------------------------------------------------
 .../forgetracker/tests/functional/test_root.py     |   11 +++-
 ForgeTracker/forgetracker/tracker_main.py          |   35 ++++++++++++++-
 2 files changed, 42 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ffb9e7f6/ForgeTracker/forgetracker/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tests/functional/test_root.py b/ForgeTracker/forgetracker/tests/functional/test_root.py
index 7015cd4..2a0e3e9 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -2236,10 +2236,15 @@ class TestBulkMove(TrackerTestController):
 
     def test_access_restriction(self):
        self.app.get('/bugs/move/', status=200)
-       self.app.get('/bugs/move/', extra_environ={'username': 'test-user-0'},
+       self.app.get('/bugs/move/',
+                    extra_environ={'username': 'test-user-0'},
                     status=403)
-       self.app.get('/bugs/move/', extra_environ={'username': '*anonymous'},
+       self.app.get('/bugs/move/',
+                    extra_environ={'username': '*anonymous'},
                     status=302)
+       self.app.post('/bugs/move_tickets',
+                     extra_environ={'username': 'test-user-0'},
+                     status=403)
 
     def test_ticket_list(self):
         r = self.app.get('/bugs/move/?q=The')
@@ -2285,7 +2290,7 @@ class TestBulkMove(TrackerTestController):
             assert_equal(ticket.discussion_thread.app_config_id, ac_id)
             assert_equal(ticket.discussion_thread.discussion.app_config_id, ac_id)
             post = ticket.discussion_thread.last_post
-            assert_equal(post.text, 'Ticket moved from /p/test/bugs/1/')
+            assert_in('Ticket moved from /p/test/bugs/', post.text)
         for t in original_tickets:
             assert_equal(t.discussion_thread.app_config_id, original_ac_id)
             assert_equal(t.discussion_thread.discussion.app_config_id, original_ac_id)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ffb9e7f6/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index b2cc363..e5cf057 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -795,11 +795,44 @@ class RootController(BaseController, FeedController):
         result['cancel_href'] = url(c.app.url + 'search/', dict(q=q, limit=limit, sort=sort))
         c.mass_move = W.mass_edit
         trackers = _my_trackers(c.user, c.app.config)
-        c.mass_move_form = W.mass_move_form(trackers=trackers)
+        c.mass_move_form = W.mass_move_form(
+            trackers=trackers,
+            action=c.app.url + 'move_tickets')
         return result
 
     @expose()
     @require_post()
+    def move_tickets(self, **post_data):
+        require_access(c.app, 'admin')
+        ticket_ids = aslist(post_data.get('__ticket_ids', []))
+        search = post_data.get('__search', '')
+        try:
+            destination_tracker_id = ObjectId(post_data.get('tracker', ''))
+        except InvalidId:
+            destination_tracker_id = None
+        tracker = M.AppConfig.query.get(_id=destination_tracker_id)
+        if tracker is None:
+            flash('Select valid tracker', 'error')
+            redirect('move/' + search)
+        if tracker == c.app.config:
+            flash('Ticket already in a selected tracker', 'info')
+            redirect('move/' + search)
+        if not has_access(tracker, 'admin')():
+            flash('You should have admin access to destination tracker', 'error')
+            redirect('move/' + search)
+        tickets = TM.Ticket.query.find(dict(
+            _id={'$in': [ObjectId(id) for id in ticket_ids]},
+            app_config_id=c.app.config._id)).all()
+        for ticket in tickets:
+            ticket.move(tracker)
+        c.app.globals.invalidate_bin_counts()
+        ThreadLocalORMSession.flush_all()
+        count = len(tickets)
+        flash('Moved {} ticket{}'.format(count, 's' if count != 1 else ''), 'ok')
+        redirect('move/' + search)
+
+    @expose()
+    @require_post()
     def update_tickets(self, **post_data):
         tickets = TM.Ticket.query.find(dict(
                 _id={'$in':[ObjectId(id) for id in aslist(post_data['__ticket_ids'])]},


Mime
View raw message