Author: gjm
Date: Sun Apr 22 08:35:20 2012
New Revision: 1328813
URL: http://svn.apache.org/viewvc?rev=1328813&view=rev
Log:
multiproduct: factors out common product path calculation to a ProductModule
class method - towards #3
Modified:
incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/ticket/web_ui.py
incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/web_ui.py
Modified:
incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/ticket/web_ui.py
URL:
http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/ticket/web_ui.py?rev=1328813&r1=1328812&r2=1328813&view=diff
==============================================================================
---
incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/ticket/web_ui.py
(original)
+++
incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/ticket/web_ui.py
Sun Apr 22 08:35:20 2012
@@ -69,12 +69,7 @@ class ProductTicketModule(TicketModule):
def get_navigation_items(self, req):
"""Overriding TicketModules New Ticket nav item"""
if 'TICKET_CREATE' in req.perm:
- product = req.args.get('productid','')
- if product and self.env.is_component_enabled(ProductModule):
- # this path will only exist if ProductModule is active
- href = req.href('products', product, 'newticket')
- else:
- href = req.href.newticket()
+ href = ProductModule.get_product_path(self.env, req, 'newticket')
yield ('mainnav', 'newticket',
tag.a(_("New Ticket"), href=href, accesskey=7))
@@ -131,17 +126,13 @@ class ProductTicketModule(TicketModule):
yield result
class ProductReportModule(ReportModule):
- """replacement for ReportModule"""
-
- # IRequestHandler methods
- def match_request(self, req):
- """Override of ReportModule match_request"""
- pathinfo = match_product_path(self.env, req)
- match = REPORT_RE.match(pathinfo)
- if match:
- if match.group(1):
- req.args['id'] = match.group(1)
- return True
-
- #def process_request(self, req):
+ """Multiproduct replacement for ReportModule"""
+
+ # INavigationContributor methods
+ #def get_active_navigation_item(self, req):
# not yet required
+
+ def get_navigation_items(self, req):
+ if 'REPORT_VIEW' in req.perm:
+ href = ProductModule.get_product_path(self.env, req, 'report')
+ yield ('mainnav', 'tickets', tag.a(_('View Tickets'), href=href))
Modified:
incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/web_ui.py
URL:
http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/web_ui.py?rev=1328813&r1=1328812&r2=1328813&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/web_ui.py
(original)
+++ incubator/bloodhound/trunk/bloodhound_multiproduct/multiproduct/web_ui.py
Sun Apr 22 08:35:20 2012
@@ -98,4 +98,12 @@ class ProductModule(Component):
if req.args.get('productid', None):
return 'product.html', None, None
return 'product_list.html', None, None
-
\ No newline at end of file
+
+ # helper methods for INavigationContributor implementations
+ @classmethod
+ def get_product_path(cls, env, req, itempath):
+ """Provide a navigation item path"""
+ product = req.args.get('productid', '')
+ if product and env.is_component_enabled(ProductModule):
+ return req.href('products', product, itempath)
+ return req.href(itempath)