You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bloodhound.apache.org by rj...@apache.org on 2014/01/23 08:08:51 UTC
svn commit: r1560601 - in /bloodhound/trunk:
bloodhound_relations/bhrelations/api.py
bloodhound_theme/bhtheme/templates/bh_ticket.html
Author: rjollos
Date: Thu Jan 23 07:08:51 2014
New Revision: 1560601
URL: http://svn.apache.org/r1560601
Log:
0.8dev: //resolve as duplicate// now works correctly for any action with the `set_resolution` operation. Refs #742.
Previously, the //Duplicate ID// input would not be displayed for any action other than //resolve//. Also the `duplicate` attribute would only be bound in `ITicketManipulator` when the action was named `resolve`.
Now a //Duplicate ID// input will be attached to the workflow action and the `duplicate` attribute will be bound by `ITicketManipulator` for any action with the `set_resolution` operation. This has been tested and functions property when there are multiple actions that specify the `set_resolution` operation.
Modified:
bloodhound/trunk/bloodhound_relations/bhrelations/api.py
bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_ticket.html
Modified: bloodhound/trunk/bloodhound_relations/bhrelations/api.py
URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_relations/bhrelations/api.py?rev=1560601&r1=1560600&r2=1560601&view=diff
==============================================================================
--- bloodhound/trunk/bloodhound_relations/bhrelations/api.py (original)
+++ bloodhound/trunk/bloodhound_relations/bhrelations/api.py Thu Jan 23 07:08:51 2014
@@ -37,6 +37,7 @@ from trac.db import DatabaseManager
from trac.resource import (ResourceSystem, Resource, ResourceNotFound,
get_resource_shortname, Neighborhood)
from trac.ticket import Ticket, ITicketManipulator, ITicketChangeListener
+from trac.ticket.api import TicketSystem
from trac.util.datefmt import utc, to_utimestamp
from trac.web.chrome import ITemplateProvider
@@ -521,7 +522,9 @@ class TicketRelationsSpecifics(Component
)
def _check_blockers(self, req, ticket):
- if req.args.get('action') == 'resolve':
+ action = req.args.get('action')
+ operations = self._get_operations_for_action(req, ticket, action)
+ if 'set_resolution' in operations:
blockers = self.rls.find_blockers(ticket, self.is_blocker)
if blockers:
blockers_str = ', '.join(
@@ -533,7 +536,9 @@ class TicketRelationsSpecifics(Component
yield None, msg
def _check_open_children(self, req, ticket):
- if req.args.get('action') == 'resolve':
+ action = req.args.get('action')
+ operations = self._get_operations_for_action(req, ticket, action)
+ if 'set_resolution' in operations:
for relation in [r for r in self.rls.get_relations(ticket)
if r['type'] == self.rls.CHILDREN_RELATION_TYPE]:
ticket = self._create_ticket_by_full_id(relation['destination'])
@@ -543,8 +548,10 @@ class TicketRelationsSpecifics(Component
yield None, msg
def _check_duplicate_id(self, req, ticket):
- if req.args.get('action') == 'resolve':
- resolution = req.args.get('action_resolve_resolve_resolution')
+ action = req.args.get('action')
+ operations = self._get_operations_for_action(req, ticket, action)
+ if 'set_resolution' in operations:
+ resolution = req.args.get('action_%s_resolve_resolution' % action)
if resolution == 'duplicate':
duplicate_id = req.args.get('duplicate_id')
if not duplicate_id:
@@ -558,6 +565,15 @@ class TicketRelationsSpecifics(Component
except NoSuchTicketError:
yield None, "Invalid duplicate ticket ID."
+ def _get_operations_for_action(self, req, ticket, action):
+ operations = []
+ for controller in TicketSystem(self.env).action_controllers:
+ actions = [a for w, a in
+ controller.get_ticket_actions(req, ticket) or []]
+ if action in actions:
+ operations += controller.actions[action]['operations']
+ return operations
+
def find_ticket(self, ticket_spec):
ticket = None
m = re.match(r'#?(?:(?P<pid>[^-]+)-)?(?P<tid>\d+)', ticket_spec)
Modified: bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_ticket.html
URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_ticket.html?rev=1560601&r1=1560600&r2=1560601&view=diff
==============================================================================
--- bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_ticket.html (original)
+++ bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_ticket.html Thu Jan 23 07:08:51 2014
@@ -162,10 +162,13 @@
}
function install_workflow(){
- <py:if test="bhrelations">
- var act = $('#action_resolve_resolve_resolution').parent();
- act.append('<span id="duplicate_id" class="hide">Duplicate ID: <input name="duplicate_id" type="text" class="input-mini" value="${ticket_duplicate_of}"></input></span>');
- </py:if>
+ <py:if test="bhrelations">/*<![CDATA[*/
+ $('select[id$=_resolve_resolution]').each(function () {
+ var prefix = $(this).attr('id').split('_').slice(0, 2).join('_');
+ $(this).parent().append('<span class="duplicate_id hide">Duplicate ID: ' +
+ '<input id="' + prefix + '_duplicate_id" name="duplicate_id" type="text" class="input-mini" value="${ticket_duplicate_of}" /></span>');
+ });
+ /*]]>*/</py:if>
var actions_box = $('#workflow-actions')
.click(function(e) { e.stopPropagation(); });
$('#action').children('div').each(function() {
@@ -188,9 +191,9 @@
else if (newresolution) {
newlabel = newlabel + ' as ' + newresolution;
if (newresolution === 'duplicate') {
- $('#duplicate_id').show();
+ $('.duplicate_id', $(this).parent()).show();
} else {
- $('#duplicate_id').hide();
+ $('.duplicate_id', $(this).parent()).hide();
}
}
$('#submit-action-label').text(newlabel);