3 | | = WorkflowNotificationPlugin = |
4 | | |
5 | | == Description == |
6 | | |
7 | | WorkflowNotificationPlugin enables flexible configuration of email |
8 | | notifications tied to ticket workflow changes. |
9 | | |
10 | | Administrators can configure any number of distinct email |
11 | | notifications to be sent out when a workflow operation occurs on a |
12 | | ticket. Each email notification is specifically attached to one or |
13 | | more workflow operations, so (for example) separate emails can be sent |
14 | | out when a ticket is accepted, reassigned, resolved, reopened, or |
15 | | marked "in QA". |
16 | | |
17 | | Each email notification's subject, body, and recipients are fully |
18 | | configurable by administrators, as Genshi templates which have access |
19 | | to the ticket's data, the comment (if any) that was left on the |
20 | | ticket, and the author of the change. Therefore notifications can be |
21 | | very flexible: some notifications can be sent to the ticket's |
22 | | reporter, others to its owner or CC list, others to the current |
23 | | updater, and others to hard-coded lists of users. |
24 | | |
25 | | The notification emails sent by this plugin respect trac's ALWAYS_CC |
26 | | and ALWAYS_BCC settings. |
27 | | |
28 | | The notification emails sent by this plugin are orthogonal to trac's |
29 | | ALWAYS_NOTIFY_UPDATER, ALWAYS_NOTIFY_OWNER, and ALWAYS_NOTIFY_REPORTER |
30 | | settings; Trac's built-in email notifications will be sent according |
31 | | to those settings, independent of this plugin's emails. |
32 | | |
33 | | == Installation == |
| 3 | = WorkflowNotificationPlugin |
| 4 | |
| 5 | == Description |
| 6 | |
| 7 | WorkflowNotificationPlugin enables flexible configuration of email notifications tied to ticket workflow changes. |
| 8 | |
| 9 | Administrators can configure any number of distinct email notifications to be sent out when a workflow operation occurs on a ticket. Each email notification is specifically attached to one or more workflow operations, so (for example) separate emails can be sent out when a ticket is accepted, reassigned, resolved, reopened, or marked "in QA". |
| 10 | |
| 11 | Each email notification's subject, body, and recipients are fully configurable by administrators, as Genshi templates which have access |
| 12 | to the ticket's data, the comment (if any) that was left on the ticket, and the author of the change. Therefore notifications can be very flexible: some notifications can be sent to the ticket's reporter, others to its owner or CC list, others to the current updater, and others to hard-coded lists of users. |
| 13 | |
| 14 | The notification emails sent by this plugin respect trac's ALWAYS_CC and ALWAYS_BCC settings. |
| 15 | |
| 16 | The notification emails sent by this plugin are orthogonal to Trac's `ALWAYS_NOTIFY_UPDATER`, `ALWAYS_NOTIFY_OWNER` and `ALWAYS_NOTIFY_REPORTER` |
| 17 | settings. Trac's built-in email notifications will be sent according to those settings, independent of this plugin's emails. |
| 18 | |
| 19 | == Bugs/Feature Requests |
| 20 | |
| 21 | Existing bugs and feature requests for WorkflowNotificationPlugin are |
| 22 | [report:9?COMPONENT=WorkflowNotificationPlugin here]. |
| 23 | |
| 24 | If you have any issues, create a |
| 25 | [http://trac-hacks.org/newticket?component=WorkflowNotificationPlugin&owner=ejucovy new ticket]. |
| 26 | |
| 27 | == Download |
| 28 | |
| 29 | Download the zipped source from [http://pypi.python.org/pypi/trac-WorkflowNotificationPlugin PyPI]. |
| 30 | |
| 31 | == Source |
| 32 | |
| 33 | You can check out WorkflowNotificationPlugin from git://github.com/boldprogressives/trac-WorkflowNotificationPlugin using Git, or [https://github.com/boldprogressives/trac-WorkflowNotificationPlugin browse the source] with Github. |
| 34 | |
| 35 | == Installation |
56 | | Now you just need to configure some notifications; see below for |
57 | | details and examples. |
58 | | |
59 | | |
60 | | |
61 | | == Bugs/Feature Requests == |
62 | | |
63 | | Existing bugs and feature requests for WorkflowNotificationPlugin are |
64 | | [report:9?COMPONENT=WorkflowNotificationPlugin here]. |
65 | | |
66 | | If you have any issues, create a |
67 | | [http://trac-hacks.org/newticket?component=WorkflowNotificationPlugin&owner=ejucovy new ticket]. |
68 | | |
69 | | == Download == |
70 | | |
71 | | Download the zipped source from [http://pypi.python.org/pypi/trac-WorkflowNotificationPlugin PyPI]. |
72 | | |
73 | | == Source == |
74 | | |
75 | | You can check out WorkflowNotificationPlugin from git://github.com/boldprogressives/trac-WorkflowNotificationPlugin using Git, or [https://github.com/boldprogressives/trac-WorkflowNotificationPlugin browse the source] with Github. |
76 | | |
77 | | == Example == |
78 | | |
79 | | === Configuration === |
80 | | |
81 | | Configure one or more notification emails attached to workflow events |
82 | | using a `ticket-workflow-notifications` section in `trac.ini`. |
83 | | |
84 | | Within this section, each entry is a notification email that may be |
85 | | sent out for a ticket. Here is an example: |
| 57 | Now you just need to configure some notifications; see below for details and examples. |
| 58 | |
| 59 | == Example |
| 60 | |
| 61 | === Configuration |
| 62 | |
| 63 | Configure one or more notification emails attached to workflow events using a `ticket-workflow-notifications` section in `trac.ini`. |
| 64 | |
| 65 | Within this section, each entry is a notification email that may be sent out for a ticket. Here is an example: |
95 | | The first line in this example defines the |
96 | | `notify_reporter_when_accepted` rule. The value in this line defines |
97 | | one or more workflow actions that will trigger this notification: in |
98 | | this case, the notification will be triggered when the "accept" action |
99 | | occurs for any ticket. (This action is defined by the default |
100 | | configuration of Trac's built in ticket workflow engine; however, any |
101 | | action that is defined by the configuration of your installed |
102 | | ITicketActionControllers may be used.) |
103 | | |
104 | | We could also define a notification to occur on multiple workflow |
105 | | actions, using a comma separated list of workflow actions: |
| 75 | The first line in this example defines the `notify_reporter_when_accepted` rule. The value in this line defines one or more workflow actions that will trigger this notification: in this case, the notification will be triggered when the "accept" action occurs for any ticket. This action is defined by the default configuration of Trac's built in ticket workflow engine; however, any action that is defined by the configuration of your installed ITicketActionControllers may be used. |
| 76 | |
| 77 | We could also define a notification to occur on multiple workflow actions, using a comma separated list of workflow actions: |
111 | | Multiple independent notifications can be configured for the same |
112 | | workflow action; in the above examples, both the |
113 | | `notify_owner_changed` and the `notify_reported_when_accepted` rules |
114 | | will be triggered when the "accept" action occurs. |
115 | | |
116 | | The following lines define the email subject, body, and recipients for |
117 | | a particular notification. These are all Genshi Text Templates that |
118 | | will be rendered with a context that includes the ticket (in its |
119 | | current state AFTER the workflow action has been applied); the author |
120 | | and comment of the current change, if any; a link to the ticket as |
121 | | `${link}`; and the project. |
122 | | |
123 | | All of these must be defined for each notification; the plugin will |
124 | | raise errors at runtime if a notification is missing any of the |
125 | | `.subject`, `.body` or `.recipients` definitions. |
126 | | |
127 | | The `.recipients` definition should be a Genshi template that renders |
128 | | to a comma separated list of email addresses and/or usernames known to |
129 | | Trac. In the above example we combine a dynamic variable based on the |
130 | | ticket's current state, a username known to Trac, and a hard coded |
131 | | email address: |
| 83 | Multiple independent notifications can be configured for the same workflow action; in the above examples, both the `notify_owner_changed` and the `notify_reported_when_accepted` rules will be triggered when the "accept" action occurs. |
| 84 | |
| 85 | The following lines define the email subject, body, and recipients for a particular notification. These are all Genshi Text Templates that |
| 86 | will be rendered with a context that includes the ticket (in its current state AFTER the workflow action has been applied); the author |
| 87 | and comment of the current change, if any; a link to the ticket as `${link}`; and the project. |
| 88 | |
| 89 | All of these must be defined for each notification; the plugin will raise errors at runtime if a notification is missing any of the `.subject`, `.body` or `.recipients` definitions. |
| 90 | |
| 91 | The `.recipients` definition should be a Genshi template that renders to a comma separated list of email addresses and/or usernames known to Trac. In the above example we combine a dynamic variable based on the ticket's current state, a username known to Trac, and a hard coded email address: |
137 | | === Conditional Notifications === |
138 | | |
139 | | In addition to the required configuration fields described above, you can |
140 | | optionally include a `.condition` definition for a notification. If provided, |
141 | | this should be a Genshi text template which evaluates to the value True if and |
142 | | only if the notification should be sent. If the template evaluates to any value |
143 | | other than True, the notification will be skipped. |
144 | | |
145 | | If no `.condition` is provided, then the notification will be sent unconditionally |
146 | | when it is triggered. |
| 97 | === Conditional Notifications |
| 98 | |
| 99 | In addition to the required configuration fields described above, you can optionally include a `.condition` definition for a notification. If provided, this should be a Genshi text template which evaluates to the value True if and only if the notification should be sent. If the template evaluates to any value other than True, the notification will be skipped. |
| 100 | |
| 101 | If no `.condition` is provided, then the notification will be sent unconditionally when it is triggered. |
172 | | === Notifications for new tickets === |
173 | | |
174 | | Most notifications are configured to refer to one or more workflow actions, |
175 | | like accept, leave, reassign, resolve, etc. |
176 | | |
177 | | You can also configure notifications to be triggered when a ticket is |
178 | | newly created. To do this, use the special workflow action `@created` |
179 | | like so: |
| 127 | === Notifications for new tickets |
| 128 | |
| 129 | Most notifications are configured to refer to one or more workflow actions, like accept, leave, reassign, resolve, etc. |
| 130 | |
| 131 | You can also configure notifications to be triggered when a ticket is newly created. To do this, use the special workflow action `@created` like so: |
227 | | === Accessing old ticket values === |
228 | | |
229 | | The ticket's old values are available in the notification templates. |
230 | | These values are provided in a Python dict named `old_values`. The |
231 | | values provided are from before any changes were made to the ticket, |
232 | | whether by workflow operations or by direct user action. |
233 | | |
234 | | You can use this dictionary to set up a notification similar to Trac's |
235 | | built in ticket change email; for example: |
| 174 | === Accessing old ticket values |
| 175 | |
| 176 | The ticket's old values are available in the notification templates. These values are provided in a Python dict named `old_values`. The |
| 177 | values provided are from before any changes were made to the ticket, whether by workflow operations or by direct user action. |
| 178 | |
| 179 | You can use this dictionary to set up a notification similar to Trac's built in ticket change email, for example: |
245 | | === Using Blank Lines in the Announcement Emails === |
246 | | |
247 | | As the examples above show, you can add blank lines by typing "\n" in your email template. The plugin's code will parse these "\n" strings into actual newline characters. So, for example, a configuration like |
248 | | |
249 | | {{{ |
250 | | notice.body = Notification for ticket ${ticket.id}: ${link}\n\n\n\nThis is a notification. |
251 | | }}} |
252 | | |
253 | | should result in an email body with four blank lines between the two sentences. |
254 | | |
255 | | This seems to work more reliably than using the .ini file's own multi-line syntax which apparently collapses whitespace. |
256 | | |
257 | | Meanwhile, if there are any newlines whatsoever in your `.subject` configuration, the plugin will replace them with spaces. This ensures that your email will have a valid subject (email subjects cannot contain newlines). |
258 | | |
259 | | == Recent Changes == |
| 189 | === Using Blank Lines in the Announcement Emails |
| 190 | |
| 191 | As the examples above show, you can add blank lines by typing "\n" in your email template. The plugin's code will parse these "\n" strings into actual newline characters. So, for example, this configuration should result in an email body with four blank lines between the two sentences: |
| 192 | |
| 193 | {{{ |
| 194 | notice.body = Notification for ticket ${ticket.id}: ${link}\n\n\n\nThis is a notification. |
| 195 | }}} |
| 196 | |
| 197 | This seems to work more reliably than using the `trac.ini` file's own multi-line syntax which apparently collapses whitespace. |
| 198 | |
| 199 | Meanwhile, if there are any newlines whatsoever in your `.subject` configuration, the plugin will replace them with spaces. This ensures that your email will have a valid subject (email subjects cannot contain newlines). |
| 200 | |
| 201 | == Recent Changes |