From 28f4a5677b8f485224ef7df675228ccf657dcb75 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Thu, 24 Nov 2016 13:28:55 +0200 Subject: Add SSL/TLS/None choices to SMTP settings --- servo/models/device.py | 4 ++-- servo/models/note.py | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) (limited to 'servo/models') diff --git a/servo/models/device.py b/servo/models/device.py index 95635df..df28671 100644 --- a/servo/models/device.py +++ b/servo/models/device.py @@ -188,7 +188,7 @@ class Device(models.Model): help_text=_('Device is considered vintage in GSX') ) fmip_active = models.BooleanField(default=False, editable=False) - + def is_apple_device(self): """ Checks if this is a valid Apple device SN @@ -395,7 +395,7 @@ class Device(models.Model): return self.photo.url except ValueError: return self.get_image_url() - + def get_fmip_status(self): """ Returns the translated FMiP status diff --git a/servo/models/note.py b/servo/models/note.py index a598a95..8b2943f 100644 --- a/servo/models/note.py +++ b/servo/models/note.py @@ -382,7 +382,16 @@ class Note(MPTTModel): if len(smtp_host) > 1: settings.EMAIL_PORT = int(smtp_host[1]) - settings.EMAIL_USE_TLS = config.get('smtp_ssl') + if config.get('SMTP_ENCRYPTION') == 'TLS': + settings.EMAIL_USE_TLS = True + + if config.get('SMTP_ENCRYPTION') == 'SSL': + settings.EMAIL_USE_SSL = True + + if config.get('SMTP_ENCRYPTION') == 'OFF': + settings.EMAIL_USE_SSL = False + settings.EMAIL_USE_TLS = False + settings.EMAIL_HOST_USER = str(config.get('smtp_user')) settings.EMAIL_HOST_PASSWORD = str(config.get('smtp_password')) @@ -630,9 +639,8 @@ class Article(models.Model): ('LOW', _('Low')), ) priority = models.CharField(max_length=128, - choices=PRIORITY_CHOICES, - default=PRIORITY_CHOICES[0][0] - ) + choices=PRIORITY_CHOICES, + default=PRIORITY_CHOICES[0][0]) url = models.URLField(default='') product_model = ArrayField(models.CharField(max_length=128), null=True, -- cgit v1.2.3