Add mailgun + emailing errors

This commit is contained in:
Gabriel Augendre 2018-03-31 17:19:56 +02:00
parent cc657ad4e4
commit e143dc23c5
No known key found for this signature in database
GPG key ID: F360212F958357D4
5 changed files with 27 additions and 2 deletions

View file

@ -13,3 +13,10 @@ COPY . ./
RUN chmod +x bash/run-prod.sh RUN chmod +x bash/run-prod.sh
CMD 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 ''

View file

@ -15,6 +15,7 @@ dj-database-url = "*"
"psycopg2-binary" = "*" "psycopg2-binary" = "*"
django-dotenv = "*" django-dotenv = "*"
plotly = "*" plotly = "*"
django-mailgun = "*"
[dev-packages] [dev-packages]

9
Pipfile.lock generated
View file

@ -1,7 +1,7 @@
{ {
"_meta": { "_meta": {
"hash": { "hash": {
"sha256": "9ce7378867a2feadabf9c87acdbede4038951b69db00e0e920576af5070c37b4" "sha256": "6f892c3bf84ae9490e88b9a4b56b258544c23872374a800b2abf9b7bf35c584d"
}, },
"pipfile-spec": 6, "pipfile-spec": 6,
"requires": {}, "requires": {},
@ -66,6 +66,13 @@
"index": "pypi", "index": "pypi",
"version": "==1.4.2" "version": "==1.4.2"
}, },
"django-mailgun": {
"hashes": [
"sha256:d795076d18c0aa66fbac37f8b428f036417a3ec7ecc2d6499c021d318d60bfff"
],
"index": "pypi",
"version": "==0.9.1"
},
"djangorestframework": { "djangorestframework": {
"hashes": [ "hashes": [
"sha256:1f6baf40ed456ed2af6bd1a4ff8bbc3503cebea16509993aea2b7085bc097766", "sha256:1f6baf40ed456ed2af6bd1a4ff8bbc3503cebea16509993aea2b7085bc097766",

View file

@ -44,6 +44,7 @@ class RoomDetailView(LoginRequiredMixin, QuickActionsMixin, SessionResetMixin, g
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)
context['sessions'] = self.object.sessions.all().order_by('-start') context['sessions'] = self.object.sessions.all().order_by('-start')
print(context['toto'])
return context return context

View file

@ -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/ # See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret! # 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! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = os.getenv('DJANGO_ENV', 'prod') == 'dev' DEBUG = os.getenv('DJANGO_ENV', 'prod') == 'dev'
ALLOWED_HOSTS = ['localhost', 'workout.augendre.info', 'web', 'workout', 'workout-web'] ALLOWED_HOSTS = ['localhost', 'workout.augendre.info', 'web', 'workout', 'workout-web']
ADMINS = [('Gabriel', os.getenv('ADMIN_EMAIL')), ]
SERVER_EMAIL = os.getenv('SERVER_EMAIL')
# Application definition # Application definition
INSTALLED_APPS = [ INSTALLED_APPS = [
@ -50,6 +53,7 @@ MIDDLEWARE = [
'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware', 'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.http.ConditionalGetMiddleware',
] ]
ROOT_URLCONF = 'workout.urls' ROOT_URLCONF = 'workout.urls'
@ -117,3 +121,8 @@ STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
LOGIN_REDIRECT_URL = 'rooms-list' 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', '')