Commit 8847726a58c46b2fe8b2c24f4c71b8dfc7019548
Exists in
master
and in
5 other branches
conflit
Showing
9 changed files
with
110 additions
and
8 deletions
Show diff stats
amadeus/settings.py
@@ -205,7 +205,8 @@ EMAIL_HOST = 'smtp.gmail.com' | @@ -205,7 +205,8 @@ EMAIL_HOST = 'smtp.gmail.com' | ||
205 | EMAIL_PORT = 587 | 205 | EMAIL_PORT = 587 |
206 | EMAIL_HOST_USER = 'amadeusteste@gmail.com' | 206 | EMAIL_HOST_USER = 'amadeusteste@gmail.com' |
207 | EMAIL_HOST_PASSWORD = 'amadeusteste' | 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 | #s3direct | 211 | #s3direct |
211 | 212 |
@@ -0,0 +1,33 @@ | @@ -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 | + ] |
@@ -0,0 +1,38 @@ | @@ -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 | \ No newline at end of file | 39 | \ No newline at end of file |
core/urls.py
@@ -13,6 +13,9 @@ urlpatterns = [ | @@ -13,6 +13,9 @@ urlpatterns = [ | ||
13 | url(r'^getNotifications/$', views.getNotifications, name='getNotifications'), | 13 | url(r'^getNotifications/$', views.getNotifications, name='getNotifications'), |
14 | url(r'^guest/$', views.GuestView.as_view(), name='guest'), | 14 | url(r'^guest/$', views.GuestView.as_view(), name='guest'), |
15 | 15 | ||
16 | + #API REST | ||
17 | + url(r'^logs/$', views.get_log), | ||
18 | + | ||
16 | #Reset Password | 19 | #Reset Password |
17 | 20 | ||
18 | url(r'^reset/$', password_reset, {'template_name':'registration/passwor_reset_form.html', | 21 | url(r'^reset/$', password_reset, {'template_name':'registration/passwor_reset_form.html', |
@@ -25,4 +28,5 @@ urlpatterns = [ | @@ -25,4 +28,5 @@ urlpatterns = [ | ||
25 | 'post_reset_redirect' : '/done/'}, | 28 | 'post_reset_redirect' : '/done/'}, |
26 | name='password_reset_confirm'), | 29 | name='password_reset_confirm'), |
27 | url(r'^done/$', password_reset_complete,{'template_name':'registration/passwor_reset_complete.html'}), | 30 | url(r'^done/$', password_reset_complete,{'template_name':'registration/passwor_reset_complete.html'}), |
31 | + | ||
28 | ] | 32 | ] |
core/views.py
@@ -11,8 +11,13 @@ from django.http import HttpResponse, JsonResponse | @@ -11,8 +11,13 @@ from django.http import HttpResponse, JsonResponse | ||
11 | from django.core.mail import send_mail,BadHeaderError | 11 | from django.core.mail import send_mail,BadHeaderError |
12 | from django.conf import settings | 12 | from django.conf import settings |
13 | from core.mixins import NotificationMixin | 13 | from core.mixins import NotificationMixin |
14 | -from .models import Notification | 14 | +from .models import Notification, Log |
15 | from rolepermissions.shortcuts import assign_role | 15 | from rolepermissions.shortcuts import assign_role |
16 | +from django.contrib.auth.decorators import login_required | ||
17 | +#API REST IMPORTS | ||
18 | +from .serializers import LogSerializer | ||
19 | +from rest_framework.renderers import JSONRenderer | ||
20 | +from rest_framework.parsers import JSONParser | ||
16 | 21 | ||
17 | from .forms import RegisterUserForm | 22 | from .forms import RegisterUserForm |
18 | from .decorators import log_decorator, notification_decorator | 23 | from .decorators import log_decorator, notification_decorator |
@@ -128,4 +133,21 @@ class GuestView (ListView): | @@ -128,4 +133,21 @@ class GuestView (ListView): | ||
128 | def get_context_data (self, **kwargs): | 133 | def get_context_data (self, **kwargs): |
129 | context = super(GuestView, self).get_context_data(**kwargs) | 134 | context = super(GuestView, self).get_context_data(**kwargs) |
130 | context['categorys_courses'] = CourseCategory.objects.all() | 135 | context['categorys_courses'] = CourseCategory.objects.all() |
131 | - return context | ||
132 | \ No newline at end of file | 136 | \ No newline at end of file |
137 | + return context | ||
138 | + | ||
139 | +class JSONResponse(HttpResponse): | ||
140 | + """ | ||
141 | + An HttpResponse that renders its content into JSON. | ||
142 | + """ | ||
143 | + def __init__(self, data, **kwargs): | ||
144 | + content = JSONRenderer().render(data) | ||
145 | + kwargs['content_type'] = 'application/json' | ||
146 | + super(JSONResponse, self).__init__(content, **kwargs) | ||
147 | + | ||
148 | +#REST API VIEWS | ||
149 | +@login_required | ||
150 | +def get_log(request): | ||
151 | + if request.method == 'GET': | ||
152 | + logs = Log.objects.all() | ||
153 | + serializer = LogSerializer(logs, many=True) | ||
154 | + return JSONResponse(serializer.data) |
requirements.txt
@@ -16,7 +16,6 @@ django-widget-tweaks==1.4.1 | @@ -16,7 +16,6 @@ django-widget-tweaks==1.4.1 | ||
16 | django-wysiwyg==0.8.0 | 16 | django-wysiwyg==0.8.0 |
17 | djangorestframework==3.4.6 | 17 | djangorestframework==3.4.6 |
18 | gunicorn==19.6.0 | 18 | gunicorn==19.6.0 |
19 | -itsdangerous==0.24 | ||
20 | Jinja2==2.8 | 19 | Jinja2==2.8 |
21 | lxml==3.6.4 | 20 | lxml==3.6.4 |
22 | MarkupSafe==0.23 | 21 | MarkupSafe==0.23 |
@@ -24,9 +23,7 @@ Pillow==3.3.1 | @@ -24,9 +23,7 @@ Pillow==3.3.1 | ||
24 | psycopg2==2.6.2 | 23 | psycopg2==2.6.2 |
25 | pycpfcnpj==1.0.2 | 24 | pycpfcnpj==1.0.2 |
26 | requests==2.11.1 | 25 | requests==2.11.1 |
27 | -six==1.10.0 | ||
28 | slugify==0.0.1 | 26 | slugify==0.0.1 |
29 | validators==0.11.0 | 27 | validators==0.11.0 |
30 | -virtualenv==15.0.3 | ||
31 | Werkzeug==0.11.11 | 28 | Werkzeug==0.11.11 |
32 | whitenoise==3.2.2 | 29 | whitenoise==3.2.2 |
users/templates/list_users.html
@@ -90,8 +90,8 @@ | @@ -90,8 +90,8 @@ | ||
90 | {% trans 'Are you sure you want to delete the user' %} <b>{{acc.name}}</b>? | 90 | {% trans 'Are you sure you want to delete the user' %} <b>{{acc.name}}</b>? |
91 | </div> | 91 | </div> |
92 | <div class="modal-footer"> | 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 | </div> | 95 | </div> |
96 | </div> | 96 | </div> |
97 | </div> | 97 | </div> |