Modify

Opened 11 years ago

Closed 10 years ago

#198 closed enhancement (fixed)

Accept workflow transitions

Reported by: thomas.moschny@… Owned by: bas
Priority: minor Milestone:
Component: email2trac Version: 1.6.0
Keywords: Cc: kroseneg@…, icon@…

Description

The ability to specify ticket properties in message body (what was #171) is really helpful.

It would be cool to make status changes via specifying TracWorkflow transitions. Instead of

@status:closed
@resolution:fixed

that would read

@->resolve(fixed)

The difference is be that the transition would only be made if allowed.

Not sure this is worth the effort though.

Attachments (0)

Change History (18)

comment:1 follow-up: Changed 11 years ago by bas

  • Status changed from new to assigned

I did not document is:-(, but there is already a workflow for ticket updates. This only activated when we try to open a close ticket, but maybe we can also do when somebody want to close it. It is called:

  • worflow: <name>

The workflow can be ignored, that is documented:

comment:2 in reply to: ↑ 1 Changed 11 years ago by thomas.moschny@…

Replying to bas:

I did not document is:-(, but there is already a workflow for ticket updates. This only activated when we try to open a close ticket, but maybe we can also do when somebody want to close it. It is called:

  • worflow: <name>

Yeah, but this is a configuration option. I was thinking of a workflow transition trigger embedded in the mail itself.

comment:3 Changed 11 years ago by bas

The option sets which workflow to be used and lookup in trac.ini. I mean exactly the same. When i ticket will be closed via the embedded command. It will activate the workflow specfied in meail2trac.conf. For the moment it is only implemented for closed tickets that will be reopened if a mail is received.

comment:4 Changed 11 years ago by kroseneg@…

  • Cc kroseneg@… added

This patch against v1.3.2 will make it possible to define a workflow for each ticket status. Simply define "workflow_<STATUS>: <WORKFLOW>" in your email2trac.conf. Defining "workflow_closed" is equivalent to "workflow".

--- email2trac.orig     2010-05-27 01:38:26.000000000 +0200
+++ email2trac  2010-05-27 02:58:48.000000000 +0200
@@ -746,7 +746,7 @@
                # reopen the ticket if it is was closed
                # We must use the ticket workflow framework
                #
-               if tkt['status'] in ['closed'] and self.EMAIL_TRIGGERS_WORKFLOW:
+               if self.EMAIL_TRIGGERS_WORKFLOW:

                        #print controller.actions['reopen']
                        #
@@ -762,14 +762,23 @@
                        #b = controller.get_ticket_changes(req, tkt, 'reopen')
                        #print 'get_ticket_changes :', b

-                       if self.WORKFLOW and (self.VERSION in [0.11]) :
+                       workflow = None
+                       if self.VERSION in [0.11]:
+                               if 'workflow_%s' % (tkt['status']) in self.parameters.keys():
+                                       workflow = self.parameters['workflow_%s' %(tkt['status'])]
+                               elif tkt['status'] in ['closed'] and self.WORKFLOW :
+                                       # fallback for compability
+                                       workflow = self.WORKFLOW
+
+                       if workflow:
+                               # execute workflow
                                from trac.ticket.default_workflow import ConfigurableTicketWorkflow
                                from trac.test import Mock, MockPerm

                                req = Mock(authname='anonymous', perm=MockPerm(), args={})

                                controller = ConfigurableTicketWorkflow(self.env)
-                               fields = controller.get_ticket_changes(req, tkt, self.WORKFLOW)
+                               fields = controller.get_ticket_changes(req, tkt, workflow)

                                if self.DEBUG:
                                        print 'TD: Workflow ticket update fields: ', fields
@@ -777,10 +786,12 @@
                                for key in fields.keys():
                                        tkt[key] = fields[key]

-                       else:
+                       elif tkt['status'] in ['closed'] :
+                               # default when no workflow defined or wrong version of trac
                                tkt['status'] = 'reopened'
                                tkt['resolution'] = ''

+
                # Must we update some ticket fields properties via subjectline
                #
                if update_fields:

comment:5 Changed 11 years ago by bas

  • Version changed from 1.3.2 to trunk

Thanks for the patch! Can you also give an example? So i can include it in the documentation.

comment:6 Changed 11 years ago by kroseneg@…

Here's an example:

email2trac.conf:

[project]
# workflow_<ticket status>: <workflow name>
workflow_closed: reopen
workflow_infoneeded: provideinfo

trac.ini:

[ticket-workflow]
reopen = closed -> reopened
reopen.permissions = TICKET_CREATE
reopen.operations = del_resolution

requestinfo = assigned,accepted,reopened -> infoneeded
requestinfo.name = request info
requestinfo.permissions = TICKET_MODIFY

provideinfo = infoneeded -> moreinfo
provideinfo.permissions = TICKET_CREATE
provideinfo.name = info provided

comment:7 Changed 10 years ago by Konstantin Ryabitsev <icon@…>

  • Cc icon@… added

I'm in the same boat as Thomas -- would like to see this in!

comment:8 Changed 10 years ago by bas

Sorry i forgot it completely. It will be on my todo list. Thanks for the reminder. It will be included in a new release

comment:9 Changed 10 years ago by bas

(In [468]) appllied patch from kroseneg at schmidham dot net to define a workflow for each ticket status. see #198

comment:10 Changed 10 years ago by Konstantin Ryabitsev <icon@…>

Excellent, I can confirm that it's working!

comment:11 Changed 10 years ago by Konstantin Ryabitsev <icon@…>

This seems to be required, unless you list all possible workflows in email2trac.conf:

  • email2trac-1.5.2.py

    old new  
    802802
    803803                        workflow = None
    804804                        if self.VERSION >= 0.11:
    805 
    806                                 workflow = self.parameters['workflow_%s' %tkt['status']]
     805                               
     806                                try:
     807                                        workflow = self.parameters['workflow_%s' %tkt['status']]
     808                                except KeyError:
     809                                        pass
    807810
    808811                                ## fallback for compability (Will be deprecated)
    809812                                #

comment:12 Changed 10 years ago by bas

Thta is not necessary as parameter is a SaraDict? that returns None if the key does not exists. I have not completed this transistion yet. I thonk we have to fetch the workflow definitions from trac.ini instead of email2trac.conf

comment:13 Changed 10 years ago by bas

(In [469]) improved workflow patch, see #198

comment:14 Changed 10 years ago by bas

Konstantin you were right with the KeyError?, thanks. Can you test the new trunk version. It also honours the permissions set in trac if enabled in email2trac.conf

comment:15 Changed 10 years ago by Konstantin Ryabitsev <icon@…>

Trunk looks good -- didn't check the permissions functionality, though, only workflows.

comment:16 Changed 10 years ago by bas

Thanks again. I tested the permission stuff and did not encounter a problem so far.

comment:17 Changed 10 years ago by bas

(In [474]) fine tuning of permission model in:

  • TICKET_APPEND
  • TICKET_CHGPROP

So email2trac will honour the permission set by the trac permission model if set in email2trac.conf. see #214, #198

comment:18 Changed 10 years ago by bas

  • Resolution set to fixed
  • Status changed from assigned to closed
  • Version changed from trunk to 1.6.0

close it will be in version 1.6.0

Add Comment

Modify Ticket

Change Properties
Action
as closed The owner will remain bas.
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.