mitar avatar mitar committed 645f348

Delete reminders when deleting a ticket.

Comments (0)

Files changed (1)

ticketreminder/api.py

 from trac.util.datefmt import pretty_timedelta, to_datetime, format_date, get_date_format_hint, format_datetime, parse_date, _time_intervals, to_utimestamp
 from trac.util.translation import _
 from trac.util import get_reporter_id
-from trac.ticket import Ticket
+from trac.ticket import Ticket, ITicketChangeListener
 from trac.perm import IPermissionRequestor, PermissionError
 from trac.resource import get_resource_url, get_resource_name
 
     With this component you can configure reminders for tickets in Trac.".
     """
 
-    implements(IEnvironmentSetupParticipant, ITemplateStreamFilter, ITemplateProvider, IRequestHandler, IRequestFilter, INavigationContributor, IPermissionRequestor)
+    implements(IEnvironmentSetupParticipant, ITemplateStreamFilter, ITemplateProvider, IRequestHandler, IRequestFilter, INavigationContributor, IPermissionRequestor, ITicketChangeListener)
 
     # IEnvironmentSetupParticipant methods
 
 
         yield 'TICKET_REMINDER_VIEW'
         yield 'TICKET_REMINDER_MODIFY'
-    
+
+    # ITicketChangeListener methods
+
+    def ticket_created(self, ticket):
+        """Called when a ticket is created."""
+
+        pass
+
+    def ticket_changed(self, ticket, comment, author, old_values):
+        """Called when a ticket is modified."""
+
+        pass
+
+    def ticket_deleted(self, ticket):
+        """Called when a ticket is deleted."""
+
+        db = self.env.get_db_cnx()
+        cursor = db.cursor()
+        cursor.execute("DELETE FROM ticketreminder WHERE ticket=%s", (ticket.id,))
+        db.commit() 
+
 def clear_time(date):
     return date.replace(hour=0, minute=0, second=0, microsecond=0)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.