Edgewall Software
Modify

Opened 13 years ago

Closed 13 years ago

Last modified 9 years ago

#10495 closed enhancement (worksforme)

ITicketManipulator - give access to ticket state before and after change

Reported by: bill.ellis@… Owned by:
Priority: normal Milestone:
Component: general Version:
Severity: normal Keywords: ITicketManipulator
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

In our context, ticket validity depends on a check of the changes made to a ticket ; not just a check of the ticket itself.

So, in implementing ITicketManipulator, at validate_ticket, we want to inspect the ticket before, the ticket after, and any contextual information associated with the change.

For example, we would like to restrict it so that only the ticket owner can transition a ticket to another state. And, during this transition, the owner may change to another person: e.g. via [ticket-workflow]…set_owner…

So, to implement the above, we'd need access to: + Who's making the change (we have that, through req.authname) + Who the previous owner was (we don't have that)

It looks like the implementation for this is tantalizingly close. A 'prepare_ticket' method is available, which (I'm guessing?) would provide access to the ticket details prior to the change. However, as documented, it's never called..

Although, that guess could be wrong - #10125 suggests that the originally intended use for 'prepare_ticket' might be something very different. Regardless, having access to 'ticket_before' in implementations of ITicketManipulator would be handy.

Attachments (0)

Change History (6)

comment:1 by Remy Blank, 13 years ago

Resolution: worksforme
Status: newclosed

The original values of changed ticket fields can be found in the _old attribute of the ticket object, a dict keyed by the field names. I don't know why it has been marked "protected" (the leading _), as it's quite useful in some situations. Maybe we should promote it to public, or provide a public interface to its values.

comment:2 by bill.ellis@…, 13 years ago

Ah - that sounds perfect - thanks for that insight!

comment:3 by brownnrl@…, 13 years ago

That's interesting, I once came across this problem but instantiated a ticket from trac.model.Ticket using the id attribute of the Ticket passed to validate_ticket. But that is much easier and cleaner… Thanks as well!

in reply to:  1 comment:4 by Ryan J Ollos <ryano@…>, 12 years ago

Replying to rblank:

The original values of changed ticket fields can be found in the _old attribute of the ticket object, a dict keyed by the field names. I don't know why it has been marked "protected" (the leading _), as it's quite useful in some situations. Maybe we should promote it to public, or provide a public interface to its values.

Naming the accessor (or renaming the property to) old_values would also make things more clear.

in reply to:  1 ; comment:5 by pohlmann.t@…, 9 years ago

Replying to Remy Blank:

The original values of changed ticket fields can be found in the _old attribute of the ticket object, a dict keyed by the field names. I don't know why it has been marked "protected" (the leading _), as it's quite useful in some situations. Maybe we should promote it to public, or provide a public interface to its values.

I'm trying to include the old status in my ticket_subject_template. How exactly would I do it? $ticket._old['status'] doesn't seem to do the trick.

Last edited 9 years ago by Ryan J Ollos (previous) (diff)

in reply to:  5 comment:6 by Ryan J Ollos, 9 years ago

Replying to pohlmann.t@gmx.de:

I'm trying to include the old status in my ticket_subject_template. How exactly would I do it? $ticket._old['status'] doesn't seem to do the trick.

See reply in SO:32473999. In the future, please keep questions like this on the MailingList or StackOverflow.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The ticket will remain with no owner.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from (none) to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.