You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bloodhound.apache.org by as...@apache.org on 2013/04/12 12:12:19 UTC

svn commit: r1467229 - in /bloodhound/trunk: bloodhound_multiproduct/multiproduct/web_ui.py bloodhound_theme/bhtheme/theme.py

Author: astaric
Date: Fri Apr 12 10:12:19 2013
New Revision: 1467229

URL: http://svn.apache.org/r1467229
Log:
Moved get_product_list helper from bhtheme to multiproduct.

Modified:
    bloodhound/trunk/bloodhound_multiproduct/multiproduct/web_ui.py
    bloodhound/trunk/bloodhound_theme/bhtheme/theme.py

Modified: bloodhound/trunk/bloodhound_multiproduct/multiproduct/web_ui.py
URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_multiproduct/multiproduct/web_ui.py?rev=1467229&r1=1467228&r2=1467229&view=diff
==============================================================================
--- bloodhound/trunk/bloodhound_multiproduct/multiproduct/web_ui.py (original)
+++ bloodhound/trunk/bloodhound_multiproduct/multiproduct/web_ui.py Fri Apr 12 10:12:19 2013
@@ -188,3 +188,17 @@ class ProductModule(Component):
         if product and env.is_component_enabled(ProductModule):
             return req.href('products', product, itempath)
         return req.href(itempath)
+
+    @classmethod
+    def get_product_list(cls, env, 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 = []
+        for product in Product.select(env):
+            if 'PRODUCT_VIEW' in req.perm(Neighborhood('product', product.prefix).
+                                          child(product.resource)):
+                product_list.append((product.prefix, product.name,
+                    href_fcn(product.prefix)))
+        return product_list

Modified: bloodhound/trunk/bloodhound_theme/bhtheme/theme.py
URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_theme/bhtheme/theme.py?rev=1467229&r1=1467228&r2=1467229&view=diff
==============================================================================
--- bloodhound/trunk/bloodhound_theme/bhtheme/theme.py (original)
+++ bloodhound/trunk/bloodhound_theme/bhtheme/theme.py Fri Apr 12 10:12:19 2013
@@ -52,7 +52,7 @@ from wsgiref.util import setup_testing_d
 
 from multiproduct.model import Product
 from multiproduct.env import ProductEnvironment
-from multiproduct.web_ui import PRODUCT_RE
+from multiproduct.web_ui import PRODUCT_RE, ProductModule
 
 try:
     from multiproduct.ticket.web_ui import ProductTicketModule
@@ -262,7 +262,8 @@ class BloodhoundTheme(ThemeBase):
         req.chrome['labels'] = self._get_whitelabelling()
 
         if data is not None:
-            data['product_list'] = self._get_product_list(req)
+            data['product_list'] = \
+                ProductModule.get_product_list(self.env, req)
 
         links = req.chrome.get('links',{})
         # replace favicon if appropriate
@@ -347,19 +348,6 @@ class BloodhoundTheme(ThemeBase):
         self._modify_resource_breadcrumb(req, template, data, content_type,
                                          is_active)
 
-    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 = []
-        for product in Product.select(self.env):
-            if 'PRODUCT_VIEW' in req.perm(Neighborhood('product', product.prefix).
-                                          child(product.resource)):
-                product_list.append((product.prefix, product.name,
-                    href_fcn(product.prefix)))
-        return product_list
-
     def _modify_resource_breadcrumb(self, req, template, data, content_type,
                                     is_active):
         """Provides logic for breadcrumb resource permissions
@@ -381,9 +369,9 @@ class BloodhoundTheme(ThemeBase):
     def _modify_admin_breadcrumb(self, req, template, data, content_type, is_active):
         # override 'normal' product list with the admin one
         glsettings = (None, _('(Global settings)'), req.href.admin())
+        admin_url = lambda x: req.href.products(x, 'admin')
         data['admin_product_list'] = [ glsettings, ] + \
-            self._get_product_list(req,
-                lambda x: req.href.products(x, 'admin'))
+            ProductModule.get_product_list(self.env, req, admin_url)
 
         if isinstance(req.perm.env, ProductEnvironment):
             product = req.perm.env.product