예제 #1
0
 def ticket_created(self, ticket):
     announcer = AnnouncementSystem(ticket.env)
     announcer.send(
         TicketChangeEvent("ticket", "created", ticket,
             author=ticket['reporter']
         )
     )
예제 #2
0
 def setUp(self):
     self.env = EnvironmentStub(enable=['trac.*'])
     self.env.path = tempfile.mkdtemp()
     self.db_mgr = DatabaseManager(self.env)
     # Setup current announcer db schema tables.
     self.an_sys = AnnouncementSystem(self.env)
     self.an_sys.upgrade_environment()
예제 #3
0
 def wiki_page_added(self, page):
     history = list(page.get_history())[0]
     announcer = AnnouncementSystem(page.env)
     announcer.send(
         WikiChangeEvent("wiki", "created", page,
             author=history[2], version=history[0]
         )
     )
예제 #4
0
 def wiki_page_changed(self, page, version, t, comment, author, ipnr):
     announcer = AnnouncementSystem(page.env)
     announcer.send(
         WikiChangeEvent("wiki", "changed", page,
             comment=comment, author=author, version=version,
             timestamp=t, remote_addr=ipnr
         )
     )
예제 #5
0
 def ticket_changed(self, ticket, comment, author, old_values):
     if old_values.keys() == ['cc'] and not comment and \
             self.ignore_cc_changes:
         return
     announcer = AnnouncementSystem(ticket.env)
     announcer.send(
         TicketChangeEvent('ticket', 'changed', ticket, comment, author,
                           old_values))
예제 #6
0
 def attachment_added(self, attachment):
     parent = attachment.resource.parent
     if parent.realm == "ticket":
         ticket = Ticket(self.env, parent.id)
         announcer = AnnouncementSystem(ticket.env)
         announcer.send(
             TicketChangeEvent("ticket", "attachment added", ticket,
                 attachment=attachment, author=attachment.author,
             )
         )
     elif parent.realm == "wiki":
         page = WikiPage(self.env, parent.id)
         announcer = AnnouncementSystem(page.env)
         announcer.send(
             WikiChangeEvent("wiki", "attachment added", page,
                 attachment=attachment, author=attachment.author,
             )
         )
예제 #7
0
 def _notify(self, category, username, password=None, token=None):
     announcer = AnnouncementSystem(self.env)
     try:
         announcer.send(
             AccountChangeEvent(category, username, password, token))
     except Exception:
         self.log.exception(
             "Failure creating announcement for account "
             "event %s: %s", username, category)
예제 #8
0
 def blog_comment_added(self, postname, number):
     """Called when Blog comment number N on post 'postname' is added."""
     blog_post = BlogPost(self.env, postname, 0)
     blog_comment = BlogComment(self.env, postname, number)
     announcer = AnnouncementSystem(self.env)
     announcer.send(
         BlogChangeEvent(blog_post, 'comment created',
                         self.env.abs_href.blog(blog_post.name),
                         blog_comment))
예제 #9
0
 def _notify(self, build, category):
     self.log.info('BittenAnnouncedEventProducer invoked for build %r', build)
     self.log.debug('build status: %s', build.status)
     self.log.info('Creating announcement for build %r', build)
     try:
         announcer = AnnouncementSystem(self.env)
         announcer.send(BittenAnnouncedEvent(build, category))
     except Exception, e:
         self.log.exception("Failure creating announcement for build "
                            "%s: %s", build.id, e)
예제 #10
0
 def wiki_page_changed(self, page, version, t, comment, author):
     announcer = AnnouncementSystem(page.env)
     announcer.send(
         WikiChangeEvent('wiki',
                         'changed',
                         page,
                         comment=comment,
                         author=author,
                         version=version,
                         timestamp=t))
예제 #11
0
 def attachment_added(self, attachment):
     parent = attachment.resource.parent
     if parent.realm == 'ticket':
         ticket = Ticket(self.env, parent.id)
         announcer = AnnouncementSystem(ticket.env)
         announcer.send(
             TicketChangeEvent('ticket',
                               'attachment added',
                               ticket,
                               attachment=attachment,
                               author=attachment.author))
     elif parent.realm == 'wiki':
         page = WikiPage(self.env, parent.id)
         announcer = AnnouncementSystem(page.env)
         announcer.send(
             WikiChangeEvent('wiki',
                             'attachment added',
                             page,
                             attachment=attachment,
                             author=attachment.author))
예제 #12
0
 def __init__(self):
     try:
         schema_ver = AnnouncementSystem(self.env).get_schema_version()
         if schema_ver > 2:
             # Support only current db schema versions.
             #   For older ones at least information stored in
             #   'session_attribute' is already handled by the
             #   respective user ID changer component for Trac core.
             self.enabled = True
     except AttributeError:
         # Some older plugin version found.
         pass
예제 #13
0
    def blog_comment_deleted(self, postname, number, fields):
        """Called when blog post comment 'number' is deleted.

        number==0 denotes all comments is deleted and fields will be empty.
        (usually follows a delete of the blog post).

        number>0 denotes a specific comment is deleted, and fields will contain
        the values of the fields as they existed pre-delete.
        """
        blog_post = BlogPost(self.env, postname, 0)
        announcer = AnnouncementSystem(self.env)
        announcer.send(
            BlogChangeEvent(blog_post, 'comment deleted',
                            self.env.abs_href.blog(blog_post.name), fields))
예제 #14
0
    def blog_post_deleted(self, postname, version, fields):
        """Called when a blog post is deleted:

        version==0 means all versions (or last remaining) version is deleted.
        Any version>0 denotes a specific version only.
        Fields is a dict with the pre-existing values of the blog post.
        If all (or last) the dict will contain the 'current' version
        contents.
        """
        blog_post = BlogPost(self.env, postname, version)
        announcer = AnnouncementSystem(self.env)
        announcer.send(
            BlogChangeEvent(blog_post, 'post deleted',
                            self.env.abs_href.blog(blog_post.name)))
예제 #15
0
    def blog_post_changed(self, postname, version):
        """Called when a new blog post 'postname' with 'version' is added.

        version==1 denotes a new post, version>1 is a new version on existing
        post.
        """
        blog_post = BlogPost(self.env, postname, version)
        action = 'post created'
        if version > 1:
            action = 'post changed'
        announcer = AnnouncementSystem(self.env)
        announcer.send(
            BlogChangeEvent(blog_post, action,
                            self.env.abs_href.blog(blog_post.name)))
예제 #16
0
 def wiki_page_version_deleted(self, page):
     announcer = AnnouncementSystem(page.env)
     announcer.send(
         WikiChangeEvent("wiki", "version deleted", page)
     )
예제 #17
0
 def setUp(self):
     self.env = EnvironmentStub(enable=['trac.*', 'announcer.*'])
     self.env.path = tempfile.mkdtemp()
     self.db_mgr = DatabaseManager(self.env)
     self.db = self.env.get_db_cnx()
     self.an_sys = AnnouncementSystem(self.env)
예제 #18
0
 def wiki_page_deleted(self, page):
     announcer = AnnouncementSystem(page.env)
     announcer.send(WikiChangeEvent('wiki', 'deleted', page))