* Added support for e-maling a queue "CC" address (two options here, one for new tickets only, one for all queue activity)

* Added support for e-mailing submitter when a ticket is closed
* Added facility to e-mail owner when someone else acts on their ticket
This commit is contained in:
Ross Poulton 2008-01-21 01:02:12 +00:00
parent 041272ce1b
commit 6ef420427d
23 changed files with 309 additions and 1 deletions

View File

@ -97,10 +97,19 @@ class TicketForm(forms.Form):
'queue': q,
}
from helpdesk.lib import send_multipart_mail
if t.submitter_email:
from helpdesk.lib import send_multipart_mail
send_multipart_mail('helpdesk/emails/submitter_newticket', context, '%s %s' % (t.ticket, t.title), t.submitter_email, q.from_address)
if t.assigned_to != user:
send_multipart_mail('helpdesk/emails/owner_assigned', context, '%s %s (Opened)' % (t.ticket, t.title), t.assigned_to.email, q.from_address)
if q.new_ticket_cc:
send_multipart_mail('helpdesk/emails/cc_newticket', context, '%s %s (Opened)' % (t.ticket, t.title), q.updated_ticket_cc, q.from_address)
elif q.updated_ticket_cc and q.updated_ticket_cc != q.new_ticket_cc:
send_multipart_mail('helpdesk/emails/cc_newticket', context, '%s %s (Opened)' % (t.ticket, t.title), q.updated_ticket_cc, q.from_address)
return t
class PublicTicketForm(forms.Form):
@ -159,4 +168,9 @@ class PublicTicketForm(forms.Form):
from helpdesk.lib import send_multipart_mail
send_multipart_mail('helpdesk/emails/submitter_newticket', context, '%s %s' % (t.ticket, t.title), t.submitter_email, q.from_address)
if q.new_ticket_cc:
send_multipart_mail('helpdesk/emails/cc_newticket', context, '%s %s (Opened)' % (t.ticket, t.title), q.updated_ticket_cc, q.from_address)
elif q.updated_ticket_cc and q.updated_ticket_cc != q.new_ticket_cc:
send_multipart_mail('helpdesk/emails/cc_newticket', context, '%s %s (Opened)' % (t.ticket, t.title), q.updated_ticket_cc, q.from_address)
return t

View File

@ -56,6 +56,9 @@ class Queue(models.Model):
return '%s <%s>' % (self.title, self.email_address)
from_address = property(_from_address)
new_ticket_cc = models.EmailField(blank=True, null=True, help_text='If an e-mail address is entered here, then it will receive notification of all new tickets created for this queue')
updated_ticket_cc = models.EmailField(blank=True, null=True, help_text='If an e-mail address is entered here, then it will receive notification of all activity (new tickets, closed tickets, updates, reassignments, etc) for this queue')
email_box_type = models.CharField(maxlength=5, choices=(('pop3', 'POP 3'),('imap', 'IMAP')), blank=True, null=True, help_text='E-Mail Server Type - Both POP3 and IMAP are supported. Select your email server type here.')
email_box_host = models.CharField(maxlength=200, blank=True, null=True, help_text='Your e-mail server address - either the domain name or IP address. May be "localhost".')
email_box_port = models.IntegerField(blank=True, null=True, help_text='Port number to use for accessing e-mail. Default for POP3 is "110", and for IMAP is "143". This may differ on some servers.')
@ -174,6 +177,13 @@ class Ticket(models.Model):
return "http://%s%s?ticket=%s&email=%s" % (site.domain, reverse('helpdesk_public_view'), self.ticket_for_url, self.submitter_email)
ticket_url = property(_get_ticket_url)
def _get_staff_url(self):
from django.contrib.sites.models import Site
from django.core.urlresolvers import reverse
site = Site.objects.get_current()
return "http://%s%s" % (site.domain, reverse('helpdesk_view', args=[self.id]))
staff_url = property(_get_staff_url)
class Admin:
list_display = ('title', 'status', 'assigned_to', 'submitter_email',)
date_hierarchy = 'created'

View File

@ -0,0 +1,10 @@
{% extends "helpdesk/emails/base.html" %}
{% block header %}Ticket Re-Assigned{% endblock %}
{% block content %}
<p style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt;'>Hello,</p>
<p style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt;'>This is a courtesy e-mail to let you know that ticket <a href='{{ ticket.staff_url }}'><b>{{ ticket.ticket }}</b></a> (<em>{{ ticket.title }}</em>) has been {% if ticket.assigned_to %}assigned to {{ ticket.assigned_to %}{% else %}unassigned{% endif %}.</p>
{% endblock %}

