mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2025-08-09 00:04:50 +02:00
* Enlarged Chart sizes to allow more data to be displayed
* Added superuser 'System settings' page with links to admin * Added ability to ignore e-mail addresses (using wildcards) from the e-mail parser * Added link to ignore email address from ticket details page (for superusers only) * Cleaned up report output by styling text & labels in the same way as tables in other views * Cleaned up dashboard lists to show text in place of tickets if no tickets are found * Added ability to sort in reverse order NOTE: REQUIRES A 'syncdb' TO CREATE THE EMAIL-IGNORE TABLES. No other DB changes were made.
This commit is contained in:
@ -20,10 +20,11 @@ from email.Utils import parseaddr
|
||||
|
||||
from django.core.files.base import ContentFile
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.db.models import Q
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from helpdesk.lib import send_templated_mail
|
||||
from helpdesk.models import Queue, Ticket, FollowUp, Attachment
|
||||
from helpdesk.models import Queue, Ticket, FollowUp, Attachment, IgnoreEmail
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
@ -76,9 +77,11 @@ def process_queue(q):
|
||||
msgSize = msg.split(" ")[1]
|
||||
|
||||
full_message = "\n".join(server.retr(msgNum)[1])
|
||||
ticket_from_message(message=full_message, queue=q)
|
||||
ticket = ticket_from_message(message=full_message, queue=q)
|
||||
|
||||
if ticket:
|
||||
server.dele(msgNum)
|
||||
|
||||
server.dele(msgNum)
|
||||
server.quit()
|
||||
|
||||
elif q.email_box_type == 'imap':
|
||||
@ -94,8 +97,10 @@ def process_queue(q):
|
||||
status, data = server.search(None, 'ALL')
|
||||
for num in data[0].split():
|
||||
status, data = server.fetch(num, '(RFC822)')
|
||||
ticket_from_message(message=data[0][1], queue=q)
|
||||
server.store(num, '+FLAGS', '\\Deleted')
|
||||
ticket = ticket_from_message(message=data[0][1], queue=q)
|
||||
if ticket:
|
||||
server.store(num, '+FLAGS', '\\Deleted')
|
||||
|
||||
server.expunge()
|
||||
server.close()
|
||||
server.logout()
|
||||
@ -111,8 +116,10 @@ def ticket_from_message(message, queue):
|
||||
sender = message.get('from', _('Unknown Sender'))
|
||||
|
||||
sender_email = parseaddr(sender)[1]
|
||||
if sender_email.startswith('postmaster'):
|
||||
sender_email = ''
|
||||
|
||||
for ignore in IgnoreEmail.objects.filter(Q(queues=queue) | Q(queues__isnull=True)):
|
||||
if ignore.test(sender_email):
|
||||
return False
|
||||
|
||||
regex = re.compile("^\[[A-Za-z0-9]+-\d+\]")
|
||||
if regex.match(subject):
|
||||
@ -256,6 +263,8 @@ def ticket_from_message(message, queue):
|
||||
a.save()
|
||||
print " - %s" % file['filename']
|
||||
|
||||
return ticket
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
process_email()
|
||||
|
Reference in New Issue
Block a user