source: worklogplugin/trunk/worklog/ticket_daemon.py

Last change on this file was 15698, checked in by Ryan J Ollos, 7 years ago

1.0dev: Add file headers

Refs #12845.

  • Property svn:eol-style set to native
File size: 1.3 KB
Line 
1# -*- coding: utf-8 -*-
2#
3# Copyright (c) 2007-2012 Colin Guthrie <trac@colin.guthr.ie>
4# Copyright (c) 2011-2016 Ryan J Ollos <ryan.j.ollos@gmail.com>
5# All rights reserved.
6#
7# This software is licensed as described in the file COPYING, which
8# you should have received as part of this distribution.
9
10from trac.core import Component, implements
11from trac.ticket import ITicketChangeListener
12
13from manager import WorkLogManager
14
15
16class WorkLogTicketObserver(Component):
17    implements(ITicketChangeListener)
18
19    def ticket_created(self, ticket):
20        """Called when a ticket is created."""
21        pass
22
23    def ticket_changed(self, ticket, comment, author, old_values):
24        """Called when a ticket is modified.
25
26        `old_values` is a dictionary containing the previous values of the
27        fields that have changed.
28        """
29        if self.config.getbool('worklog', 'autostop') \
30                and 'closed' == ticket['status'] \
31                and 'status' in old_values \
32                and 'closed' != old_values['status']:
33            mgr = WorkLogManager(self.env, self.config)
34            who, since = mgr.who_is_working_on(ticket.id)
35            if who:
36                mgr = WorkLogManager(self.env, self.config, who)
37                mgr.stop_work()
38
39    def ticket_deleted(self, ticket):
40        """Called when a ticket is deleted."""
41        pass
Note: See TracBrowser for help on using the repository browser.