Changes between Version 19 and Version 20 of WorkflowNotificationPlugin


Ignore:
Timestamp:
Feb 3, 2016, 7:22:09 AM (8 years ago)
Author:
figaro
Comment:

Hosted on github

Legend:

Unmodified
Added
Removed
Modified
  • WorkflowNotificationPlugin

    v19 v20  
    99Administrators 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".
    1010
    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.
     11Each email notification's subject, body, and recipients are fully configurable by administrators, as Genshi templates which have access 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.
    1312
    1413The notification emails sent by this plugin respect Trac's `ALWAYS_CC` and `ALWAYS_BCC` settings.
    1514
    16 The notification emails sent by this plugin are orthogonal to Trac's `ALWAYS_NOTIFY_UPDATER`, `ALWAYS_NOTIFY_OWNER` and `ALWAYS_NOTIFY_REPORTER`
     15The notification emails sent by this plugin are independent of Trac's `ALWAYS_NOTIFY_UPDATER`, `ALWAYS_NOTIFY_OWNER` and `ALWAYS_NOTIFY_REPORTER`
    1716settings. Trac's built-in email notifications will be sent according to those settings, independent of this plugin's emails.
    1817
     
    5453}}}
    5554
    56 Now you just need to configure some notifications; see below for details and examples.
     55Now you just need to configure some notifications, see below for details and examples.
    5756
    5857== Example
     
    6261Configure one or more notification emails attached to workflow events using a `ticket-workflow-notifications` section in `trac.ini`.
    6362
    64 Within this section, each entry is a notification email that may be sent out for a ticket.  Here is an example:
     63Within this section, each entry is a notification email that may be sent out for a ticket. Here is an example:
    6564{{{#!ini
    6665[ticket-workflow-notifications]
     
    8079Multiple 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.
    8180
    82 The following lines define the email subject, body, and recipients for a particular notification.  These are all Genshi Text Templates that
    83 will be rendered with a context that includes the ticket (in its current state AFTER the workflow action has been applied); the author
    84 and comment of the current change, if any; a link to the ticket as `${link}`; and the project.
     81The following lines define the email subject, body, and recipients for a particular notification. These are all Genshi Text Templates that will be rendered with a context that includes the ticket (in its current state AFTER the workflow action has been applied); the author and comment of the current change, if any; a link to the ticket as `${link}`; and the project.
    8582
    8683All 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.
    8784
    88 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:
     85The `.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:
    8986{{{#!ini
    9087notify_reporter_when_accepted.recipients = ${ticket.reporter}, trac-admin@hostname.com, trac_user
    9188}}}
    9289
    93 === Conditional Notifications
     90=== Conditional notifications
    9491
    95 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. 
     92In 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.
    9693
    9794If the notification should be sent unconditionally when it is triggered, the .condition line should be set to `${True}`.
     
    10299[ticket-workflow-notifications]
    103100when_fixed = resolve
    104 when_fixed.body = Ticket ${ticket.id} has been fixed!  View it here: ${link}
     101when_fixed.body = Ticket ${ticket.id} has been fixed! View it here: ${link}
    105102when_fixed.subject = Ticket ${ticket.id} is fixed!
    106103when_fixed.recipients = ${ticket.cc}
     
    152149=== Notifications when no action has occurred
    153150
    154 A workflow action always occurs when a ticket is changed, even if the user doesn't explicitly select a workflow action!  In the standard Trac configuration, the default action is "leave". So you could set up a notification like so:
     151A workflow action always occurs when a ticket is changed, even if the user doesn't explicitly select a workflow action! In the standard Trac configuration, the default action is "leave". So you could set up a notification like so:
    155152
    156153{{{#!ini
     
    163160=== Accessing old ticket values
    164161
    165 The ticket's old values are available in the notification templates. These values are provided in a Python dict named `old_values`. The
    166 values provided are from before any changes were made to the ticket, whether by workflow operations or by direct user action.
     162The 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.
    167163
    168164You can use this dictionary to set up a notification similar to Trac's built in ticket change email, for example:
     
    175171}}}
    176172
    177 === Using Blank Lines in the Announcement Emails
     173=== Using blank lines in the announcement emails
    178174
    179175As 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: