incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [28/40] git commit: [#5951] Display closed milestones in an optgroup
Date Mon, 01 Apr 2013 14:27:47 GMT
[#5951] Display closed milestones in an optgroup

Signed-off-by: Cory Johns <cjohns@slashdotmedia.com>


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

Branch: refs/heads/cj/5963
Commit: b5bc1858daa093d1ce7b2b6c6026039af6fdcf09
Parents: 5acf2eb
Author: Cory Johns <cjohns@slashdotmedia.com>
Authored: Wed Mar 27 19:56:22 2013 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Thu Mar 28 19:45:46 2013 +0000

----------------------------------------------------------------------
 .../forgetracker/tests/functional/test_root.py     |   19 ++++++--
 ForgeTracker/forgetracker/widgets/ticket_form.py   |   36 ++++++++++++---
 2 files changed, 44 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b5bc1858/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 b7f4ae2..d638cf8 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -116,16 +116,25 @@ class TestMilestones(TrackerTestController):
         }
         self.app.post('/bugs/update_milestones', d)
         r = self.app.get('/bugs/1/')
+        closed = r.html.find('optgroup', label='Closed')
+        assert closed
+        closed = str(closed)
         assert '<option selected value="1.0">1.0</option>' in r
+        assert '<option selected value="1.0">1.0</option>' not in closed
         assert '<option value="2.0">2.0</option>' in r
-        assert '<option value="3.0">3.0</option>' not in r
-        assert '<option value="4.0">4.0</option>' not in r
+        assert '<option value="2.0">2.0</option>' not in closed
+        assert '<option value="3.0">3.0</option>' in closed
+        assert '<option value="4.0">4.0</option>' in closed
         r = self.app.get('/bugs/new/')
+        closed = r.html.find('optgroup', label='Closed')
+        assert closed
+        closed = str(closed)
         assert '<option selected value="1.0">1.0</option>' not in r
-        assert '<option value="1.0">1.0</option>' not in r
+        assert '<option value="1.0">1.0</option>' in closed
         assert '<option value="2.0">2.0</option>' in r
-        assert '<option value="3.0">3.0</option>' not in r
-        assert '<option value="4.0">4.0</option>' not in r
+        assert '<option value="2.0">2.0</option>' not in closed
+        assert '<option value="3.0">3.0</option>' in closed
+        assert '<option value="4.0">4.0</option>' in closed
 
 
 def post_install_create_ticket_permission(app):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b5bc1858/ForgeTracker/forgetracker/widgets/ticket_form.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/widgets/ticket_form.py b/ForgeTracker/forgetracker/widgets/ticket_form.py
index aaba037..4394fbb 100644
--- a/ForgeTracker/forgetracker/widgets/ticket_form.py
+++ b/ForgeTracker/forgetracker/widgets/ticket_form.py
@@ -179,9 +179,33 @@ class TicketCustomField(object):
         return factory(field)
 
 class MilestoneField(ew.SingleSelectField):
-    def display(self, *args, **kwargs):
-        milestone_value = kwargs['value']
-        for milestone in reversed(self.options):  # reverse so del hits the correct indexes
-            if milestone.complete and (milestone.py_value != milestone_value):
-                del self.options[self.options.index(milestone)]
-        return super(MilestoneField, self).display(*args, **kwargs)
+    template=ew.Snippet('''<select {{widget.j2_attrs({
+               'id':id,
+               'name':rendered_name,
+               'multiple':multiple,
+               'class':css_class},
+               attrs)}}>
+            {% for o in open_milestones %}
+            <option{% if o.selected%} selected{% endif %} value="{{o.html_value}}">{{o.label|e}}</option>
+            {% endfor %}
+            {% if closed_milestones %}
+            <optgroup label="Closed">
+                {% for o in closed_milestones %}
+                <option{% if o.selected%} selected{% endif %} value="{{o.html_value}}">{{o.label|e}}</option>
+                {% endfor %}
+            </optgroup>
+            {% endif %}
+        </select>''', 'jinja2')
+
+    def prepare_context(self, context):
+        context = super(MilestoneField, self).prepare_context(context)
+
+        # group open / closed milestones
+        context['open_milestones'] = [opt for opt in self.options if not opt.complete]
+        context['closed_milestones'] = [opt for opt in self.options if opt.complete]
+
+        # filter closed milestones entirely
+        #value = context['value']
+        #context['options'] = [opt for opt in self.options if not opt.complete or value ==
opt.py_value]
+
+        return context


Mime
View raw message