View File

@ -0,0 +1,7 @@
Hello,
This is a courtesy e-mail to let you know that ticket {{ ticket.ticket }} ("{{ ticket.title }}") has been {% if ticket.assigned_to %}assigned to {{ ticket.assigned_to }}{% else %}unassigned{% endif %}
You can view this online at {{ ticket.staff_url }}.
{% include "helpdesk/emails/text_footer.txt" %}

View File

@ -0,0 +1,12 @@
{% extends "helpdesk/emails/base.html" %}
{% block header %}Ticket Closed{% endblock %}
{% block content %}
<p style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt;'>Hello,</p>
<p style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt;'>Ticket <i>{{ ticket.title }}</i> ("{{ ticket.title }}") has been closed.</p>
<p style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt;'>If you wish to view this ticket online, you can visit <a href="{{ ticket.get_staff_url }}">{{ ticket.get_staff_url }}</a>.</p>
{% endblock %}

View File

@ -0,0 +1,7 @@
Hello,
Ticket {{ ticket.title }} ("{{ ticket.title }}") has been closed.
If you wish to view this ticket online, you can visit {{ ticket.get_staff_url }}.
{% include "helpdesk/emails/text_footer.txt" %}

View File

@ -0,0 +1,10 @@
{% extends "helpdesk/emails/base.html" %}
{% block header %}Ticket Re-Assigned{% endblock %}
{% block content %}
<p style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt;'>Hello,</p>
<p style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt;'>This is a courtesy e-mail to let you know that ticket <a href='{{ ticket.staff_url }}'><b>{{ ticket.ticket }}</b></a> (<em>{{ ticket.title }}</em>) has been opened.</p>
{% endblock %}

View File

@ -0,0 +1,7 @@
Hello,
This is a courtesy e-mail to let you know that ticket {{ ticket.ticket }} ("{{ ticket.title }}") has been opened.
You can view this online at {{ ticket.staff_url }}.
{% include "helpdesk/emails/text_footer.txt" %}

View File

@ -0,0 +1,18 @@
{% extends "helpdesk/emails/base.html" %}
{% block header %}Ticket Resolution{% endblock %}
{% block content %}
<p style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt;'>Hello,</p>
<p style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt;'>Ticket {{ ticket.ticket }} (<i>{{ ticket.title }}</i>) has been resolved.</p>
<p style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt;'>The following resolution was added:</p>
<blockquote style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt; padding-left: 20px; border-left: solid #ccc 2px;'>{{ resolution }}</blockquote>
<p style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt;'>This resolution has been e-mailed to the submitter, who will verify it before you can close this ticket.</p>
<p style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt;'>If you wish to view this ticket online, you can visit <a href="{{ ticket.get_staff_url }}">{{ ticket.get_staff_url }}</a>.</p>
{% endblock %}

View File

@ -0,0 +1,13 @@
Hello,
Ticket {{ ticket.ticket }} ({{ ticket.title }}) has been resolved.
The following resolution was added:
{{ resolution }}
This resolution has been e-mailed to the submitter, who will verify it before you can close this ticket.
If you wish to view this ticket online, you can visit {{ ticket.get_staff_url }}.
{% include "helpdesk/emails/text_footer.txt" %}

View File

@ -0,0 +1,18 @@
{% extends "helpdesk/emails/base.html" %}
{% block header %}Ticket Updated{% endblock %}
{% block content %}
<p style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt;'>Hello,</p>
<p style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt;'>Ticket <a href='{{ ticket.staff_url }}'>{{ ticket.ticket }}</a> (<em>{{ ticket.title }}</em>) has been updated.</p>
<p style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt;'>The following comment was added:</p>
<blockquote style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt; padding-left: 20px; border-left: solid #ccc 2px;'>{{ comment }}</blockquote>
<p style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt;'>This information has {% if private %}not {% endif %} been e-mailed to the submitter.</p>
<p style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt;'>If you wish to view this ticket online, you can visit <a href="{{ ticket.staff_url }}">{{ ticket.staff_url }}</a>.</p>
{% endblock %}

View File

@ -0,0 +1,13 @@
Hello,
Ticket {{ ticket.ticket }} ({{ ticket.title }}) has been updated.
The following comment was added:
{{ comment }}
This information has {% if private %}not {% endif %} been e-mailed to the submitter.
If you wish to view this ticket online, you can visit {{ ticket.staff_url }}.
{% include "helpdesk/emails/text_footer.txt" %}

