forked from extern/django-helpdesk
* Add smart e-mail parsing - if subject contains a ticket ID, the new e-mail
is added as a followup to that ticket. * Add basic code to support Google Charts in a future revision * Improved use of Queue "Update" CC.
This commit is contained in:
parent
224ad8722f
commit
4a082e0bfb
3
README
3
README
@ -52,6 +52,9 @@ LICENSE.JQUERY and LICENSE.NICEDIT for their respective license terms.
|
|||||||
3. An existing WORKING Django project with database etc. If you
|
3. An existing WORKING Django project with database etc. If you
|
||||||
cannot log into the Admin, you won't get this product working.
|
cannot log into the Admin, you won't get this product working.
|
||||||
|
|
||||||
|
4. pygooglechart (needs minor mods to @staticmethod calls for python 2.3)
|
||||||
|
http://pygooglechart.slowchop.com/
|
||||||
|
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
3. Installation
|
3. Installation
|
||||||
|
8
forms.py
8
forms.py
@ -102,12 +102,13 @@ class TicketForm(forms.Form):
|
|||||||
if t.submitter_email:
|
if t.submitter_email:
|
||||||
send_multipart_mail('helpdesk/emails/submitter_newticket', context, '%s %s' % (t.ticket, t.title), t.submitter_email, q.from_address)
|
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:
|
if t.assigned_to and 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)
|
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:
|
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)
|
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:
|
|
||||||
|
if 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)
|
send_multipart_mail('helpdesk/emails/cc_newticket', context, '%s %s (Opened)' % (t.ticket, t.title), q.updated_ticket_cc, q.from_address)
|
||||||
|
|
||||||
return t
|
return t
|
||||||
@ -170,7 +171,8 @@ class PublicTicketForm(forms.Form):
|
|||||||
|
|
||||||
if q.new_ticket_cc:
|
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)
|
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:
|
|
||||||
|
if 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)
|
send_multipart_mail('helpdesk/emails/cc_newticket', context, '%s %s (Opened)' % (t.ticket, t.title), q.updated_ticket_cc, q.from_address)
|
||||||
|
|
||||||
return t
|
return t
|
||||||
|
8
lib.py
8
lib.py
@ -76,3 +76,11 @@ def send_multipart_mail(template_name, email_context, subject, recipients, sende
|
|||||||
|
|
||||||
return msg.send(fail_silently)
|
return msg.send(fail_silently)
|
||||||
|
|
||||||
|
def normalise_to_100(data):
|
||||||
|
max_value = max(data)
|
||||||
|
if max_value > 100:
|
||||||
|
new_data = []
|
||||||
|
for d in data:
|
||||||
|
new_data.append(int(d/float(max_value)*100))
|
||||||
|
data = new_data
|
||||||
|
return data
|
||||||
|
@ -31,7 +31,7 @@ import imaplib
|
|||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import email, mimetypes, re
|
import email, mimetypes, re
|
||||||
from email.Utils import parseaddr
|
from email.Utils import parseaddr
|
||||||
from helpdesk.models import Queue,Ticket
|
from helpdesk.models import Queue,Ticket, FollowUp
|
||||||
from helpdesk.lib import send_multipart_mail
|
from helpdesk.lib import send_multipart_mail
|
||||||
|
|
||||||
def process_email():
|
def process_email():
|
||||||
@ -89,10 +89,10 @@ def ticket_from_message(message, queue):
|
|||||||
|
|
||||||
sender_email = parseaddr(message.get('from', 'Unknown Sender'))[1]
|
sender_email = parseaddr(message.get('from', 'Unknown Sender'))[1]
|
||||||
|
|
||||||
regex = re.compile("^\[\d+\]")
|
regex = re.compile("^\[[A-Za-z0-9]+-\d+\]")
|
||||||
if regex.match(subject):
|
if regex.match(subject):
|
||||||
# This is a reply or forward.
|
# This is a reply or forward.
|
||||||
ticket = re.match(r"^\[(?P<id>\d+)\]", subject).group('id')
|
ticket = re.match(r"^\[(?P<queue>[A-Za-z0-9]+)-(?P<id>\d+)\]", subject).group('id')
|
||||||
else:
|
else:
|
||||||
ticket = None
|
ticket = None
|
||||||
counter = 0
|
counter = 0
|
||||||
@ -147,10 +147,36 @@ def ticket_from_message(message, queue):
|
|||||||
'queue': queue,
|
'queue': queue,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
update = ""
|
||||||
|
|
||||||
if sender_email:
|
if sender_email:
|
||||||
send_multipart_mail('helpdesk/emails/submitter_newticket', context, '%s %s' % (t.ticket, t.title), sender_email, queue.from_address)
|
send_multipart_mail('helpdesk/emails/submitter_newticket', context, '%s %s' % (t.ticket, t.title), sender_email, queue.from_address)
|
||||||
|
|
||||||
print " [%s-%s] %s" % (t.queue.slug, t.id, t.title)
|
if queue.new_ticket_cc:
|
||||||
|
send_multipart_mail('helpdesk/emails/cc_newticket', context, '%s %s (Opened)' % (t.ticket, t.title), queue.updated_ticket_cc, queue.from_address)
|
||||||
|
|
||||||
|
if queue.updated_ticket_cc and queue.updated_ticket_cc != queue.new_ticket_cc:
|
||||||
|
send_multipart_mail('helpdesk/emails/cc_newticket', context, '%s %s (Opened)' % (t.ticket, t.title), queue.updated_ticket_cc, queue.from_address)
|
||||||
|
|
||||||
|
else:
|
||||||
|
f = FollowUp(
|
||||||
|
ticket = t,
|
||||||
|
title = 'E-Mail Received from %s' % sender_email,
|
||||||
|
date = datetime.now(),
|
||||||
|
public = True,
|
||||||
|
comment = body,
|
||||||
|
)
|
||||||
|
f.save()
|
||||||
|
update = " (Updated)"
|
||||||
|
|
||||||
|
if t.assigned_to:
|
||||||
|
send_multipart_mail('helpdesk/emails/owner_updated', context, '%s %s (Updated)' % (t.ticket, t.title), t.assigned_to.email, queue.from_address)
|
||||||
|
|
||||||
|
if queue.updated_ticket_cc:
|
||||||
|
send_multipart_mail('helpdesk/emails/cc_updatedt', context, '%s %s (Updated)' % (t.ticket, t.title), queue.updated_ticket_cc, queue.from_address)
|
||||||
|
|
||||||
|
|
||||||
|
print " [%s-%s] %s%s" % (t.queue.slug, t.id, t.title, update)
|
||||||
|
|
||||||
#for file in files:
|
#for file in files:
|
||||||
#data = file['content']
|
#data = file['content']
|
||||||
|
Loading…
Reference in New Issue
Block a user