bloodhound-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mat...@apache.org
Subject svn commit: r1459053 - in /incubator/bloodhound/branches/bep_0003_multiproduct: bloodhound_dashboard/bhdashboard/ bloodhound_dashboard/bhdashboard/widgets/ bloodhound_dashboard/bhdashboard/widgets/templates/ bloodhound_theme/bhtheme/htdocs/
Date Wed, 20 Mar 2013 21:07:47 GMT
Author: matevz
Date: Wed Mar 20 21:07:47 2013
New Revision: 1459053

URL: http://svn.apache.org/r1459053
Log:
#325 - Multiproduct UI: Dashboard (added Product info - milestones)

Modified:
    incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_dashboard/bhdashboard/web_ui.py
    incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_dashboard/bhdashboard/widgets/product.py
    incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_dashboard/bhdashboard/widgets/templates/widget_product.html
    incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_theme/bhtheme/htdocs/bloodhound.css

Modified: incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_dashboard/bhdashboard/web_ui.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_dashboard/bhdashboard/web_ui.py?rev=1459053&r1=1459052&r2=1459053&view=diff
==============================================================================
--- incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_dashboard/bhdashboard/web_ui.py
(original)
+++ incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_dashboard/bhdashboard/web_ui.py
Wed Mar 20 21:07:47 2013
@@ -228,12 +228,12 @@ class DashboardModule(Component):
                             'args' : ['Timeline', None, {'args' : {}}]
                         },
                     'products': {
-                            'args' : ['Product', None, {'args': {}}]
+                            'args' : ['Product', None, {'args': { 'max': 3 }}]
                         },
                }
         }
 
-    # global dashboard: add milestone column, group by product
+    # global dashboard queries: add milestone column, group by product
     DASHBOARD_GLOBAL_SCHEMA = copy.deepcopy(DASHBOARD_SCHEMA)
     DASHBOARD_GLOBAL_SCHEMA['widgets']['active tickets']['args'][2]['args']['query'] = (
         'status=!closed&group=product&col=id&col=summary&col=owner&col=status&'
@@ -243,6 +243,8 @@ class DashboardModule(Component):
         'status=!closed&group=product&col=id&col=summary&col=owner&col=status&'
         'col=priority&order=priority&col=milestone&owner=$USER&'
     )
+    # TODO: Remove versions, milestones and components from global dashboard.
+    # They will be displayed in the product widgets
 
     # Public API
     def expand_layout_data(self, context, layout_name, schema, embed=False):