View File

@ -0,0 +1,15 @@
{% extends "helpdesk/emails/base.html" %}
{% block header %}Ticket Assigned To You{% endblock %}
{% block content %}
<p style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt;'>Hello,</p>
<p style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt;'>This is a courtesy e-mail to let you know that a ticket has been assigned to you.</p>
<p style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt;'>{% if ticket.submitter_email %}The ticket was submitted by {{ ticket.submitter_email }}, and the subject{% else %}The ticket subject{% endif%} is <i>{{ ticket.title }}</i>.</p>
<p style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt;'>The ticket ID is <a href='{{ ticket.staff_url }}'><b>{{ ticket.ticket }}</a></b>. It's priority is {{ ticket.get_priority_display }}.</p>
{% endblock %}

View File

@ -0,0 +1,9 @@
Hello,
This is a courtesy e-mail to let you know that a ticket has been assigned to you.
{% if ticket.submitter_email %}The ticket was submitted by {{ ticket.submitter_email }}, and the subject{% else %}The ticket subject{% endif%} is {{ ticket.title }}.
The ticket ID is {{ ticket.ticket }}, you can view it online at {{ ticket.staff_url }}. It's priority is {{ ticket.get_priority_display }}.
{% include "helpdesk/emails/text_footer.txt" %}

View File

@ -0,0 +1,12 @@
{% extends "helpdesk/emails/base.html" %}
{% block header %}Ticket Closed{% endblock %}
{% block content %}
<p style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt;'>Hello,</p>
<p style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt;'>A ticket currently assigned to you with a subject of <i>{{ ticket.title }}</i> has been closed.</p>
<p style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt;'>If you wish to view this ticket online, you can visit <a href="{{ ticket.get_staff_url }}">{{ ticket.get_staff_url }}</a>.</p>
{% endblock %}

View File

@ -0,0 +1,7 @@
Hello,
A ticket currently assigned to you with a subject of "{{ ticket.title }}" has been closed.
If you wish to view this ticket online, you can visit {{ ticket.get_staff_url }}.
{% include "helpdesk/emails/text_footer.txt" %}

View File

@ -0,0 +1,18 @@
{% extends "helpdesk/emails/base.html" %}
{% block header %}Ticket Resolution{% endblock %}
{% block content %}
<p style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt;'>Hello,</p>
<p style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt;'>A ticket currently assigned to you with a subject of <i>{{ ticket.title }}</i> has had a resolution added.</p>
<p style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt;'>The following resolution was added to ticket <b>{{ ticket.ticket }}</b>:</p>
<blockquote style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt; padding-left: 20px; border-left: solid #ccc 2px;'>{{ resolution }}</blockquote>
<p style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt;'>This resolution has been e-mailed to the submitter, who will verify it before you can close this ticket.</p>
<p style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt;'>If you wish to view this ticket online, you can visit <a href="{{ ticket.get_staff_url }}">{{ ticket.get_staff_url }}</a>.</p>
{% endblock %}

View File

@ -0,0 +1,13 @@
Hello,
A ticket currently assigned to you with a subject of {{ ticket.title }} has had a resolution added.
The following resolution was added to ticket {{ ticket.ticket }}:
{{ resolution }}
This resolution has been e-mailed to the submitter, who will verify it before you can close this ticket.
If you wish to view this ticket online, you can visit {{ ticket.get_staff_url }}.
{% include "helpdesk/emails/text_footer.txt" %}

View File

@ -0,0 +1,18 @@
{% extends "helpdesk/emails/base.html" %}
{% block header %}Ticket Updated{% endblock %}
{% block content %}
<p style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt;'>Hello,</p>
<p style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt;'>Ticket <a href='{{ ticket.staff_url }}'>{{ ticket.ticket }}</a> (<em>{{ ticket.title }}</em>), which is assigned to you, has been updated.</p>
<p style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt;'>The following comment was added to ticket <b>{{ ticket.ticket }}</b>:</p>
<blockquote style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt; padding-left: 20px; border-left: solid #ccc 2px;'>{{ comment }}</blockquote>
<p style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt;'>This information has {% if private %}not {% endif %} been e-mailed to the submitter.</p>
<p style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt;'>If you wish to view this ticket online, you can visit <a href="{{ ticket.staff_url }}">{{ ticket.staff_url }}</a>.</p>
{% endblock %}

View File

