* 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:
Ross Poulton 2008-08-20 01:57:41 +00:00
parent 5040d3d243
commit b5cdea2fab
4 changed files with 42 additions and 16 deletions

View File

@ -57,7 +57,14 @@ def process_email():
def process_queue(q):
print "Processing: %s" % q
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.user(q.email_box_user)
server.pass_(q.email_box_pass)
@ -75,9 +82,13 @@ def process_queue(q):
server.quit()
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.select(q.email_box_imap_folder)
status, data = server.search(None, 'ALL')
@ -150,8 +161,7 @@ def ticket_from_message(message, queue):
high_priority_types = ('high', 'important', '1', 'urgent')
if smtp_priority in high_priority_types
or smtp_importance in high_priority_types:
if smtp_priority in high_priority_types or smtp_importance in high_priority_types:
priority = 2
if ticket == None:
@ -192,8 +202,7 @@ def ticket_from_message(message, queue):
fail_silently=True,
)
if queue.updated_ticket_cc
and queue.updated_ticket_cc != queue.new_ticket_cc:
if queue.updated_ticket_cc and queue.updated_ticket_cc != queue.new_ticket_cc:
send_templated_mail(
'newticket_cc',
context,

View File

@ -114,6 +114,14 @@ class Queue(models.Model):
'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(
_('E-Mail Username'),
max_length=200,
@ -179,9 +187,13 @@ class Queue(models.Model):
self.email_box_imap_folder = 'INBOX'
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
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
super(Queue, self).save()

View File

@ -55,7 +55,8 @@ def api(request, method):
# TODO: Move away from having the username & password in every request.
request.user = authenticate(
username=request.POST.get('user', False),
password=request.POST.get('password'))
password=request.POST.get('password'),
)
if request.user is None:
return api_return(STATUS_ERROR_PERMISSIONS)

View File

@ -32,13 +32,17 @@ def dashboard(request):
with options for them to 'Take' ownership of said tickets.
"""
tickets = Ticket.objects
.filter(assigned_to=request.user)
.exclude(status=Ticket.CLOSED_STATUS)
tickets = Ticket.objects.filter(
assigned_to=request.user,
).exclude(
status=Ticket.CLOSED_STATUS,
)
unassigned_tickets = Ticket.objects
.filter(assigned_to__isnull=True)
.exclude(status=Ticket.CLOSED_STATUS)
unassigned_tickets = Ticket.objects.filter(
assigned_to__isnull=True,
).exclude(
status=Ticket.CLOSED_STATUS,
)
# The following query builds a grid of queues & ticket statuses,
# to be displayed to the user. EG: