Author: matevz
Date: Fri Mar 15 09:38:32 2013
New Revision: 1456836
URL: http://svn.apache.org/r1456836
Log:
#325 - Multiproduct UI: Dashboard (initial implementation - product widget)
Added:
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
Modified:
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_dashboard/bhdashboard/layouts/templates/bs_grid_full.html
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_dashboard/bhdashboard/web_ui.py
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_dashboard/setup.py
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/hooks.py
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_theme/bhtheme/theme.py
Modified:
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_dashboard/bhdashboard/layouts/templates/bs_grid_full.html
URL:
http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_dashboard/bhdashboard/layouts/templates/bs_grid_full.html?rev=1456836&r1=1456835&r2=1456836&view=diff
==============================================================================
---
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_dashboard/bhdashboard/layouts/templates/bs_grid_full.html
(original)
+++
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_dashboard/bhdashboard/layouts/templates/bs_grid_full.html
Fri Mar 15 09:38:32 2013
@@ -22,13 +22,15 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:py="http://genshi.edgewall.org/"
- xmlns:xi="http://www.w3.org/2001/XInclude">
+ xmlns:xi="http://www.w3.org/2001/XInclude"
+ py:with="is_global = req.perm.env.product is None">
<xi:include href="layout.html" />
<head>
<title>$title</title>
</head>
<body>
+ <h2 py:if="not is_global">Dashboard for product
<i>${req.perm.env.product.name}</i></h2>
<xi:include href="bs_grid.html" />
<div id="ft" class="row">
<div id="help">
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=1456836&r1=1456835&r2=1456836&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
Fri Mar 15 09:38:32 2013
@@ -47,6 +47,7 @@ from trac.web.chrome import add_ctxtnav,
from bhdashboard.api import DashboardSystem, InvalidIdentifier
from bhdashboard import _json
+from multiproduct.env import ProductEnvironment
class DashboardModule(Component):
"""Web frontend for dashboard infrastructure.
@@ -71,6 +72,9 @@ class DashboardModule(Component):
"""
if data is not None :
data['bhdb'] = DashboardChrome(self.env)
+ if isinstance(req.perm.env, ProductEnvironment) and \
+ data.get('product_list'):
+ data['resourcepath_template'] = 'bh_path_general.html'
for item in req.chrome['nav'].get('mainnav', []):
self.log.debug('%s' % (item,))
if item['name'] == 'tickets':
@@ -89,6 +93,7 @@ class DashboardModule(Component):
return bool(re.match(r'^/dashboard(/.)?', req.path_info))
def process_request(self, req):
+ req.perm.require('PRODUCT_VIEW')
"""Initially this will render static widgets. With time it will be
more and more dynamic and flexible.
"""
@@ -149,8 +154,8 @@ class DashboardModule(Component):
{
'_class' : 'span8',
'widgets' : ['my tickets', 'active
tickets',
- 'versions', 'milestones',
- 'components']
+ 'products', 'versions',
+ 'milestones', 'components']
},
{
'_class' : 'span4',
@@ -218,6 +223,9 @@ class DashboardModule(Component):
'activity': {
'args' : ['Timeline', None, {'args' : {}}]
},
+ 'products': {
+ 'args' : ['Product', None, {'args': {}}]
+ },
}
}
Added:
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=1456836&view=auto
==============================================================================
---
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_dashboard/bhdashboard/widgets/product.py
(added)
+++
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_dashboard/bhdashboard/widgets/product.py
Fri Mar 15 09:38:32 2013
@@ -0,0 +1,68 @@
+#!/usr/bin/env python
+# -*- coding: UTF-8 -*-
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+r"""Project dashboard for Apache(TM) Bloodhound
+
+Widgets displaying product information (multiproduct).
+"""
+
+from trac.util.translation import _
+
+from bhdashboard.util import WidgetBase, check_widget_name, pretty_wrapper
+
+from multiproduct.env import Product, ProductEnvironment
+
+
+__metaclass__ = type
+
+class ProductWidget(WidgetBase):
+ """Display products available to the user.
+ """
+ def get_widget_params(self, name):
+ """Return a dictionary containing arguments specification for
+ the widget with specified name.
+ """
+ return {
+ 'max' : {
+ 'desc' : """Limit the number of products displayed""",
+ 'type' : int
+ },
+ }
+
+ get_widget_params = pretty_wrapper(get_widget_params, check_widget_name)
+
+ def render_widget(self, name, context, options):
+ """Gather product list and render data in compact view
+ """
+ data = {}
+ req = context.req
+ title = ''
+
+ 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)]
+ title = _('Products')
+
+ return 'widget_product.html', \
+ { 'title': title, 'data': data, }, context
+
+ render_widget = pretty_wrapper(render_widget, check_widget_name)
+
Added:
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=1456836&view=auto
==============================================================================
---
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_dashboard/bhdashboard/widgets/templates/widget_product.html
(added)
+++
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_dashboard/bhdashboard/widgets/templates/widget_product.html
Fri Mar 15 09:38:32 2013
@@ -0,0 +1,38 @@
+<!--!
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+
+<div id="content" class="product"
+ 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>
Modified:
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_dashboard/setup.py
URL:
http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_dashboard/setup.py?rev=1456836&r1=1456835&r2=1456836&view=diff
==============================================================================
---
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_dashboard/setup.py
(original)
+++
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_dashboard/setup.py
Fri Mar 15 09:38:32 2013
@@ -122,6 +122,7 @@ ENTRY_POINTS = r"""
bhdashboard.macros = bhdashboard.macros
bhdashboard.layouts.bootstrap = bhdashboard.layouts.bootstrap
bhdashboard.widgets.containers = bhdashboard.widgets.containers
+ bhdashboard.widgets.product = bhdashboard.widgets.product
bhdashboard.widgets.query = bhdashboard.widgets.query
bhdashboard.widgets.report = bhdashboard.widgets.report
bhdashboard.widgets.ticket = bhdashboard.widgets.ticket
Modified:
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/hooks.py
URL:
http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/hooks.py?rev=1456836&r1=1456835&r2=1456836&view=diff
==============================================================================
---
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/hooks.py
(original)
+++
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/hooks.py
Fri Mar 15 09:38:32 2013
@@ -78,8 +78,9 @@ class ProductRequestWithSession(RequestW
def __init__(self, env, environ, start_response):
super(ProductRequestWithSession, self).__init__(environ,
start_response)
self.base_url = env.base_url
- self.href = ProductizedHref(self.href, env.href.base)
- self.abs_href = ProductizedHref(self.abs_href, env.abs_href.base)
+ if isinstance(env, multiproduct.env.ProductEnvironment):
+ self.href = ProductizedHref(self.href, env.href.base)
+ self.abs_href = ProductizedHref(self.abs_href, env.abs_href.base)
def product_perm(self, product, resource=None):
"""Helper for per product permissions"""
@@ -95,7 +96,4 @@ class ProductRequestWithSession(RequestW
class ProductRequestFactory(RequestFactoryBase):
def create_request(self, env, environ, start_response):
- if isinstance(env, multiproduct.env.ProductEnvironment):
- return ProductRequestWithSession(env, environ, start_response)
- else:
- return RequestWithSession(environ, start_response)
\ No newline at end of file
+ return ProductRequestWithSession(env, environ, start_response)
\ No newline at end of file
Modified:
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_theme/bhtheme/theme.py
URL:
http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_theme/bhtheme/theme.py?rev=1456836&r1=1456835&r2=1456836&view=diff
==============================================================================
---
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_theme/bhtheme/theme.py
(original)
+++
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_theme/bhtheme/theme.py
Fri Mar 15 09:38:32 2013
@@ -351,11 +351,7 @@ class BloodhoundTheme(ThemeBase):
product_list = []
is_product_scope = isinstance(req.perm.env, ProductEnvironment)
for product in Product.select(self.env):
- if is_product_scope:
- if 'PRODUCT_VIEW' in req.product_perm(product.prefix,
product.resource):
- product_list.append((product.prefix, product.name,
- href_fcn(product.prefix)))
- else:
+ if 'PRODUCT_VIEW' in req.product_perm(product.prefix,
product.resource):
product_list.append((product.prefix, product.name,
href_fcn(product.prefix)))
return product_list