Commit 32000fa55fd2f198da0839e70bc676804fca15ba

Authored by fbormann
2 parents 252e7ebb bc06250e

Merge branch 'dev' of https://github.com/amadeusproject/amadeuslms into dev

amadeus/settings.py
... ... @@ -205,7 +205,8 @@ EMAIL_HOST = 'smtp.gmail.com'
205 205 EMAIL_PORT = 587
206 206 EMAIL_HOST_USER = 'amadeusteste@gmail.com'
207 207 EMAIL_HOST_PASSWORD = 'amadeusteste'
208   -EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
  208 +# SMTP CONFIG
  209 +# EMAIL_BACKEND = 'core.smtp.AmadeusEmailBackend'
209 210  
210 211 #s3direct
211 212  
... ...
app/migrations/0001_initial.py 0 → 100644
... ... @@ -0,0 +1,33 @@
  1 +# -*- coding: utf-8 -*-
  2 +# Generated by Django 1.10 on 2016-11-03 22:03
  3 +from __future__ import unicode_literals
  4 +
  5 +from django.db import migrations, models
  6 +
  7 +
  8 +class Migration(migrations.Migration):
  9 +
  10 + initial = True
  11 +
  12 + dependencies = [
  13 + ]
  14 +
  15 + operations = [
  16 + migrations.CreateModel(
  17 + name='EmailBackend',
  18 + fields=[
  19 + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
  20 + ('description', models.CharField(max_length=100, verbose_name='Description')),
  21 + ('host', models.URLField(verbose_name='E-mail Host')),
  22 + ('port', models.CharField(blank=True, max_length=4, verbose_name='Email Port')),
  23 + ('username', models.CharField(max_length=30, verbose_name='Email host username')),
  24 + ('password', models.CharField(blank=True, max_length=30, verbose_name='Email host password')),
  25 + ('safe_conection', models.IntegerField(choices=[(0, 'No'), (1, 'TLS, if available'), (2, 'TLS'), (3, 'SSL')], default=0, verbose_name='Use safe conection')),
  26 + ('default_from_email', models.EmailField(blank=True, max_length=254, verbose_name='Default from email')),
  27 + ],
  28 + options={
  29 + 'verbose_name_plural': 'Amadeus SMTP settings',
  30 + 'verbose_name': 'Amadeus SMTP setting',
  31 + },
  32 + ),
  33 + ]
... ...
app/migrations/__init__.py 0 → 100644
core/smtp.py 0 → 100644
... ... @@ -0,0 +1,38 @@
  1 +from django.core.mail.backends import EmailBackend
  2 +from app.models import EmailBackend as SmtpModal
  3 +
  4 +class AmadeusEmailBackend(EmailBackend):
  5 + """docstring for AmadeusEmailBackend"""
  6 + def __init__(self, host=None, port=None, username=None, password=None,
  7 + use_tls=None, fail_silently=False, use_ssl=None, timeout=None,
  8 + ssl_keyfile=None, ssl_certfile=None,
  9 + **kwargs):
  10 + super(AmadeusEmailBackend, self).__init__(fail_silently=fail_silently)
  11 + try:
  12 + config = SmtpModal.objects.latest('id')
  13 + self.host = config.host or settings.EMAIL_HOST
  14 + self.port = config.port or settings.EMAIL_PORT
  15 + self.username = config.username or settings.EMAIL_HOST_USER if username is None else username
  16 + self.password = config.password or settings.EMAIL_HOST_PASSWORD if password is None else password
  17 +
  18 + if config.safe_conection == 2:
  19 + self.use_tls = True
  20 + self.use_ssl = False
  21 + elif config.safe_conection == 3:
  22 + self.use_tls = False
  23 + self.use_ssl = True
  24 + else:
  25 + self.use_tls = False
  26 + self.use_ssl = False
  27 +
  28 + self.timeout = settings.EMAIL_TIMEOUT if timeout is None else timeout
  29 + self.ssl_keyfile = settings.EMAIL_SSL_KEYFILE if ssl_keyfile is None else ssl_keyfile
  30 + self.ssl_certfile = settings.EMAIL_SSL_CERTFILE if ssl_certfile is None else ssl_certfile
  31 + if self.use_ssl and self.use_tls:
  32 + raise ValueError(
  33 + "EMAIL_USE_TLS/EMAIL_USE_SSL are mutually exclusive, so only set "
  34 + "one of those settings to True.")
  35 + self.connection = None
  36 + self._lock = threading.RLock()
  37 + except:
  38 + pass
0 39 \ No newline at end of file
... ...
users/templates/list_users.html
... ... @@ -90,8 +90,8 @@
90 90 {% trans 'Are you sure you want to delete the user' %} <b>{{acc.name}}</b>?
91 91 </div>
92 92 <div class="modal-footer">
93   - <button type="button" class="btn btn-default" data-dismiss="modal">{% trans 'Cancel' %}</button>
94   - <button type="button" class="btn btn-primary"> <a href="{% url 'users:delete' acc.username %}">{% trans 'Delete' %}</a></button>
  93 + <a href="#" class="btn btn-raised btn-danger" data-dismiss="modal">{% trans 'Cancel' %}</a>
  94 + <a href="{% url 'users:delete' acc.username %}" class="btn btn-raised btn-success" style="margin-top: 0">{% trans 'Delete' %}</a>
95 95 </div>
96 96 </div>
97 97 </div>
... ...