notifications when close/reopen issue
This commit is contained in:
parent
745a28dce4
commit
3074b99017
6 changed files with 40 additions and 34 deletions
|
@ -9,7 +9,6 @@ from issue.models import *
|
||||||
def notify_new_issue(issue):
|
def notify_new_issue(issue):
|
||||||
|
|
||||||
project = issue.project
|
project = issue.project
|
||||||
|
|
||||||
dests = project.subscribers.all().distinct()
|
dests = project.subscribers.all().distinct()
|
||||||
|
|
||||||
if hasattr(settings, 'FROM_ADDR'):
|
if hasattr(settings, 'FROM_ADDR'):
|
||||||
|
@ -17,10 +16,9 @@ def notify_new_issue(issue):
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
subject = "[PonyTracker] New issue: %s (%s)" %(issue.title, project)
|
subject = "[%s] %s" %(project, issue.title)
|
||||||
|
|
||||||
data = []
|
data = []
|
||||||
|
|
||||||
for dest in dests:
|
for dest in dests:
|
||||||
|
|
||||||
if dest == issue.author:
|
if dest == issue.author:
|
||||||
|
@ -31,22 +29,32 @@ def notify_new_issue(issue):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
c = {
|
c = {
|
||||||
'dest': dest.username,
|
'description': issue.description,
|
||||||
'author': issue.author.username,
|
|
||||||
'title': issue.title,
|
|
||||||
'description:': issue.description,
|
|
||||||
'uri': settings.BASE_URL \
|
'uri': settings.BASE_URL \
|
||||||
+ reverse('show-issue', args=[project.name, issue.id]),
|
+ reverse('show-issue', args=[project.name, issue.id]),
|
||||||
}
|
}
|
||||||
|
|
||||||
message = render_to_string('emails/new_issue.html', c)
|
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))
|
send_mass_mail(tuple(data))
|
||||||
|
|
||||||
|
|
||||||
def notify_new_comment(event):
|
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
|
issue = event.issue
|
||||||
project = issue.project
|
project = issue.project
|
||||||
|
@ -60,7 +68,7 @@ def notify_new_comment(event):
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
subject = "[PonyTracker] New comment - %s (%s)" %(issue.title, project)
|
subject = "Re: [%s] %s" %(project, issue.title)
|
||||||
|
|
||||||
data = []
|
data = []
|
||||||
|
|
||||||
|
@ -74,16 +82,14 @@ def notify_new_comment(event):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
c = {
|
c = {
|
||||||
'dest': dest.username,
|
|
||||||
'author': event.author.username,
|
|
||||||
'title': issue.title,
|
|
||||||
'comment': event.additionnal_section,
|
'comment': event.additionnal_section,
|
||||||
'uri': settings.BASE_URL \
|
'uri': settings.BASE_URL \
|
||||||
+ reverse('show-issue', args=[project.name, issue.id]),
|
+ 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))
|
send_mass_mail(tuple(data))
|
||||||
|
|
4
issue/templates/emails/close_issue.html
Normal file
4
issue/templates/emails/close_issue.html
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
Issue closed.
|
||||||
|
|
||||||
|
--
|
||||||
|
You can see the issue on PonyTracker: {{ uri }}
|
|
@ -1,12 +1,4 @@
|
||||||
Dear {{ dest }},
|
{{ comment }}
|
||||||
|
|
||||||
{{ author }} commented the issue '{{ title }}':
|
--
|
||||||
|
Respond on PonyTracker: {{ uri }}
|
||||||
{{ comment }}
|
|
||||||
|
|
||||||
You can respond by following this link:
|
|
||||||
|
|
||||||
{{ uri }}
|
|
||||||
|
|
||||||
Sincerly,
|
|
||||||
PonyTracker
|
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
Dear {{ dest }},
|
|
||||||
|
|
||||||
{{ author }} added a new issue: '{{ title }}'
|
|
||||||
{% if description %}
|
{% if description %}
|
||||||
{{ description }}
|
{{ description }}
|
||||||
|
{% else %}
|
||||||
|
No description.
|
||||||
{% endif %}
|
{% endif %}
|
||||||
You can coment it by following this link:
|
|
||||||
|
|
||||||
{{ uri }}
|
--
|
||||||
|
Comment it on PonyTracker: {{ uri }}
|
||||||
Sincerly,
|
|
||||||
PonyTracker
|
|
||||||
|
|
4
issue/templates/emails/reopen_issue.html
Normal file
4
issue/templates/emails/reopen_issue.html
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
Issue reopened.
|
||||||
|
|
||||||
|
--
|
||||||
|
You can see the issue on PonyTracker: {{ uri }}
|
|
@ -521,6 +521,8 @@ def issue_close(request, project, issue):
|
||||||
event = Event(issue=issue, author=author, code=Event.CLOSE)
|
event = Event(issue=issue, author=author, code=Event.CLOSE)
|
||||||
event.save()
|
event.save()
|
||||||
|
|
||||||
|
notify_close_issue(event)
|
||||||
|
|
||||||
return redirect('list-issue', project.name)
|
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 = Event(issue=issue, author=author, code=Event.REOPEN)
|
||||||
event.save()
|
event.save()
|
||||||
|
|
||||||
|
notify_reopen_issue(event)
|
||||||
|
|
||||||
return redirect('show-issue', project.name, issue.id)
|
return redirect('show-issue', project.name, issue.id)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue