incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject [1/2] git commit: [#2125] ticket:271 added closed milestone to ticket form
Date Thu, 21 Feb 2013 18:56:43 GMT
[#2125] ticket:271 added closed milestone to ticket form


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

Branch: refs/heads/master
Commit: e6c59d8503ee91d3fc87050a9c6e494be796529e
Parents: cc78b92
Author: Yuriy Arhipov <yuriyarhipovua@yandex.ru>
Authored: Tue Feb 12 18:29:45 2013 +0400
Committer: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Committed: Thu Feb 21 18:56:11 2013 +0000

----------------------------------------------------------------------
 .../forgetracker/tests/functional/test_root.py     |   18 +++++++++++++++
 ForgeTracker/forgetracker/widgets/ticket_form.py   |   16 ++++++++++---
 2 files changed, 30 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e6c59d85/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 47b2690..1b67a61 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -74,6 +74,24 @@ class TestMilestones(TrackerTestController):
         app = p.app_instance('bugs')
         assert len(app.globals.custom_fields) == 1, len(app.globals.custom_fields)
 
+    def test_closed_milestone(self):
+        self.new_ticket(summary='bar', _milestone='1.0', status='closed')
+        d = {
+            'field_name':'_milestone',
+            'milestones-0.old_name':'1.0',
+            'milestones-0.new_name':'1.0',
+            'milestones-0.description':'',
+            'milestones-0.complete':'Closed',
+            'milestones-0.due_date':''
+        }
+        self.app.post('/bugs/update_milestones', d)
+        r = self.app.get('/bugs/1/')
+        assert '<option selected value="1.0">1.0</option>' in r
+        r = self.app.get('/bugs/new/')
+        assert  '<option value="2.0">2.0</option>' in r
+        assert '<option selected value="1.0">1.0</option>' not in r
+
+
 def post_install_create_ticket_permission(app):
     """Set to authenticated permission to create tickets but not update"""
     role = M.ProjectRole.by_name('*authenticated')._id

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e6c59d85/ForgeTracker/forgetracker/widgets/ticket_form.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/widgets/ticket_form.py b/ForgeTracker/forgetracker/widgets/ticket_form.py
index 4ec551b..75074d0 100644
--- a/ForgeTracker/forgetracker/widgets/ticket_form.py
+++ b/ForgeTracker/forgetracker/widgets/ticket_form.py
@@ -32,6 +32,13 @@ class GenericTicketForm(ew.SimpleForm):
     def display_field_by_name(self, idx, ignore_errors=False):
         field = self.fields[idx]
         ctx = self.context_for(field)
+        if idx == '_milestone':
+            milestone_value = ctx.value
+            for milestone in field.options:
+                if milestone.status and (milestone.py_value != milestone_value):
+                    del field.options[field.options.index(milestone)]
+            ctx = self.context_for(field)
+
         display = field.display(**ctx)
         if ctx['errors'] and field.show_errors and not ignore_errors:
             display = "%s<div class='error'>%s</div>" % (display, ctx['errors'])
@@ -111,10 +118,11 @@ class TicketCustomField(object):
     def _milestone(field):
         options = []
         for m in field.milestones:
-            if not m.complete:
-                options.append(ew.Option(
-                        label=m.name,
-                        py_value=m.name))
+            options.append(ew.Option(
+                label=m.name,
+                py_value=m.name,
+                status=bool(m.complete)))
+
         ssf = ew.SingleSelectField(
             label=field.label, name=str(field.name),
             options=options)


Mime
View raw message