Changeset 3086

Show
Ignore:
Timestamp:
01/17/08 19:37:48 (10 months ago)
Author:
ixokai
Message:

Fixed some logic stuff in the compatibility modules that prevented creation messages from going out to people who should get it; added more wiki notification capability that goes beyond simple 'watching'.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • announcerplugin/0.11/announcerplugin/producers/attachment.py

    r3046 r3086  
    33from announcerplugin.api import AnnouncementSystem 
    44from announcerplugin.producers.ticket import TicketChangeEvent 
     5from announcerplugin.producers.wiki import WikiChangeEvent 
    56from trac.ticket.model import Ticket 
     7from trac.wiki.model import WikiPage 
    68 
    79class AttachmentChangeProducer(Component): 
     
    2123                    attachment=attachment, author=attachment.author,  
    2224                ) 
     25            ) 
     26        elif parent.realm == "wiki": 
     27            page = WikiPage(self.env, parent.id) 
     28            announcer = AnnouncementSystem(page.env) 
     29            announcer.send( 
     30                WikiChangeEvent("wiki", "attachment added", page, 
     31                    attachment=attachment, author=attachment.author,  
     32                ) 
    2333            )             
    2434 
  • announcerplugin/0.11/announcerplugin/producers/ticket.py

    r3064 r3086  
    5656         
    5757    def ticket_changed(self, ticket, comment, author, old_values): 
    58         if old_values.keys() == ['cc'] and not comment
     58        if old_values.keys() == ['cc'] and not comment and self.ignore_cc_changes
    5959            return 
    6060             
  • announcerplugin/0.11/announcerplugin/producers/wiki.py

    r3047 r3086  
     1import inspect 
     2 
    13from trac.core import * 
    24from trac.config import BoolOption 
     
    79    def __init__(self, realm, category, target,  
    810                 comment=None, author=None, version=None,  
    9                  timestamp=None, remote_addr=None): 
     11                 timestamp=None, remote_addr=None, 
     12                 attachment=None): 
    1013        AnnouncementEvent.__init__(self, realm, category, target) 
    1114 
     
    1518        self.timestamp = timestamp 
    1619        self.remote_addr = remote_addr 
     20        self.attachment = attachment 
    1721 
    1822class WikiChangeProducer(Component): 
     
    2024     
    2125    def wiki_page_added(self, page): 
    22         pass 
     26        announcer = AnnouncementSystem(page.env) 
     27        announcer.send( 
     28            WikiChangeEvent("wiki", "created", page, 
     29                author=page.author             
     30            ) 
     31        )         
    2332         
    2433    def wiki_page_changed(self, page, version, t, comment, author, ipnr): 
    25         print "PAGE NAME", page.name 
    2634        announcer = AnnouncementSystem(page.env) 
    2735        announcer.send( 
     
    3341         
    3442    def wiki_page_deleted(page): 
    35         """Called when a page has been deleted.""" 
    36  
     43        announcer = AnnouncementSystem(page.env) 
     44        announcer.send( 
     45            WikiChangeEvent("wiki", "deleted", page) 
     46        ) 
     47         
    3748    def wiki_page_version_deleted(page): 
    38         """Called when a version of a page has been deleted.""" 
    39                  
     49        announcer = AnnouncementSystem(page.env) 
     50        announcer.send( 
     51            WikiChangeEvent("wiki", "version deleted", page) 
     52        ) 
     53         
  • announcerplugin/0.11/announcerplugin/subscribers/__init__.py

    r3064 r3086  
    33import ticket_groups 
    44import watchers 
     5import wiki 
  • announcerplugin/0.11/announcerplugin/subscribers/ticket_compat.py

    r3046 r3086  
    9797        if event.realm == "ticket": 
    9898            ticket = event.target 
    99             if event.category in ('changed', 'attachment added'): 
     99             
     100            if event.category in ('created', 'changed', 'attachment added'): 
    100101                component = model.Component(self.env, ticket['component']) 
    101102                if component.owner: 
     
    103104                    self.log.debug("LegacyTicketSubscriber added '%s' because of rule: component owner" % (component.owner,)) 
    104105                    yield ('email', component.owner, None) 
    105                                      
    106             elif event.category == "changed": 
    107                 if self.always_notify_owner and not self._check_opt_out('notify_owner', ticket['owner']):                    
     106                                                     
     107                if self.always_notify_owner and ticket['owner'] and not self._check_opt_out('notify_owner', ticket['owner']):                    
    108108                    self.log.debug("LegacyTicketSubscriber added '%s' because of rule: always_notify_owner" % ticket['owner']) 
    109109                    yield ('email', ticket['owner'], None) 
    110110                     
    111                 if self.always_notify_reporter and not self._check_opt_out('notify_reporter', ticket['reporter']): 
     111                if self.always_notify_reporter and ticket['reporter'] and not self._check_opt_out('notify_reporter', ticket['reporter']): 
    112112                    self.log.debug("LegacyTicketSubscriber added '%s' because of rule: always_notify_reporter" % ticket['reporter']) 
    113113                    yield ('email', ticket['reporter'], None) 
    114114                     
    115                 if self.always_notify_updater and not self._check_opt_out('notify_updater', event.author): 
     115                if self.always_notify_updater and event.author and not self._check_opt_out('notify_updater', event.author): 
    116116                    self.log.debug("LegacyTicketSubscriber added '%s' because of rule: always_notify_updater" % event.author) 
    117117                    yield ('email', event.author, None) 
     
    132132        result = cursor.fetchone() 
    133133        if result: 
    134             r = result[0] == '0' 
    135             self.log.debug("LegacyTicketSubscriber excluded '%s' because of opt-out rule: %s" % (sid,preference)) 
    136             return True 
     134            optout = (result[0] == '0') 
     135            if optout: 
     136                self.log.debug("LegacyTicketSubscriber excluded '%s' because of opt-out rule: %s" % (sid,preference)) 
     137                return True 
    137138         
    138139        return False 
     
    144145        return ('ticket',) 
    145146         
    146     def get_subscription_categories(self, *args): 
    147         return ('changed', 'attachment added') 
     147    def get_subscription_categories(self, realm): 
     148        if realm == 'ticket': 
     149            return ('changed', 'attachment added') 
    148150         
    149151    def get_subscriptions_for_event(self, event): 
  • announcerplugin/0.11/announcerplugin/subscribers/watchers.py

    r3051 r3086  
    233233         
    234234    def get_subscriptions_for_event(self, event): 
    235         print "CHecking subscription", event.realm 
    236235        if event.realm in self.get_subscription_realms(): 
    237236            if event.category in self.get_subscription_categories(event.realm):