notifications when close/reopen issue

This commit is contained in:
Élie Bouttier 2014-08-17 14:31:41 -07:00
parent 745a28dce4
commit 3074b99017
6 changed files with 40 additions and 34 deletions

View file

@ -9,7 +9,6 @@ from issue.models import *
def notify_new_issue(issue):
project = issue.project
dests = project.subscribers.all().distinct()
if hasattr(settings, 'FROM_ADDR'):
@ -17,10 +16,9 @@ def notify_new_issue(issue):
else:
return
subject = "[PonyTracker] New issue: %s (%s)" %(issue.title, project)
subject = "[%s] %s" %(project, issue.title)
data = []
for dest in dests:
if dest == issue.author:
@ -31,22 +29,32 @@ def notify_new_issue(issue):
continue
c = {
'dest': dest.username,
'author': issue.author.username,
'title': issue.title,
'description:': issue.description,
'description': issue.description,
'uri': settings.BASE_URL \
+ reverse('show-issue', args=[project.name, issue.id]),
}
message = render_to_string('emails/new_issue.html', c)
data += [(subject, message, from_addr, [dest_addr])]
data += [(subject, message,
"%s <%s>" %(issue.author.username, from_addr), [dest_addr])]
send_mass_mail(tuple(data))
def notify_new_comment(event):
notify_event(event, 'new_comment')
def notify_close_issue(event):
notify_event(event, 'close_issue')
def notify_reopen_issue(event):
notify_event(event, 'reopen_issue')
def notify_event(event, template):
issue = event.issue
project = issue.project
@ -60,7 +68,7 @@ def notify_new_comment(event):
else:
return
subject = "[PonyTracker] New comment - %s (%s)" %(issue.title, project)
subject = "Re: [%s] %s" %(project, issue.title)
data = []
@ -74,16 +82,14 @@ def notify_new_comment(event):
continue
c = {
'dest': dest.username,
'author': event.author.username,
'title': issue.title,
'comment': event.additionnal_section,
'uri': settings.BASE_URL \
+ reverse('show-issue', args=[project.name, issue.id]),
}
message = render_to_string('emails/new_comment.html', c)
message = render_to_string('emails/%s.html' % template, c)
data += [(subject, message, from_addr, [dest_addr])]
data += [(subject, message,
'%s <%s>' %(event.author.username, from_addr), [dest_addr])]
send_mass_mail(tuple(data))

View file

@ -0,0 +1,4 @@
Issue closed.
--
You can see the issue on PonyTracker: {{ uri }}

View file

@ -1,12 +1,4 @@
Dear {{ dest }},
{{ comment }}
{{ author }} commented the issue '{{ title }}':
{{ comment }}
You can respond by following this link:
{{ uri }}
Sincerly,
PonyTracker
--
Respond on PonyTracker: {{ uri }}

View file

@ -1,12 +1,8 @@
Dear {{ dest }},
{{ author }} added a new issue: '{{ title }}'
{% if description %}
{{ description }}
{{ description }}
{% else %}
No description.
{% endif %}
You can coment it by following this link:
{{ uri }}
Sincerly,
PonyTracker
--
Comment it on PonyTracker: {{ uri }}

View file

@ -0,0 +1,4 @@
Issue reopened.
--
You can see the issue on PonyTracker: {{ uri }}

View file

@ -521,6 +521,8 @@ def issue_close(request, project, issue):
event = Event(issue=issue, author=author, code=Event.CLOSE)
event.save()
notify_close_issue(event)
return redirect('list-issue', project.name)
@ -536,6 +538,8 @@ def issue_reopen(request, project, issue):
event = Event(issue=issue, author=author, code=Event.REOPEN)
event.save()
notify_reopen_issue(event)
return redirect('show-issue', project.name, issue.id)