* Rename Trac plugin `NewTicketNotification` to the more general `TicketNotifications`
* Add an additional package (sub-plugin): attachmentnotification - This package contains the new AttachmentTicketNotification Trac component * Add a new Trac component: AttachmentTicketNotification - This component sends notification mails to all ticket subscribers when an attachment is added to that ticket - Created this component on Per's request git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8038 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
fcaf404d25
commit
cb279c37c4
|
@ -1,3 +0,0 @@
|
||||||
/build
|
|
||||||
/dist
|
|
||||||
/NewTicketNotification.egg-info
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
/build
|
||||||
|
/dist
|
||||||
|
/TicketNotifications.egg-info
|
|
@ -0,0 +1,60 @@
|
||||||
|
# vim: set et sts=4 sw=4 encoding=utf8:
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from model import *
|
||||||
|
|
||||||
|
from trac.attachment import IAttachmentChangeListener
|
||||||
|
from trac.core import *
|
||||||
|
from trac.ticket import Ticket
|
||||||
|
from trac.ticket.notification import TicketNotifyEmail
|
||||||
|
from trac.util.text import exception_to_unicode
|
||||||
|
from trac.web.chrome import ITemplateProvider
|
||||||
|
|
||||||
|
class TicketAttachmentNotifyEmail(TicketNotifyEmail):
|
||||||
|
template_name = 'attachment_email.txt'
|
||||||
|
|
||||||
|
class AttachmentTicketNotification(Component):
|
||||||
|
"""Extends Trac to notify ticket subscribers when a new attachment is
|
||||||
|
created and attached to a ticket.
|
||||||
|
"""
|
||||||
|
|
||||||
|
implements(ITemplateProvider, IAttachmentChangeListener)
|
||||||
|
|
||||||
|
# ITemplateProvider methods
|
||||||
|
def get_htdocs_dirs(self):
|
||||||
|
"""Return a list of directories with static resources (such as style
|
||||||
|
sheets, images, etc.)
|
||||||
|
|
||||||
|
Each item in the list must be a `(prefix, abspath)` tuple. The
|
||||||
|
`prefix` part defines the path in the URL that requests to these
|
||||||
|
resources are prefixed with.
|
||||||
|
|
||||||
|
The `abspath` is the absolute path to the directory containing the
|
||||||
|
resources on the local file system.
|
||||||
|
"""
|
||||||
|
return []
|
||||||
|
|
||||||
|
def get_templates_dirs(self):
|
||||||
|
"""Return a list of directories containing the provided template
|
||||||
|
files.
|
||||||
|
"""
|
||||||
|
from pkg_resources import resource_filename
|
||||||
|
return [resource_filename(__name__, 'templates')]
|
||||||
|
|
||||||
|
# IAttachmentChangeListener methods
|
||||||
|
def attachment_added(self, attachment):
|
||||||
|
if attachment.parent_realm == 'ticket':
|
||||||
|
try:
|
||||||
|
tn = TicketAttachmentNotifyEmail(self.env)
|
||||||
|
# ticket that this attachment will modify
|
||||||
|
ticket = Ticket(self.env, tkt_id=attachment.parent_id)
|
||||||
|
tn.data.update({
|
||||||
|
'attachment': attachment,
|
||||||
|
})
|
||||||
|
tn.notify(ticket, newticket=False, modtime=attachment.date)
|
||||||
|
except Exception, e:
|
||||||
|
self.log.exception("Failure sending notification for attachment "
|
||||||
|
"on ticket #%s: %s" % (ticket.id, exception_to_unicode(e)))
|
||||||
|
|
||||||
|
def attachment_deleted(self, attachment):
|
||||||
|
pass
|
|
@ -0,0 +1,14 @@
|
||||||
|
$ticket_body_hdr
|
||||||
|
$ticket_props
|
||||||
|
|
||||||
|
Attachment $attachment.filename (${pretty_size(attachment.size)}) - added by ${attachment.author and format_author(attachment.author) or 'anonymous'}
|
||||||
|
#if attachment.description
|
||||||
|
|
||||||
|
Description:
|
||||||
|
$attachment.description
|
||||||
|
#end
|
||||||
|
|
||||||
|
--
|
||||||
|
Ticket URL: <$ticket.link>
|
||||||
|
$project.name <${project.url or abs_href()}>
|
||||||
|
$project.descr
|
|
@ -5,11 +5,17 @@
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name = 'NewTicketNotification',
|
name = 'TicketNotifications',
|
||||||
version = '0.1',
|
version = '0.1',
|
||||||
|
|
||||||
packages = ['newticketnotification'],
|
packages = [
|
||||||
package_data = { 'newticketnotification': ['templates/*.html'] },
|
'attachmentnotification',
|
||||||
|
'newticketnotification',
|
||||||
|
],
|
||||||
|
package_data = {
|
||||||
|
'attachmentnotification': ['templates/*.txt'],
|
||||||
|
'newticketnotification': ['templates/*.html'],
|
||||||
|
},
|
||||||
|
|
||||||
install_requires = ['trac>=0.11'],
|
install_requires = ['trac>=0.11'],
|
||||||
|
|
||||||
|
@ -26,6 +32,7 @@ setup(
|
||||||
|
|
||||||
entry_points = {
|
entry_points = {
|
||||||
'trac.plugins': [
|
'trac.plugins': [
|
||||||
|
'attachmentnotification.main = attachmentnotification.main',
|
||||||
'newticketnotification.admin = newticketnotification.admin',
|
'newticketnotification.admin = newticketnotification.admin',
|
||||||
'newticketnotification.main = newticketnotification.main',
|
'newticketnotification.main = newticketnotification.main',
|
||||||
],
|
],
|
Loading…
Reference in New Issue