Opened 5 years ago

Closed 5 years ago

Last modified 13 months ago

#10692 closed enhancement (fixed)

Make ticket's old data available somehow

Reported by: ejucovy Owned by: ejucovy
Priority: high Component: WorkflowNotificationPlugin
Severity: normal Keywords:
Cc: Trac Release:


Currently the plugin only has access to the values of the ticket's attributes after the workflow action has been applied.

It would be nice if it could also provide access to the ticket's old values somehow. Without access to the old values, it's impossible to recreate Trac's core "ticket change" notifications using this plugin.

This should be possible to do, because the plugin's ITicketActionController.get_ticket_changes method is called, before any changes are applied, in the same request that then calls .apply_action_side_effects. So during that method, we could retrieve the ticket's values, before changes are applied, and stash them somewhere, probably on the request.

Attachments (0)

Change History (3)

comment:1 Changed 5 years ago by ejucovy

Resolution: fixed
Status: newclosed

Implemented in this commit.

comment:2 Changed 20 months ago by robert.bostedt@…

i don't understand how to access the old values

comment:3 Changed 13 months ago by ejucovy

Accessing old ticket values

The ticket's old values are available in the notification templates. These values are provided in a Python dict named old_values. The values provided are from before any changes were made to the ticket, whether by workflow operations or by direct user action.

You can use this dictionary to set up a notification similar to Trac's built in ticket change email; for example:

ticket_changed = *
ticket_changed.body = Ticket changed by $ $change.comment
                      {% for field in old_ticket %}{% if old_ticket[field] != ticket[field] %}
              $field changed: ${old_ticket[field]} => ${ticket[field]}{% end %}{% end %}
ticket_changed.recipients = $ticket.reporter
ticket_changed.subject = Ticket $ has changed!

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain ejucovy.
The resolution will be deleted.

Add Comment

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

Note: See TracTickets for help on using tickets.