@ -0,0 +1,13 @@
Hello,
Ticket {{ ticket.ticket }} ({{ ticket.title }}), which is assigned to you, has been updated.
The following comment was added to ticket {{ ticket.ticket }}:
{{ comment }}
This information has {% if private %}not {% endif %} been e-mailed to the submitter.
If you wish to view this ticket online, you can visit {{ ticket.staff_url }}.
{% include "helpdesk/emails/text_footer.txt" %}

View File

@ -0,0 +1,14 @@
{% extends "helpdesk/emails/base.html" %}
{% block header %}Your Ticket Has Been Closed{% endblock %}
{% block content %}
<p style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt;'>Hello,</p>
<p style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt;'>You recently logged a ticket with a subject of <i>{{ ticket.title }}</i> with us. This e-mail is to confirm that this ticket has been closed.</p>
<p style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt;'>If you believe that further work is required on this ticket, please let us know by replying to this e-mail and keeping the subject intact.</p>
<p style='font-family: "Trebuchet MS", Arial, sans-serif; font-size: 11pt;'>If you wish to view this ticket online, you can visit <a href="{{ ticket.get_ticket_url }}">{{ ticket.get_ticket_url }}</a>.</p>
{% endblock %}

View File

@ -0,0 +1,9 @@
Hello,
You recently logged a ticket with a subject of "{{ ticket.title }}" with us. This e-mail is to confirm that this ticket has been closed.
If you believe that further work is required on this ticket, please let us know by replying to this e-mail and keeping the subject intact.
If you wish to view this ticket online, you can visit {{ ticket.get_ticket_url }}.
{% include "helpdesk/emails/text_footer.txt" %}

View File

@ -137,11 +137,14 @@ def update_ticket(request, ticket_id):
if public:
f.public = True
reassigned = False
if owner:
if owner != 0 and (ticket.assigned_to and owner != ticket.assigned_to.id) or not ticket.assigned_to:
new_user = User.objects.get(id=owner)
f.title = 'Assigned to %s' % new_user.username
ticket.assigned_to = new_user
reassigned = True
else:
f.title = 'Unassigned'
ticket.assigned_to = None
@ -186,11 +189,49 @@ def update_ticket(request, ticket_id):
if f.new_status == Ticket.RESOLVED_STATUS:
template = 'helpdesk/emails/submitter_resolved'
subject = '%s %s (Resolved)' % (ticket.ticket, ticket.title)
elif f.new_status == Ticket.CLOSED_STATUS:
template = 'helpdesk/emails/submitter_closed'
subject = '%s %s (Closed)' % (ticket.ticket, ticket.title)
else:
template = 'helpdesk/emails/submitter_updated'
subject = '%s %s (Updated)' % (ticket.ticket, ticket.title)
send_multipart_mail(template, context, subject, ticket.submitter_email, ticket.queue.from_address)
if ticket.assigned_to and request.user != ticket.assigned_to:
# We only send e-mails to staff members if the ticket is updated by
# another user.
if reassigned:
template_staff = 'helpdesk/emails/owner_assigned'
subject = '%s %s (Assigned)' % (ticket.ticket, ticket.title)
elif f.new_status == Ticket.RESOLVED_STATUS:
template_staff = 'helpdesk/emails/owner_resolved'
subject = '%s %s (Resolved)' % (ticket.ticket, ticket.title)
elif f.new_status == Ticket.CLOSED_STATUS:
template_staff = 'helpdesk/emails/owner_closed'
subject = '%s %s (Closed)' % (ticket.ticket, ticket.title)
else:
template_staff = 'helpdesk/emails/owner_updated'
subject = '%s %s (Updated)' % (ticket.ticket, ticket.title)
send_multipart_mail(template_staff, context, subject, ticket.submitter_email, ticket.queue.from_address)
if q.updated_ticket_cc:
if reassigned:
template_cc = 'helpdesk/emails/cc_assigned'
subject = '%s %s (Assigned)' % (ticket.ticket, ticket.title)
elif f.new_status == Ticket.RESOLVED_STATUS:
template_cc = 'helpdesk/emails/cc_resolved'
subject = '%s %s (Resolved)' % (ticket.ticket, ticket.title)
elif f.new_status == Ticket.CLOSED_STATUS:
template_cc = 'helpdesk/emails/cc_closed'
subject = '%s %s (Closed)' % (ticket.ticket, ticket.title)
else:
template_cc = 'helpdesk/emails/cc_updated'
subject = '%s %s (Updated)' % (ticket.ticket, ticket.title)
send_multipart_mail(template_cc, context, q.updated_ticket_cc, t.submitter_email, q.from_address)
ticket.save()
return HttpResponseRedirect(ticket.get_absolute_url())