Modified: incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_dashboard/bhdashboard/widgets/product.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_dashboard/bhdashboard/widgets/product.py?rev=1459053&r1=1459052&r2=1459053&view=diff
==============================================================================
--- incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_dashboard/bhdashboard/widgets/product.py
(original)
+++ incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_dashboard/bhdashboard/widgets/product.py
Wed Mar 20 21:07:47 2013
@@ -25,10 +25,12 @@ Widgets displaying product information (
 """
 
 from trac.util.translation import _
+from trac.ticket.model import Milestone
 
 from bhdashboard.util import WidgetBase, check_widget_name, pretty_wrapper
 
 from multiproduct.env import Product, ProductEnvironment
+from multiproduct.hooks import ProductizedHref
 
 
 __metaclass__ = type
@@ -49,16 +51,46 @@ class ProductWidget(WidgetBase):
 
     get_widget_params = pretty_wrapper(get_widget_params, check_widget_name)
 
+    def _get_product_milestones(self, req, product, max_):
+        milestones = []
+        penv = ProductEnvironment(self.env, product.prefix)
+        href = ProductizedHref(self.env, penv.href.base)
+        for m in Milestone.select(penv):
+            m.url = href.milestone(m.name)
+            m.ticket_count = penv.db_query(
+                'SELECT count(*) FROM ticket WHERE milestone="%s" '
+                'AND status <> "closed"' % m.name)[0][0]
+            milestones.append(m)
+            if len(milestones) == max_:
+                break
+
+        milestones.sort(key=lambda x: x.ticket_count, reverse=True)
+        if len(milestones) == max_:
+            m = Milestone(penv)
+            m.name = _('... more')
+            m.url = href.milestone()
+            m.ticket_count = None
+            milestones.append(m)
+
+        # TODO: add a (No milestone) to the list, pointing
+        # to the tickets (query) without a set milestones
+        return milestones
+
+
     def render_widget(self, name, context, options):
         """Gather product list and render data in compact view
         """
         data = {}
         req = context.req
         title = ''
+        params = ('max', )
+        max_, = self.bind_params(name, options, *params)
 
         if not isinstance(req.perm.env, ProductEnvironment):
-            data['product_list'] = [p for p in Product.select(self.env)
-                if 'PRODUCT_VIEW' in req.product_perm(p.prefix)]
+            for p in Product.select(self.env):
+                if 'PRODUCT_VIEW' in req.product_perm(p.prefix):
+                    p.milestones = self._get_product_milestones(req, p, max_)
+                    data.setdefault('product_list', []).append(p)
             title = _('Products')
 
         return 'widget_product.html', \

Modified: incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_dashboard/bhdashboard/widgets/templates/widget_product.html
URL: http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_dashboard/bhdashboard/widgets/templates/widget_product.html?rev=1459053&r1=1459052&r2=1459053&view=diff
==============================================================================
--- incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_dashboard/bhdashboard/widgets/templates/widget_product.html
(original)
+++ incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_dashboard/bhdashboard/widgets/templates/widget_product.html
Wed Mar 20 21:07:47 2013
@@ -21,18 +21,22 @@
   xmlns="http://www.w3.org/1999/xhtml"
   xmlns:py="http://genshi.edgewall.org/"
   xmlns:xi="http://www.w3.org/2001/XInclude">
-  <table py:if="product_list">
-    <thead>
-      <tr>
-        <th>${_('Name')}</th>
-        <th>${_('Prefix')}</th>
-      </tr>
-    </thead>
-    <tbody>
-      <tr py:for="p in product_list">
-        <td>$p.name</td>
-        <td><a href="${href.products(p.prefix)}">$p.prefix</a></td>
-      </tr>
-    </tbody>
-  </table>
+  <div py:if="product_list" class="row" id="products">
+    <div py:for="p in product_list" class="span3 well product-well">
+      <h4>&#9734; <a href="${req.href.products(p.prefix)}">$p.name ($p.prefix)</a></h4>
+      <h5 class="milestone-title">Milestones</h5>
+      <py:choose test="">
+        <py:when test="p.milestones">
+          <ul py:if="p.milestones" class="milestones">
+            <li py:for="m in p.milestones">
+              <a href="$m.url">$m.name<py:if test="m.ticket_count is not None">
($m.ticket_count)</py:if></a>
+            </li>
+          </ul>
+        </py:when>
+        <py:otherwise>
+          (No milestones for this product)
+        </py:otherwise>
+      </py:choose>
+    </div>
+  </div>
 </div>

Modified: incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_theme/bhtheme/htdocs/bloodhound.css
URL: http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_theme/bhtheme/htdocs/bloodhound.css?rev=1459053&r1=1459052&r2=1459053&view=diff
==============================================================================
--- incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_theme/bhtheme/htdocs/bloodhound.css
(original)
+++ incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_theme/bhtheme/htdocs/bloodhound.css
Wed Mar 20 21:07:47 2013
@@ -1107,3 +1107,27 @@ table.wiki th {
 }
 
 /* @end */
+
+/* @group Dashboard */
+
+#products h4 {
+  margin: 5px 0 10px 0;
+}
+
+#products h5 {
+  margin: 5px 0 0 0;
+}
+
+#products .product-well {
+  background-color: white;
+  padding: 10px;
+}
+
+#products .milestones {
+  list-style-type: none;
+  margin: 0;
+  padding: 0;
+}
+
+/* @end */
+



Mime
View raw message