Author: rjollos Date: Tue Jul 9 09:14:53 2013 New Revision: 1501149 URL: http://svn.apache.org/r1501149 Log: Fix //View/Edit// link in the presence of product subdomains. Fixes #586.
Ensure that the resource URL is properly constructed for all of the product and resource mappings specified in BEP-0003. Patch by Olemis. Modified: bloodhound/trunk/bloodhound_theme/bhtheme/htdocs/js/theme.js bloodhound/trunk/bloodhound_theme/bhtheme/theme.py Modified: bloodhound/trunk/bloodhound_theme/bhtheme/htdocs/js/theme.js URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_theme/bhtheme/htdocs/js/theme.js?rev=1501149&r1=1501148&r2=1501149&view=diff ============================================================================== --- bloodhound/trunk/bloodhound_theme/bhtheme/htdocs/js/theme.js (original) +++ bloodhound/trunk/bloodhound_theme/bhtheme/htdocs/js/theme.js Tue Jul 9 09:14:53 2013 @@ -129,15 +129,11 @@ $( function () { product_base_url = ''; $.post(product_base_url + '/qct', $('#qct-form').serialize(), function(ticket) { - var base_url = product_base_url.split('/products/')[0]; - var href = base_url + '/products/' + - encodeURIComponent(ticket.product) + - '/ticket/' + ticket.id; qct_alert({ ticket: ticket.id, msg: '<span class="alert alert-success">' + 'Has been created</span> ' + - '<a href="' + href + '">View / Edit</a>' + '<a href="' + ticket.url + '">View / Edit</a>' }); }) .error(function(jqXHR, textStatus, errorMsg) { @@ -165,13 +161,8 @@ $( function () { product_base_url = ''; $.post(product_base_url + '/qct', $('#qct-inline-form').serialize(), function(ticket) { - var base_url = product_base_url.split('/products/')[0]; - var href = base_url + '/products/' + - encodeURIComponent(ticket.product) + - '/ticket/' + ticket.id; - var msg = 'Ticket #' + ticket.id + ' has been created. '; - msg += '<a href="' + href + '">View / Edit</a>'; + msg += '<a href="' + ticket.url + '">View / Edit</a>'; $('#qct-inline-notice-success span').html(msg); $('#qct-inline-notice-success').show({'duration': 400}); }) Modified: bloodhound/trunk/bloodhound_theme/bhtheme/theme.py URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_theme/bhtheme/theme.py?rev=1501149&r1=1501148&r2=1501149&view=diff ============================================================================== --- bloodhound/trunk/bloodhound_theme/bhtheme/theme.py (original) +++ bloodhound/trunk/bloodhound_theme/bhtheme/theme.py Tue Jul 9 09:14:53 2013 @@ -26,7 +26,7 @@ from genshi.output import DocType from trac.config import ListOption, Option from trac.core import Component, TracError, implements from trac.mimeview.api import get_mimetype -from trac.resource import Resource +from trac.resource import get_resource_url, Neighborhood, Resource from trac.ticket.model import Ticket, Milestone from trac.ticket.notification import TicketNotifyEmail from trac.ticket.web_ui import TicketModule @@ -521,7 +521,10 @@ class QuickCreateTicketDialog(Component) self.log.exception("BH: Quick create ticket failed %s" % (exc,)) req.send(str(exc), 'plain/text', 500) else: - req.send(to_json({'product': product, 'id': tid}), + tres = Neighborhood('product', product)('ticket', tid) + href = req.href + req.send(to_json({'product': product, 'id': tid, + 'url': get_resource_url(self.env, tres, href)}), 'application/json') def _get_ticket_module(self):