#10495 closed enhancement (worksforme)
ITicketManipulator - give access to ticket state before and after change
Reported by: | 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)
follow-ups: 4 5 comment:1 by , 13 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
comment:3 by , 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!
comment:4 by , 12 years ago
Replying to rblank:
The original values of changed ticket fields can be found in the
_old
attribute of the ticket object, adict
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.
follow-up: 6 comment:5 by , 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, adict
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.
comment:6 by , 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.
The original values of changed ticket fields can be found in the
_old
attribute of the ticket object, adict
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.