mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2025-05-30 22:45:48 +02:00
* Fix a few indenting issues
* Fix #11: BUG Port number in POP3 isn't used * Fix #11: ENHANCEMENT Use SSL in POP3 and IMAP (requires database change)
This commit is contained in:
parent
5040d3d243
commit
b5cdea2fab
@ -57,7 +57,14 @@ def process_email():
|
|||||||
def process_queue(q):
|
def process_queue(q):
|
||||||
print "Processing: %s" % q
|
print "Processing: %s" % q
|
||||||
if q.email_box_type == 'pop3':
|
if q.email_box_type == 'pop3':
|
||||||
server = poplib.POP3(q.email_box_host)
|
|
||||||
|
if q.email_box_ssl:
|
||||||
|
if not q.email_box_port: q.email_box_port = 995
|
||||||
|
server = poplib.POP3_SSL(q.email_box_host, q.email_box_port)
|
||||||
|
else:
|
||||||
|
if not q.email_box_port: q.email_box_port = 110
|
||||||
|
server = poplib.POP3(q.email_box_host, q.email_box_port)
|
||||||
|
|
||||||
server.getwelcome()
|
server.getwelcome()
|
||||||
server.user(q.email_box_user)
|
server.user(q.email_box_user)
|
||||||
server.pass_(q.email_box_pass)
|
server.pass_(q.email_box_pass)
|
||||||
@ -75,9 +82,13 @@ def process_queue(q):
|
|||||||
server.quit()
|
server.quit()
|
||||||
|
|
||||||
elif q.email_box_type == 'imap':
|
elif q.email_box_type == 'imap':
|
||||||
if not q.email_box_port: q.email_box_port = 143
|
if q.email_box_ssl:
|
||||||
|
if not q.email_box_port: q.email_box_port = 993
|
||||||
|
server = imaplib.IMAP4_SSL(q.email_box_host, q.email_box_port)
|
||||||
|
else:
|
||||||
|
if not q.email_box_port: q.email_box_port = 143
|
||||||
|
server = imaplib.IMAP4(q.email_box_host, q.email_box_port)
|
||||||
|
|
||||||
server = imaplib.IMAP4(q.email_box_host, q.email_box_port)
|
|
||||||
server.login(q.email_box_user, q.email_box_pass)
|
server.login(q.email_box_user, q.email_box_pass)
|
||||||
server.select(q.email_box_imap_folder)
|
server.select(q.email_box_imap_folder)
|
||||||
status, data = server.search(None, 'ALL')
|
status, data = server.search(None, 'ALL')
|
||||||
@ -150,8 +161,7 @@ def ticket_from_message(message, queue):
|
|||||||
|
|
||||||
high_priority_types = ('high', 'important', '1', 'urgent')
|
high_priority_types = ('high', 'important', '1', 'urgent')
|
||||||
|
|
||||||
if smtp_priority in high_priority_types
|
if smtp_priority in high_priority_types or smtp_importance in high_priority_types:
|
||||||
or smtp_importance in high_priority_types:
|
|
||||||
priority = 2
|
priority = 2
|
||||||
|
|
||||||
if ticket == None:
|
if ticket == None:
|
||||||
@ -192,8 +202,7 @@ def ticket_from_message(message, queue):
|
|||||||
fail_silently=True,
|
fail_silently=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
if queue.updated_ticket_cc
|
if queue.updated_ticket_cc and queue.updated_ticket_cc != queue.new_ticket_cc:
|
||||||
and queue.updated_ticket_cc != queue.new_ticket_cc:
|
|
||||||
send_templated_mail(
|
send_templated_mail(
|
||||||
'newticket_cc',
|
'newticket_cc',
|
||||||
context,
|
context,
|
||||||
|
16
models.py
16
models.py
@ -114,6 +114,14 @@ class Queue(models.Model):
|
|||||||
'servers. Leave it blank to use the defaults.'),
|
'servers. Leave it blank to use the defaults.'),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
email_box_ssl = models.BooleanField(
|
||||||
|
_('Use SSL for E-Mail?'),
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
help_text=_('Whether to use SSL for IMAP or POP3 - the default ports '
|
||||||
|
'when using SSL are 993 for IMAP and 995 for POP3.'),
|
||||||
|
)
|
||||||
|
|
||||||
email_box_user = models.CharField(
|
email_box_user = models.CharField(
|
||||||
_('E-Mail Username'),
|
_('E-Mail Username'),
|
||||||
max_length=200,
|
max_length=200,
|
||||||
@ -179,9 +187,13 @@ class Queue(models.Model):
|
|||||||
self.email_box_imap_folder = 'INBOX'
|
self.email_box_imap_folder = 'INBOX'
|
||||||
|
|
||||||
if not self.email_box_port:
|
if not self.email_box_port:
|
||||||
if self.email_box_type == 'imap':
|
if self.email_box_type == 'imap' and self.email_box_ssl:
|
||||||
|
self.email_box_port = 993
|
||||||
|
elif self.email_box_type == 'imap' and not self.email_box_ssl:
|
||||||
self.email_box_port = 143
|
self.email_box_port = 143
|
||||||
else:
|
elif self.email_box_type == 'pop3' and self.email_box_ssl:
|
||||||
|
self.email_box_port = 995
|
||||||
|
elif self.email_box_type == 'pop3' and not self.email_box_ssl:
|
||||||
self.email_box_port = 110
|
self.email_box_port = 110
|
||||||
super(Queue, self).save()
|
super(Queue, self).save()
|
||||||
|
|
||||||
|
@ -55,7 +55,8 @@ def api(request, method):
|
|||||||
# TODO: Move away from having the username & password in every request.
|
# TODO: Move away from having the username & password in every request.
|
||||||
request.user = authenticate(
|
request.user = authenticate(
|
||||||
username=request.POST.get('user', False),
|
username=request.POST.get('user', False),
|
||||||
password=request.POST.get('password'))
|
password=request.POST.get('password'),
|
||||||
|
)
|
||||||
|
|
||||||
if request.user is None:
|
if request.user is None:
|
||||||
return api_return(STATUS_ERROR_PERMISSIONS)
|
return api_return(STATUS_ERROR_PERMISSIONS)
|
||||||
|
@ -32,13 +32,17 @@ def dashboard(request):
|
|||||||
with options for them to 'Take' ownership of said tickets.
|
with options for them to 'Take' ownership of said tickets.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
tickets = Ticket.objects
|
tickets = Ticket.objects.filter(
|
||||||
.filter(assigned_to=request.user)
|
assigned_to=request.user,
|
||||||
.exclude(status=Ticket.CLOSED_STATUS)
|
).exclude(
|
||||||
|
status=Ticket.CLOSED_STATUS,
|
||||||
|
)
|
||||||
|
|
||||||
unassigned_tickets = Ticket.objects
|
unassigned_tickets = Ticket.objects.filter(
|
||||||
.filter(assigned_to__isnull=True)
|
assigned_to__isnull=True,
|
||||||
.exclude(status=Ticket.CLOSED_STATUS)
|
).exclude(
|
||||||
|
status=Ticket.CLOSED_STATUS,
|
||||||
|
)
|
||||||
|
|
||||||
# The following query builds a grid of queues & ticket statuses,
|
# The following query builds a grid of queues & ticket statuses,
|
||||||
# to be displayed to the user. EG:
|
# to be displayed to the user. EG:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user