|
1 | 1 | from trac.admin import IAdminCommandProvider |
2 | | -from trac.attachment import Attachment |
| 2 | +from trac.attachment import Attachment, IAttachmentChangeListener |
3 | 3 | from trac.core import Component, implements |
4 | | -from trac.versioncontrol import RepositoryManager, NoSuchChangeset |
| 4 | +from trac.versioncontrol import ( |
| 5 | + RepositoryManager, NoSuchChangeset, IRepositoryChangeListener) |
5 | 6 |
|
| 7 | +from code_comments.api import ICodeCommentChangeListener |
6 | 8 | from code_comments.comments import Comments |
7 | 9 |
|
8 | 10 |
|
@@ -200,3 +202,27 @@ def _do_seed(self): |
200 | 202 | comments = Comments(None, self.env).all() |
201 | 203 | for comment in comments: |
202 | 204 | Subscription.from_comment(self.env, comment) |
| 205 | + |
| 206 | + |
| 207 | +class SubscriptionListeners(Component): |
| 208 | + """ |
| 209 | + Automatically creates subscriptions for attachments, changesets, and |
| 210 | + comments. |
| 211 | + """ |
| 212 | + implements(IAttachmentChangeListener, IRepositoryChangeListener, |
| 213 | + ICodeCommentChangeListener) |
| 214 | + |
| 215 | + # IAttachmentChangeListener methods |
| 216 | + |
| 217 | + def attachment_added(self, attachment): |
| 218 | + Subscription.from_attachment(self.env, attachment) |
| 219 | + |
| 220 | + # IRepositoryChangeListener methods |
| 221 | + |
| 222 | + def changeset_added(self, repos, changeset): |
| 223 | + Subscription.from_changeset(self.env, changeset) |
| 224 | + |
| 225 | + # ICodeCommentChangeListener methods |
| 226 | + |
| 227 | + def comment_created(self, comment): |
| 228 | + Subscription.from_comment(self.env, comment) |
0 commit comments