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:00:34 UTC

svn commit: r1560598 - /bloodhound/trunk/bloodhound_relations/bhrelations/api.py

Author: rjollos
Date: Thu Jan 23 07:00:33 2014
New Revision: 1560598

URL: http://svn.apache.org/r1560598
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

Modified: bloodhound/trunk/bloodhound_relations/bhrelations/api.py
URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_relations/bhrelations/api.py?rev=1560598&r1=1560597&r2=1560598&view=diff
==============================================================================
--- bloodhound/trunk/bloodhound_relations/bhrelations/api.py (original)
+++ bloodhound/trunk/bloodhound_relations/bhrelations/api.py Thu Jan 23 07:00:33 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)