Opened 8 years ago

Closed 5 years ago

# Integrating functionality of TypedTicketWorkflowPlugin into this plugin

Reported by: Owned by: anonymous retracile normal AdvancedTicketWorkflowPlugin normal mithnae 0.11

### Description

Do you think it would be possible to integrate the functionality of TypedTicketWorkflowPlugin into this plug-in - both plug-ins are not getting along with each other very well in my installation of TRAC:-( I was trying to integrate it myself, but it seems I'm not good enough in Python. BTW, your code was really very helpful in project I manage @ my corpo - very good work indeed.

### comment:1 follow-up: ↓ 2 Changed 8 years ago by hju@…

@anonymous

Did you mention the patch in #4547 and the additional code in #4548?

I've not yet installed the TypedTicketWorkflowPlugin, but it looks interesting and these patches do either.

### comment:2 in reply to: ↑ 1 Changed 8 years ago by mithnae

@anonymous

Did you mention the patch in #4547 and the additional code in #4548?

I've not yet installed the TypedTicketWorkflowPlugin, but it looks interesting and these patches do either.

no this comment is no mine, the patch is neither. thank you for your time and attention :-)

### comment:3 follow-up: ↓ 4 Changed 7 years ago by jmartinez@…

I wouldn't patch this plugin with the code from TypedTicketWorkflowPlugin since the author of that plugin did things very incorrectly.

I've gone through in my distribution and reconfigured the class to work the "proper way" inside the Trac plugin architecture and of course, it works perfectly with your plugin.

All you need to do is change his class to inherit your ticket base class and make a tiny modification to the get_ticket_actions method, as such:

class TicketWorkflowOpFilterType(TicketWorkflowOpBase):

def get_ticket_actions(self, req, ticket):
controller = ConfigurableTicketWorkflow(self.env)
actions = controller.get_actions_by_operation_for_req( req, ticket, self._op_name)
actions = self.filter_actions(actions, ticket)
return actions

def filter_actions(self, action, ticket):
"""Finds the actions that use this operation"""
filterd_actions = []
for default, action_name in action:
action_attributes = self.actions[action_name]
if 'tickettype' in action_attributes:
#TODO normalization this should be done only once
required_types = [a.strip() for a in
action_attributes['tickettype'].split(',')]
if ticket.get_value_or_default('type') in required_types:
filterd_actions.append((default, action_name))
else:
filterd_actions.append((default, action_name))
return filterd_actions



This seems to work for me and it literally took 2 minutes to implement via pasting his plugin into yours and just modifying the class inheritance and that one chunk of code.

Regards

Note: I am on a different machine than where I have my source for this plugin, so I just copied and pasted the TypedTicketWorkflowPlugin into the editor here and changed like 3 lines - no warranty is implied here, but you get the idea)

### comment:4 in reply to: ↑ 3 Changed 5 years ago by retracile

• Resolution set to wontfix
• Status changed from new to closed

All you need to do is change his class to inherit your ticket base class and make a tiny modification to the get_ticket_actions method, as such:

...

Note: I am on a different machine than where I have my source for this plugin, so I just copied and pasted the TypedTicketWorkflowPlugin into the editor here and changed like 3 lines - no warranty is implied here, but you get the idea)

I don't see how that accomplishes the goal; I don't see how it hooks into anything. I've incorporated #4547, so I think things should work on this side. But I don't think the filtering functionality itself belongs in this plugin.