Changes between Initial Version and Version 1 of WorkflowNotificationPlugin


Ignore:
Timestamp:
Dec 10, 2012, 4:01:19 AM (11 years ago)
Author:
ejucovy
Comment:

New hack WorkflowNotificationPlugin, created by ejucovy

Legend:

Unmodified
Added
Removed
Modified
  • WorkflowNotificationPlugin

    v1 v1  
     1[[PageOutline(2-5,Contents,pullout)]]
     2
     3= WorkflowNotificationPlugin =
     4
     5== Description ==
     6
     7WorkflowNotificationPlugin enables flexible configuration of email
     8notifications tied to ticket workflow changes.
     9
     10Administrators can configure any number of distinct email
     11notifications to be sent out when a workflow operation occurs on a
     12ticket. Each email notification is specifically attached to one or
     13more workflow operations, so (for example) separate emails can be sent
     14out when a ticket is accepted, reassigned, resolved, reopened, or
     15marked "in QA".
     16
     17Each email notification's subject, body, and recipients are fully
     18configurable by administrators, as Genshi templates which have access
     19to the ticket's data, the comment (if any) that was left on the
     20ticket, and the author of the change. Therefore notifications can be
     21very flexible: some notifications can be sent to the ticket's
     22reporter, others to its owner or CC list, others to the current
     23updater, and others to hard-coded lists of users.
     24
     25The notification emails sent by this plugin respect trac's ALWAYS_CC
     26and ALWAYS_BCC settings.
     27
     28The notification emails sent by this plugin are orthogonal to trac's
     29ALWAYS_NOTIFY_UPDATER, ALWAYS_NOTIFY_OWNER, and ALWAYS_NOTIFY_REPORTER
     30settings; Trac's built-in email notifications will be sent according
     31to those settings, independent of this plugin's emails.
     32
     33== Installation ==
     34
     35Install the plugin's source code:
     36{{{
     37$ easy_install trac-WorkflowNotificationPlugin
     38}}}
     39
     40Enable its components in trac.ini:
     41{{{
     42[components]
     43workflow_notification.* = enabled
     44}}}
     45
     46Add its component to your list of workflow providers, after all other
     47workflow providers; for example:
     48{{{
     49[ticket]
     50workflow = ConfigurableTicketWorkflow, TicketWorkflowNotifier
     51}}}
     52
     53Now you just need to configure some notifications; see below for
     54details and examples.
     55
     56
     57
     58== Bugs/Feature Requests ==
     59
     60Existing bugs and feature requests for WorkflowNotificationPlugin are
     61[report:9?COMPONENT=WorkflowNotificationPlugin here].
     62
     63If you have any issues, create a
     64[http://trac-hacks.org/newticket?component=WorkflowNotificationPlugin&owner=ejucovy new ticket].
     65
     66== Download ==
     67
     68Download the zipped source from [download:workflownotificationplugin here].
     69
     70== Source ==
     71
     72You can check out WorkflowNotificationPlugin from [http://trac-hacks.org/svn/workflownotificationplugin here] using Subversion, or [source:workflownotificationplugin browse the source] with Trac.
     73
     74== Example ==
     75
     76== Configuration ==
     77
     78Configure one or more notification emails attached to workflow events
     79using a `ticket-workflow-notifications` section in `trac.ini`.
     80
     81Within this section, each entry is a notification email that may be
     82sent out for a ticket.  Here is an example:
     83{{{
     84[ticket-workflow-notifications]
     85notify_reporter_when_accepted = accept
     86notify_reporter_when_accepted.body = Hi $ticket.reporter, '$ticket.summary' has been accepted by $change.author. Its status is now $ticket.status.\n\n{% if change.comment %}$change.author said:\n\n$change.comment{% end %}-----\nTicket URL: $link\n$project.name <${project.url or abs_href()}>\n$project.descr
     87notify_reporter_when_accepted.recipients = $ticket.reporter, trac-admin@hostname.com, trac_user
     88notify_reporter_when_accepted.subject = '$ticket.summary' is now accepted
     89}}}
     90
     91The first line in this example defines the
     92`notify_reporter_when_accepted` rule. The value in this line defines
     93one or more workflow actions that will trigger this notification: in
     94this case, the notification will be triggered when the "accept" action
     95occurs for any ticket.  (This action is defined by the default
     96configuration of Trac's built in ticket workflow engine; however, any
     97action that is defined by the configuration of your installed
     98ITicketActionControllers may be used.)
     99
     100We could also define a notification to occur on multiple workflow
     101actions, using a comma separated list of workflow actions:
     102{{{
     103notify_owner_changed = accept, reassign
     104}}}
     105
     106Multiple independent notifications can be configured for the same
     107workflow action; in the above examples, both the
     108`notify_owner_changed` and the `notify_reported_when_accepted` rules
     109will be triggered when the "accept" action occurs.
     110
     111The following lines define the email subject, body, and recipients for
     112a particular notification.  These are all Genshi Text Templates that
     113will be rendered with a context that includes the ticket (in its
     114current state AFTER the workflow action has been applied); the author
     115and comment of the current change, if any; a link to the ticket as
     116`$link`; and the project.
     117
     118All of these must be defined for each notification; the plugin will
     119raise errors at runtime if a notification is missing any of the
     120`.subject`, `.body` or `.recipients` definitions.
     121
     122The `.recipients` definition should be a Genshi template that renders
     123to a comma separated list of email addresses and/or usernames known to
     124Trac.  In the above example we combine a dynamic variable based on the
     125ticket's current state, a username known to Trac, and a hard coded
     126email address:
     127{{{
     128notify_reporter_when_accepted.recipients = $ticket.reporter, trac-admin@hostname.com, trac_user
     129}}}
     130
     131==== Notifications for new tickets ====
     132
     133Most notifications are configured to refer to one or more workflow actions,
     134like "accept", "leave", "reassign", "resolve", etc.
     135
     136You can also configure notifications to be triggered when a ticket is
     137newly created. To do this, use the special workflow action `@created`
     138like so:
     139
     140{{{
     141[ticket-workflow-notifications]
     142new_ticket = @created
     143new_ticket.body = New ticket $ticket.summary has been created
     144new_ticket.recipients = $ticket.owner
     145new_ticket.subject = New ticket created
     146}}}
     147
     148==== Notifications for all actions ====
     149
     150You can also set the special value `*` for a notification, which means
     151it will be triggered on every workflow action including ticket creation:
     152
     153{{{
     154[ticket-workflow-notifications]
     155ticket_changed = *
     156ticket_changed.body = View the ticket here: $link
     157ticket_changed.recipients = watchful_user, another_watchful_user
     158ticket_changed.subject = Ticket $ticket.id has changed!
     159}}}
     160
     161==== Notifications for the when no action has occurred ====
     162
     163A workflow action always occurs when a ticket is changed, even if the user
     164doesn't explicitly select a workflow action!  In the standard Trac configuration,
     165the default action is "leave".  So you could set up a notification like so:
     166
     167{{{
     168same_status = leave
     169same_status.body = View the ticket here: $link
     170same_status.recipients = watchful_user, another_watchful_user
     171same_status.subject = Ticket $ticket.id has been edited!
     172}}}
     173
     174
     175== Recent Changes ==
     176
     177[[ChangeLog(workflownotificationplugin, 3)]]
     178
     179== Author/Contributors ==
     180
     181'''Author:''' [wiki:ejucovy] [[BR]]
     182'''Maintainer:''' [wiki:ejucovy] [[BR]]
     183'''Contributors:'''