-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for trac 1.4 #13
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
from setuptools import setup | ||
|
||
VERSION = '0.2.1' | ||
VERSION = '0.3.0' | ||
PACKAGE = 'ticketreminder' | ||
|
||
setup( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from api import * | ||
import pkg_resources | ||
|
||
pkg_resources.require('Trac >= 1.0') | ||
pkg_resources.require('Trac >= 1.3') | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
from trac.core import * | ||
from trac.admin import IAdminCommandProvider | ||
from trac.attachment import AttachmentModule | ||
from trac.mimeview import Context | ||
#from trac.mimeview import RenderingContext | ||
from trac.db import DatabaseManager | ||
from trac.env import IEnvironmentSetupParticipant | ||
from trac.web import ITemplateStreamFilter, IRequestHandler, IRequestFilter | ||
|
@@ -16,14 +16,17 @@ | |
from trac.util.translation import _ | ||
from trac.util import get_reporter_id | ||
from trac.ticket import Ticket, ITicketChangeListener | ||
from trac.ticket.notification import TicketNotifyEmail | ||
#from trac.ticket.notification import TicketNotifyEmail | ||
from trac.notification.api import NotificationEvent, NotificationSystem | ||
from trac.perm import IPermissionRequestor, PermissionError | ||
from trac.resource import get_resource_url, get_resource_name | ||
|
||
from genshi.core import Markup | ||
from genshi.builder import tag | ||
from genshi.filters import Transformer | ||
|
||
from trac.web.chrome import web_context | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd move this into the |
||
import db_default | ||
|
||
|
||
|
@@ -251,7 +254,7 @@ def filter_stream(self, req, method, filename, stream, data): | |
tags = self._reminder_tags(req, data) | ||
if tags: | ||
ticket_resource = data['ticket'].resource | ||
context = Context.from_request(req, ticket_resource) | ||
context = web_context(req, ticket_resource) | ||
attachments_data = AttachmentModule(self.env).attachment_data(context) | ||
|
||
add_stylesheet(req, 'ticketreminder/css/ticketreminder.css') | ||
|
@@ -281,7 +284,7 @@ def _format_reminder(self, req, ticket, id, time, author, origin, description, d | |
when = tag("In ", tag.strong(pretty_timedelta(time)), " (", format_date(time), ")") | ||
|
||
if description: | ||
context = Context.from_request(req, ticket.resource) | ||
context = web_context(req, ticket.resource) | ||
desc = tag.div(format_to_oneliner(self.env, context, description), class_="description") | ||
else: | ||
desc = tag() | ||
|
@@ -408,8 +411,10 @@ def _do_send(self, id, ticket, author, origin, description): | |
if ticket['status'] != 'closed': | ||
reminder = self._format_reminder_text(ticket, id, author, origin, description) | ||
|
||
tn = TicketReminderNotifyEmail(self.env, reminder) | ||
tn.notify(ticket) | ||
#tn = TicketReminderNotifyEmail(self.env, reminder) | ||
#tn.notify(ticket) | ||
event = TicketReminderEvent(ticket, ticket['time'], author, reminder) | ||
tn = NotificationSystem(self.env).notify(event) | ||
except Exception, e: | ||
self.env.log.error("Failure sending reminder notification for ticket #%s: %s", ticket.id, exception_to_unicode(e)) | ||
print "Failure sending reminder notification for ticket #%s: %s" % (ticket.id, exception_to_unicode(e)) | ||
|
@@ -421,22 +426,32 @@ def _do_send(self, id, ticket, author, origin, description): | |
""", (id,)) | ||
|
||
|
||
class TicketReminderNotifyEmail(TicketNotifyEmail): | ||
def __init__(self, env, reminder): | ||
super(TicketReminderNotifyEmail, self).__init__(env) | ||
self.reminder = reminder | ||
|
||
def _notify(self, ticket, newticket=True, modtime=None): | ||
description = ticket.values.get('description') | ||
ticket.values['description'] = self.reminder | ||
super(TicketReminderNotifyEmail, self)._notify(ticket, newticket, modtime) | ||
ticket.values['description'] = description | ||
|
||
def notify(self, ticket): | ||
super(TicketReminderNotifyEmail, self).notify(ticket, newticket=True) | ||
|
||
def format_subj(self, summary, newticket=True): | ||
return super(TicketReminderNotifyEmail, self).format_subj("Ticket reminder", newticket) | ||
#class TicketReminderNotifyEmail(TicketNotifyEmail): | ||
# def __init__(self, env, reminder): | ||
# super(TicketReminderNotifyEmail, self).__init__(env) | ||
# self.reminder = reminder | ||
# | ||
# def _notify(self, ticket, newticket=True, modtime=None): | ||
# description = ticket.values.get('description') | ||
# ticket.values['description'] = self.reminder | ||
# super(TicketReminderNotifyEmail, self)._notify(ticket, newticket, modtime) | ||
# ticket.values['description'] = description | ||
# | ||
# def notify(self, ticket): | ||
# super(TicketReminderNotifyEmail, self).notify(ticket, newticket=True) | ||
# | ||
# def format_subj(self, summary, newticket=True): | ||
# return super(TicketReminderNotifyEmail, self).format_subj("Ticket reminder", newticket) | ||
|
||
class TicketReminderEvent(NotificationEvent): | ||
"""Represent a ticket reminder `NotificationEvent`.""" | ||
|
||
def __init__(self, target, time, author, comment=None): | ||
|
||
super(TicketChangeEvent, self).__init__('ticket', 'reminder', target, | ||
time, author) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This class may not be necessary. |
||
self.comment = comment | ||
self.changes = {} | ||
|
||
|
||
def clear_time(date): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes you made should be compatible with 1.2 as well. Could we set this to 1.2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you can test it, sure