Author: matevz
Date: Thu Mar 14 12:18:21 2013
New Revision: 1456400
URL: http://svn.apache.org/r1456400
Log:
Ref. #326, consolidated 'normal' and admin breadcrumbs
Modified:
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_theme/bhtheme/templates/bh_admin.html
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_theme/bhtheme/templates/bh_path_general.html
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_theme/bhtheme/templates/bloodhound_theme.html
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_theme/bhtheme/theme.py
Modified:
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_theme/bhtheme/templates/bh_admin.html
URL:
http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_theme/bhtheme/templates/bh_admin.html?rev=1456400&r1=1456399&r2=1456400&view=diff
==============================================================================
---
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_theme/bhtheme/templates/bh_admin.html
(original)
+++
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_theme/bhtheme/templates/bh_admin.html
Thu Mar 14 12:18:21 2013
@@ -48,7 +48,7 @@
</py:def>
<py:def function="admin_function(fix_legacy)">
<div id="content" class="admin row">
- <h1 class="span12">Administration${' - ' + admin_current_product[0] if
admin_current_product else None}</h1>
+ <h1 class="span12">Administration${' - ' + admin_current_product[1] if
admin_current_product else None}</h1>
<div id="tabs" class="span3 hidden-phone">
${admin_nav_list(False)}
Modified:
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_theme/bhtheme/templates/bh_path_general.html
URL:
http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_theme/bhtheme/templates/bh_path_general.html?rev=1456400&r1=1456399&r2=1456400&view=diff
==============================================================================
---
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_theme/bhtheme/templates/bh_path_general.html
(original)
+++
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_theme/bhtheme/templates/bh_path_general.html
Thu Mar 14 12:18:21 2013
@@ -24,46 +24,72 @@
xmlns:xi="http://www.w3.org/2001/XInclude"
py:strip=""
py:with="single_product = not product_list or len(product_list) < 2">
- <li py:if="bhdb">
- <a title="View the dashboard" href="${href.dashboard()}">Dashboard</a>
- <span class="divider">/</span>
- </li>
- <div class="btn-group" py:strip="single_product">
- <button class="btn btn-mini" py:strip="single_product">
- <a title="Current product"
href="${href.products(req.perm.env.product.prefix)}">${req.perm.env.product.name}</a>
- </button>
- <py:if test="not single_product">
- <button class="btn btn-mini dropdown-toggle" data-toggle="dropdown">
- <span class="caret"></span>
- </button>
- <ul class="dropdown-menu">
- <li py:for="prefix,name in product_list">
- <a title="Product $name ($prefix)"
href="${href.products(prefix)}">$name ($prefix)</a>
- </li>
- <li class="divider"></li>
- <li><a title="Back to products" href="${href.products()}">All
products</a></li>
- </ul>
- </py:if>
- </div>
- <py:if test="milestone"
- py:with="single_milestone = not milestone_list or len(milestone_list) <
2">
- <li><span class="divider">/</span></li>
- <div class="btn-group" py:strip="single_milestone">
- <button class="btn btn-mini" py:strip="single_milestone">
- <a title="Current milestone"
href="${href.milestone(milestone.name)}">${milestone.name}</a>
- </button>
- <py:if test="not single_milestone">
- <button class="btn btn-mini dropdown-toggle" data-toggle="dropdown">
- <span class="caret"></span>
+
+ <py:choose test="">
+ <py:when test="admin_product_list">
+ <li py:with="prefix,name,url = admin_current_product">
+ <div class="btn-group">
+ <a class="btn dropdown-toggle" data-toggle="dropdown" href="$url"
+ title="Select product to administer">
+ $name
+ <span class="caret"></span>
+ </a>
+ <ul class="dropdown-menu">
+ <li py:with="prefix,name,url = admin_product_list[0]">
+ <a href="${url}">${name}</a>
+ </li>
+ <li class="divider"></li>
+ <li py:for="prefix,name,url in admin_product_list[1:]">
+ <a href="${url}">${name}</a>
+ </li>
+ </ul>
+ </div>
+ </li>
+ </py:when>
+
+ <py:otherwise>
+ <li py:if="bhdb">
+ <a title="View the dashboard" href="${href.dashboard()}">Dashboard</a>
+ <span class="divider">/</span>
+ </li>
+ <div class="btn-group" py:strip="single_product">
+ <button class="btn btn-mini" py:strip="single_product">
+ <a title="Current product"
href="${href.products(req.perm.env.product.prefix)}">${req.perm.env.product.name}</a>
</button>
- <ul class="dropdown-menu">
- <li py:for="name in milestone_list">
- <a title="Milestone $name" href="${href.milestone(name)}">$name</a>
- </li>
- <li class="divider"></li>
- <li><a title="Back to roadmap"
href="${href.roadmap()}">Roadmap</a></li>
- </ul>
+ <py:if test="not single_product">
+ <button class="btn btn-mini dropdown-toggle" data-toggle="dropdown">
+ <span class="caret"></span>
+ </button>
+ <ul class="dropdown-menu">
+ <li py:for="prefix,name,url in product_list">
+ <a title="Product $name ($prefix)" href="$url">$name
($prefix)</a>
+ </li>
+ <li class="divider"></li>
+ <li><a title="Back to products" href="${href.products()}">All
products</a></li>
+ </ul>
+ </py:if>
+ </div>
+ <py:if test="milestone"
+ py:with="single_milestone = not milestone_list or len(milestone_list)
< 2">
+ <li><span class="divider">/</span></li>
+ <div class="btn-group" py:strip="single_milestone">
+ <button class="btn btn-mini" py:strip="single_milestone">
+ <a title="Current milestone"
href="${href.milestone(milestone.name)}">${milestone.name}</a>
+ </button>
+ <py:if test="not single_milestone">
+ <button class="btn btn-mini dropdown-toggle"
data-toggle="dropdown">
+ <span class="caret"></span>
+ </button>
+ <ul class="dropdown-menu">
+ <li py:for="name in milestone_list">
+ <a title="Milestone $name"
href="${href.milestone(name)}">$name</a>
+ </li>
+ <li class="divider"></li>
+ <li><a title="Back to roadmap"
href="${href.roadmap()}">Roadmap</a></li>
+ </ul>
+ </py:if>
+ </div>
</py:if>
- </div>
- </py:if>
+ </py:otherwise>
+ </py:choose>
</div>
Modified:
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_theme/bhtheme/templates/bloodhound_theme.html
URL:
http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_theme/bhtheme/templates/bloodhound_theme.html?rev=1456400&r1=1456399&r2=1456400&view=diff
==============================================================================
---
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_theme/bhtheme/templates/bloodhound_theme.html
(original)
+++
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_theme/bhtheme/templates/bloodhound_theme.html
Thu Mar 14 12:18:21 2013
@@ -258,25 +258,6 @@
<!--! breadcrumb (TODO: which ones do we hide on the
phones/tablets?) -->
<div id="stickyStatus" class="span12">
<ul class="breadcrumb">
- <li py:if="admin_product_list">
- <div class="btn-group">
- <a class="btn dropdown-toggle" data-toggle="dropdown"
href="${admin_current_product[1]}"
- title="Select product to administer">
- ${admin_current_product[0]}
- <span class="caret"></span>
- </a>
- <ul class="dropdown-menu">
- <li py:with="name,url = admin_product_list[0]">
- <a href="${url}">${name}</a>
- </li>
- <li class="divider"></li>
- <li py:for="name,url in admin_product_list[1:]">
- <a href="${url}">${name}</a>
- </li>
- </ul>
- </div>
- </li>
-
<li py:choose="">
<xi:include py:when="value_of('resourcepath_template')"
href="${resourcepath_template}" />
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=1456400&r1=1456399&r2=1456400&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
Thu Mar 14 12:18:21 2013
@@ -256,6 +256,9 @@ class BloodhoundTheme(ThemeBase):
req.chrome['labels'] = self._get_whitelabelling()
+ if data is not None:
+ data['product_list'] = self._get_product_list(req)
+
links = req.chrome.get('links',{})
# replace favicon if appropriate
if self.env.project_icon == 'common/trac.ico':
@@ -317,8 +320,6 @@ class BloodhoundTheme(ThemeBase):
# Context nav
prevnext_nav(req, _('Previous'), _('Next'))
# Breadcrumbs nav
- data['product_list'] = [(p.prefix, p.name)
- for p in self._get_product_list(req)]
data['resourcepath_template'] = 'bh_path_search.html'
def _modify_wiki_page_path(self, req, template, data, content_type,
is_active):
@@ -342,18 +343,21 @@ class BloodhoundTheme(ThemeBase):
self._modify_resource_breadcrumb(req, template, data, content_type,
is_active)
- def _get_product_list(self, req):
+ def _get_product_list(self, req, href_fcn=None):
+ """Returns a list of products as (prefix, name, url) tuples
+ """
+ if href_fcn is None:
+ href_fcn = req.href.products
product_list = []
is_product_scope = isinstance(req.perm.env, ProductEnvironment)
for product in Product.select(self.env):
if is_product_scope:
- # Per-product permissions only work when checking them against
- # the appropriate ProductEnvironment (i.e. not cross-product).
if 'PRODUCT_VIEW' in req.product_perm(product.prefix,
product.resource):
- product_list.append(product)
+ product_list.append((product.prefix, product.name,
+ href_fcn(product.prefix)))
else:
- product_list.append(product)
-
+ product_list.append((product.prefix, product.name,
+ href_fcn(product.prefix)))
return product_list
def _modify_resource_breadcrumb(self, req, template, data, content_type,
@@ -368,26 +372,26 @@ class BloodhoundTheme(ThemeBase):
res = Resource(resname, data['ticket'][resname])
data['path_show_' + resname] = permname in req.perm(res)
- # add list of products available to this user, and their milestones
- data['product_list'] = [(p.prefix, p.name)
- for p in self._get_product_list(req)]
+ # add milestone list + current milestone to the breadcrumb
data['milestone_list'] = [m.name for m in
Milestone.select(self.env)]
mname = data['ticket']['milestone']
if mname:
data['milestone'] = Milestone(self.env, mname)
def _modify_admin_breadcrumb(self, req, template, data, content_type,
is_active):
- glsettings = (_('(Global settings)'), req.href.admin())
+ # override 'normal' product list with the admin one
+ glsettings = (None, _('(Global settings)'), req.href.admin())
data['admin_product_list'] = [ glsettings, ] + \
- [(p.name, req.href.products(p.prefix, 'admin'))
- for p in self._get_product_list(req)]
+ self._get_product_list(req,
+ lambda x: req.href.products(x, 'admin'))
if isinstance(req.perm.env, ProductEnvironment):
product = req.perm.env.product
- data['admin_current_product'] = (product.name,
+ data['admin_current_product'] = (product.prefix, product.name,
req.href.products(product.prefix, 'admin'))
else:
data['admin_current_product'] = glsettings
+ data['resourcepath_template'] = 'bh_path_general.html'
def _modify_browser(self, req, template, data, content_type, is_active):
"""Locate path to file in breadcrumbs area rather than title.
@@ -402,8 +406,6 @@ class BloodhoundTheme(ThemeBase):
def _add_products_general_breadcrumb(self, req, template, data,
content_type, is_active):
- data['product_list'] = [(p.prefix, p.name)
- for p in self._get_product_list(req)]
data['resourcepath_template'] = 'bh_path_general.html'
# INavigationContributor methods