Commits

Anonymous committed c817f99

Moved get_product_list helper from bhtheme to multiproduct.

  • Participants
  • Parent commits a8da1c4

Comments (0)

Files changed (2)

File bloodhound_multiproduct/multiproduct/web_ui.py

         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

File bloodhound_theme/bhtheme/theme.py

 
 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
         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
         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
     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