From e143dc23c5791ac5f6c0bbf10989bebe7ba6f887 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Sat, 31 Mar 2018 17:19:56 +0200 Subject: [PATCH] Add mailgun + emailing errors --- Dockerfile | 7 +++++++ Pipfile | 1 + Pipfile.lock | 9 ++++++++- gym/views.py | 1 + workout/settings.py | 11 ++++++++++- 5 files changed, 27 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 58726ba..8825c4c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,3 +13,10 @@ COPY . ./ RUN chmod +x bash/run-prod.sh CMD bash/run-prod.sh + +ENV SECRET_KEY '' +ENV MAILGUN_ACCESS_KEY '' +ENV MAILGUN_SERVER_NAME '' +ENV DJANGO_ENV '' +ENV ADMIN_EMAIL '' +ENV SERVER_EMAIL '' diff --git a/Pipfile b/Pipfile index 167b1c6..ea5a8e1 100644 --- a/Pipfile +++ b/Pipfile @@ -15,6 +15,7 @@ dj-database-url = "*" "psycopg2-binary" = "*" django-dotenv = "*" plotly = "*" +django-mailgun = "*" [dev-packages] diff --git a/Pipfile.lock b/Pipfile.lock index bf05f31..252b68b 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "9ce7378867a2feadabf9c87acdbede4038951b69db00e0e920576af5070c37b4" + "sha256": "6f892c3bf84ae9490e88b9a4b56b258544c23872374a800b2abf9b7bf35c584d" }, "pipfile-spec": 6, "requires": {}, @@ -66,6 +66,13 @@ "index": "pypi", "version": "==1.4.2" }, + "django-mailgun": { + "hashes": [ + "sha256:d795076d18c0aa66fbac37f8b428f036417a3ec7ecc2d6499c021d318d60bfff" + ], + "index": "pypi", + "version": "==0.9.1" + }, "djangorestframework": { "hashes": [ "sha256:1f6baf40ed456ed2af6bd1a4ff8bbc3503cebea16509993aea2b7085bc097766", diff --git a/gym/views.py b/gym/views.py index ed94fe9..b0e8d3b 100644 --- a/gym/views.py +++ b/gym/views.py @@ -44,6 +44,7 @@ class RoomDetailView(LoginRequiredMixin, QuickActionsMixin, SessionResetMixin, g def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['sessions'] = self.object.sessions.all().order_by('-start') + print(context['toto']) return context diff --git a/workout/settings.py b/workout/settings.py index 0b17734..a5662f1 100644 --- a/workout/settings.py +++ b/workout/settings.py @@ -21,13 +21,16 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'x*8q7sd14&a%cu95$h@jl&&#bb&j(j*-6h5!3atz*v%!zo3hd4' +SECRET_KEY = os.getenv('SECRET_KEY', 'x*8q7sd14&a%cu95$h@jl&&#bb&j(j*-6h5!3atz*v%!zo3hd4') # SECURITY WARNING: don't run with debug turned on in production! DEBUG = os.getenv('DJANGO_ENV', 'prod') == 'dev' ALLOWED_HOSTS = ['localhost', 'workout.augendre.info', 'web', 'workout', 'workout-web'] +ADMINS = [('Gabriel', os.getenv('ADMIN_EMAIL')), ] +SERVER_EMAIL = os.getenv('SERVER_EMAIL') + # Application definition INSTALLED_APPS = [ @@ -50,6 +53,7 @@ MIDDLEWARE = [ 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', + 'django.middleware.http.ConditionalGetMiddleware', ] ROOT_URLCONF = 'workout.urls' @@ -117,3 +121,8 @@ STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') LOGIN_REDIRECT_URL = 'rooms-list' + +EMAIL_BACKEND = 'django_mailgun.MailgunBackend' +MAILGUN_ACCESS_KEY = os.getenv('MAILGUN_ACCESS_KEY', '') +MAILGUN_SERVER_NAME = os.getenv('MAILGUN_SERVER_NAME', '') +