Changeset 745


Ignore:
Timestamp:
12/02/08 15:22:15 (5 years ago)
Author:
rcorsaro
Message:

merged latest announcer trac-hacks commits

Location:
trunk/trac-hacks/announcerplugin/announcerplugin
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/trac-hacks/announcerplugin/announcerplugin/api.py

    r450 r745  
    313313                    self.log.debug(stmt) 
    314314                    cursor.execute(stmt) 
     315                    db.commit() 
    315316 
    316317        except Exception, e: 
  • trunk/trac-hacks/announcerplugin/announcerplugin/distributors/email_distributor.py

    r631 r745  
    33from trac.config import Option, BoolOption, IntOption, OrderedExtensionsOption 
    44from trac.util import get_pkginfo 
     5from trac.util.translation import _ 
     6 
    57from announcerplugin.api import IAnnouncementDistributor 
    68from announcerplugin.api import IAnnouncementFormatter 
     
    1315from email.MIMEText import MIMEText 
    1416from email.Utils import formatdate 
    15 from email.header import Header 
     17try: 
     18    from email.header import Header 
     19except: 
     20    from email.Header import Header 
    1621import time, Queue, threading, smtplib 
    1722 
     
    119124     
    120125    default_email_format = Option('announcer', 'default_email_format', 'text/plain') 
    121      
     126 
    122127    def __init__(self): 
    123         if self.smtp_enabled and self.use_threaded_delivery: 
    124             self._deliveryQueue = Queue.Queue() 
    125             thread = DeliveryThread(self._deliveryQueue, self._transmit) 
     128        self.delivery_queue = None 
     129 
     130    def get_delivery_queue(self): 
     131        if not self.delivery_queue: 
     132            self.delivery_queue = Queue.Queue() 
     133            thread = DeliveryThread(self.delivery_queue, self._transmit) 
    126134            thread.start() 
     135 
     136        return self.delivery_queue 
    127137     
    128138    # IAnnouncementDistributor 
     
    133143        if not self.smtp_enabled: 
    134144            return 
    135          
    136145        public_cc = self.config.getbool('announcer', 'use_public_cc') 
    137146        to = self.config.get('announcer', 'smtp_to') 
     
    228237        subject = formatter.format_subject(transport, event.realm, format, event) 
    229238         
    230         charset = self.env.config.get('trac', 'default_charset') or 'utf-8' 
     239        charset = self.env.config.get('trac', 'default_charset', 'utf-8') 
    231240        alternate_format = formatter.get_format_alternative(transport, event.realm, format) 
    232241        if alternate_format: 
     
    277286        package = (self.smtp_from, [x[2] for x in recipients if x], rootMessage.as_string() ) 
    278287        if self.use_threaded_delivery: 
    279             self._deliveryQueue.put(package) 
     288            self.get_delivery_queue().put(package) 
    280289        else: 
    281290            self._transmit(*package) 
     
    285294 
    286295    def _transmit(self, smtpfrom, addresses, message): 
    287         smtp = smtplib.SMTP() 
    288         smtp.connect(self.smtp_server) 
     296        smtp = smtplib.SMTP(self.smtp_server, self.smtp_port) 
    289297        if self.use_tls: 
    290298            smtp.ehlo() 
     299            if not smtp.esmtp_features.has_key('starttls'): 
     300                raise TracError(_("TLS enabled but server does not support " \ 
     301                        "TLS")) 
    291302            smtp.starttls() 
    292303            smtp.ehlo() 
  • trunk/trac-hacks/announcerplugin/announcerplugin/formatters/ticket_email.py

    r175 r745  
    9393        long_changes = {} 
    9494         
    95         for field, old_value in event.changes.items(): 
    96             new_value = ticket[field] 
     95        changed_items = [(field, unicode(old_value)) for field, old_value in  
     96            event.changes.items()] 
     97        for field, old_value in changed_items: 
     98            new_value = unicode(ticket[field]) 
    9799            if ('\n' in new_value) or ('\n' in old_value): 
    98100                # long_changes[field.capitalize()] = \ 
     
    122124            project_name = self.env.project_name, 
    123125            project_desc = self.env.project_description, 
    124             project_link = self.env.project_url, 
     126            project_link = self.env.project_url or self.env.abs_href(), 
    125127            has_changes = short_changes or long_changes, 
    126128            long_changes = long_changes, 
     
    179181            project_name = self.env.project_name, 
    180182            project_desc = self.env.project_description, 
    181             project_link = self.env.project_url, 
     183            project_link = self.env.project_url or self.env.abs_href(), 
    182184            has_changes = short_changes or long_changes, 
    183185            long_changes = long_changes, 
  • trunk/trac-hacks/announcerplugin/announcerplugin/htdocs/css/announcer_prefs.css

    r596 r745  
    66    text-align: left; 
    77    margin: 1em; 
    8 } 
    9  
    10 div.announcer_preference_box ul {  
    11         list-style:none;  
    128} 
    139 
  • trunk/trac-hacks/announcerplugin/announcerplugin/subscribers/ticket_compat.py

    r559 r745  
    4949        notification section, except users can opt-out in their preferences. Used 
    5050        only if LegacyTicketSubscriber is enabled.""") 
     51 
     52    always_notify_component_owner = BoolOption("announcer",  
     53            "always_notify_component_owner", True, 
     54            """Whether or not to notify the owner of the ticket's  
     55            component.""") 
    5156         
    5257    def get_announcement_preference_boxes(self, req): 
    53         yield "legacy", "Legacy Notification (Opt-Out)" 
     58        yield "legacy", "Ticket Notifications" 
    5459 
    5560    def render_announcement_preference_box(self, req, panel): 
     
    6974        if req.method == "POST": 
    7075            if always_notify_owner: 
    71                 sess['announcer_legacy_notify_owner'] = req.args.get('legacy_notify_owner', False) 
     76                sess['announcer_legacy_notify_owner'] = unicode(req.args.get('legacy_notify_owner', False)) 
    7277            if always_notify_reporter: 
    73                 sess['announcer_legacy_notify_reporter'] = req.args.get('legacy_notify_reporter', False) 
     78                sess['announcer_legacy_notify_reporter'] = unicode(req.args.get('legacy_notify_reporter', False)) 
    7479            if always_notify_updater: 
    75                 sess['announcer_legacy_notify_updater'] = req.args.get('legacy_notify_updater', False) 
     80                sess['announcer_legacy_notify_updater'] = unicode(req.args.get('legacy_notify_updater', False)) 
    7681         
    7782        data = dict( 
     
    100105             
    101106            if event.category in ('created', 'changed', 'attachment added'): 
    102                 try: 
    103                     # this throws an exception if the component does not exist 
    104                     component = model.Component(self.env, ticket['component']) 
    105                     if component.owner: 
    106                         ## TODO: Is this an option? 
    107                         self.log.debug("LegacyTicketSubscriber added '%s' because of rule: component owner" % (component.owner,)) 
    108                         yield ('email', component.owner, True, None) 
    109                 except ResourceNotFound, message: 
    110                     self.log.warn("LegacyTicketSubscriber couldn't add component owner because component was not found, message: '%s'" % (message,))     
     107                if self.always_notify_component_owner: 
     108                    try: 
     109                        # this throws an exception if the component does not exist 
     110                        component = model.Component(self.env, ticket['component']) 
     111                        if component.owner: 
     112                            self.log.debug("LegacyTicketSubscriber added '%s' because of rule: component owner" % (component.owner,)) 
     113                            yield ('email', component.owner, True, None) 
     114                    except ResourceNotFound, message: 
     115                        self.log.warn("LegacyTicketSubscriber couldn't add component owner because component was not found, message: '%s'" % (message,))     
    111116 
    112117                if self.always_notify_owner and ticket['owner'] and not self._check_opt_out('notify_owner', ticket['owner']):                    
  • trunk/trac-hacks/announcerplugin/announcerplugin/subscribers/watchers.py

    r732 r745  
    7777               AND category=%s 
    7878               AND rule=%s 
    79         """, (sid, int(authenticated), 'watcher', realm, '*', resource)) 
     79        """, (sid, int(authenticated), 'watcher', realm, '*', unicode(resource))) 
    8080         
    8181        result = cursor.fetchone() 
     
    127127               AND category=%s 
    128128               AND rule=%s 
    129         """, (sid, int(authenticated), 'watcher', realm, '*', resource)) 
     129        """, (sid, int(authenticated), 'watcher', realm, '*', unicode(resource))) 
    130130         
    131131        if not use_db: 
     
    198198               AND realm=%s 
    199199               AND rule=%s 
    200         """, ('watcher', 'wiki', page.name)) 
     200        """, ('watcher', 'wiki', unicode(page.name))) 
    201201 
    202202        db.commit() 
     
    224224               AND realm=%s 
    225225               AND rule=%s 
    226         """, ('watcher', 'ticket', str(ticket.id))) 
     226        """, ('watcher', 'ticket', unicode(ticket.id))) 
    227227 
    228228        db.commit() 
     
    250250                       AND rule=%s 
    251251                """, ('watcher', event.realm, '*',  
    252                     str(self._get_target_identifier(event.realm,  
     252                    unicode(self._get_target_identifier(event.realm,  
    253253                    event.target)))) 
    254254             
  • trunk/trac-hacks/announcerplugin/announcerplugin/templates/prefs_announcer_joinable_groups.html

    r175 r745  
    55  receive any email for them unless you choose to. They are general topics that may be added onto the CC list of tickets 
    66  (by prepending their name with @), which can be used to bring specific attention to those people who are concerned 
    7   with the topic. 
     7  with the topic. Case does matter. 
    88  <ul py:for="group in joinable_groups"> 
    99    <li> 
    10       <input type="checkbox" name="joinable_group_${group}" checked="${joinable_groups[group]}" value="1" /> ${group.capitalize()} 
     10      <input type="checkbox" name="joinable_group_${group}" checked="${joinable_groups[group]}" value="1" /> ${group} 
    1111    </li> 
    1212  </ul> 
  • trunk/trac-hacks/announcerplugin/announcerplugin/templates/prefs_announcer_legacy.html

    r175 r745  
    22     xmlns:py="http://genshi.edgewall.org/" 
    33     xmlns:xi="http://www.w3.org/2001/XInclude"> 
    4   The legacy mode has been activated by the administrators, with the following options: 
    54  <ul> 
    65    <li py:if="always_notify_owner"> 
    76      <input type="checkbox" name="legacy_notify_owner" checked="${legacy_notify_owner}" value="1" /> 
    8       Always notify the ticket's owner. 
     7      Notify me of changes to tickets that I own. 
    98    </li>         
    109    <li py:if="always_notify_reporter"> 
    1110      <input type="checkbox" name="legacy_notify_reporter" checked="${legacy_notify_reporter}" value="1" /> 
    12       Always notify the ticket's reporter. 
     11      Notify me of changes to tickets that I reported. 
    1312    </li>         
    1413    <li py:if="always_notify_updater"> 
    1514      <input type="checkbox" name="legacy_notify_updater" checked="${legacy_notify_updater}" value="1" /> 
    16       Always notify the person updating the ticket. 
     15      Notify me when I update a ticket. 
    1716    </li>         
    1817  </ul> 
    19   If you would like to opt-out of any of these announcements, simply uncheck them. 
    2018</span> 
Note: See TracChangeset for help on using the changeset viewer.