incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject [04/50] git commit: [#3153] ticket:389 added milestones to tracker bulk_export
Date Mon, 26 Aug 2013 14:00:43 GMT
[#3153] ticket:389 added milestones to tracker bulk_export


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

Branch: refs/heads/tv/6595
Commit: 59d60f6e6387d4f171a16fa4bb4b8a047780388a
Parents: 68077e9
Author: Anton Kasyanov <mind1master@gmail.com>
Authored: Tue Jul 23 20:09:29 2013 +0300
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Thu Aug 22 20:04:41 2013 +0000

----------------------------------------------------------------------
 ForgeTracker/forgetracker/tests/test_app.py |  6 ++++-
 ForgeTracker/forgetracker/tracker_main.py   | 31 +++++++++++++++---------
 2 files changed, 24 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/59d60f6e/ForgeTracker/forgetracker/tests/test_app.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tests/test_app.py b/ForgeTracker/forgetracker/tests/test_app.py
index 7437e4d..a718885 100644
--- a/ForgeTracker/forgetracker/tests/test_app.py
+++ b/ForgeTracker/forgetracker/tests/test_app.py
@@ -35,7 +35,7 @@ class TestBulkExport(TrackerTestController):
         self.project = M.Project.query.get(shortname='test')
         self.tracker = self.project.app_instance('bugs')
         self.new_ticket(summary='foo', _milestone='1.0')
-        self.new_ticket(summary='bar', _milestone='1.0')
+        self.new_ticket(summary='bar', _milestone='2.0')
         ticket = TM.Ticket.query.find(dict(summary='foo')).first()
         ticket.discussion_thread.add_post(text='silly comment')
 
@@ -59,3 +59,7 @@ class TestBulkExport(TrackerTestController):
         assert_true('options' in tracker_config.keys())
         assert_true('acl' in tracker_config.keys())
         assert_equal(tracker_config['options']['mount_point'], 'bugs')
+
+        milestones = sorted(tracker['milestones'], key=operator.itemgetter('name'))
+        assert_equal(milestones[0]['name'], '1.0')
+        assert_equal(milestones[1]['name'], '2.0')

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/59d60f6e/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index 5c574e3..1880cd8 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -420,12 +420,30 @@ class ForgeTrackerApp(Application):
                 f.write(',')
         f.write('], "tracker_config":')
         json.dump(self.config, f, cls=jsonify.GenericJSON)
+        f.write(', "milestones":')
+        milestones = self.milestones
+        json.dump(milestones, f, cls=jsonify.GenericJSON)
         f.write('}')
 
     @property
     def bins(self):
         return TM.Bin.query.find(dict(app_config_id=self.config._id)).sort('summary').all()
 
+    @property
+    def milestones(self):
+        milestones = []
+        for fld in self.globals.milestone_fields:
+            if fld.name == '_milestone':
+                for m in fld.milestones:
+                    d =  self.globals.milestone_count('%s:%s' % (fld.name, m.name))
+                    milestones.append(dict(
+                        name=m.name,
+                        due_date=m.get('due_date'),
+                        description=m.get('description'),
+                        complete=m.get('complete'),
+                        total=d['hits'],
+                        closed=d['closed']))
+        return milestones
 
 
 ### Controllers ###
@@ -614,19 +632,8 @@ class RootController(BaseController, FeedController):
     @expose('jinja:forgetracker:templates/tracker/milestones.html')
     def milestones(self, **kw):
         require_access(c.app, 'configure')
-        milestones = []
         c.date_field = W.date_field
-        for fld in c.app.globals.milestone_fields:
-            if fld.name == '_milestone':
-                for m in fld.milestones:
-                    d =  c.app.globals.milestone_count('%s:%s' % (fld.name, m.name))
-                    milestones.append(dict(
-                        name=m.name,
-                        due_date=m.get('due_date'),
-                        description=m.get('description'),
-                        complete=m.get('complete'),
-                        total=d['hits'],
-                        closed=d['closed']))
+        milestones = c.app.milestones
         return dict(milestones=milestones)
 
     @without_trailing_slash


Mime
View raw message