You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bloodhound.apache.org by ma...@apache.org on 2013/05/17 14:35:20 UTC
svn commit: r1483770 -
/bloodhound/trunk/bloodhound_relations/bhrelations/web_ui.py
Author: matevz
Date: Fri May 17 12:35:20 2013
New Revision: 1483770
URL: http://svn.apache.org/r1483770
Log:
Ref. #523 - allow #<id> ticket specification + search for tickets in all products (global id)
Modified:
bloodhound/trunk/bloodhound_relations/bhrelations/web_ui.py
Modified: bloodhound/trunk/bloodhound_relations/bhrelations/web_ui.py
URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_relations/bhrelations/web_ui.py?rev=1483770&r1=1483769&r2=1483770&view=diff
==============================================================================
--- bloodhound/trunk/bloodhound_relations/bhrelations/web_ui.py (original)
+++ bloodhound/trunk/bloodhound_relations/bhrelations/web_ui.py Fri May 17 12:35:20 2013
@@ -28,7 +28,7 @@ import re
import pkg_resources
from trac.core import Component, implements, TracError
-from trac.resource import get_resource_url
+from trac.resource import get_resource_url, ResourceNotFound
from trac.ticket.model import Ticket
from trac.util.translation import _
from trac.web import IRequestHandler
@@ -37,6 +37,8 @@ from trac.web.chrome import ITemplatePro
from bhrelations.api import RelationsSystem, ResourceIdSerializer, \
TicketRelationsSpecifics
+from multiproduct.model import Product
+from multiproduct.env import ProductEnvironment
class RelationManagementModule(Component):
implements(IRequestHandler, ITemplateProvider)
@@ -114,10 +116,28 @@ class RelationManagementModule(Component
grouped_relations.setdefault(reltypes[r['type']], []).append(r)
return grouped_relations
- def find_ticket(self, tid):
- try:
- ticket = Ticket(self.env, tid)
- except ValueError:
+ def find_ticket(self, ticket_spec):
+ ticket = None
+ m = re.match(r'#?(?P<tid>\d+)', ticket_spec)
+ if m:
+ tid = m.group('tid')
+ try:
+ ticket = Ticket(self.env, tid)
+ except ResourceNotFound:
+ # ticket not found in current product, try all other products
+ for p in Product.select(self.env):
+ if p.prefix != self.env.product.prefix:
+ # TODO: check for PRODUCT_VIEW permissions
+ penv = ProductEnvironment(self.env.parent, p.prefix)
+ try:
+ ticket = Ticket(penv, tid)
+ except ResourceNotFound:
+ pass
+ else:
+ break
+
+ # ticket still not found, use fallback for <prefix>:ticket:<id> syntax
+ if ticket is None:
trs = TicketRelationsSpecifics(self.env)
try:
resource = ResourceIdSerializer.get_resource_by_id(tid)