From 768b8cf2c833474b44567bb3e3112af873ce1f91 Mon Sep 17 00:00:00 2001 From: Burhan Khalid Date: Mon, 6 Jul 2015 21:23:12 +0300 Subject: [PATCH 1/5] adding support for mailgun --- README.rst | 4 ++-- {{cookiecutter.repo_name}}/README.rst | 24 ++++++++++--------- .../config/settings/production.py | 10 ++++---- .../requirements/production.txt | 4 ++++ 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/README.rst b/README.rst index 68a6ab62..fd6c3eb0 100644 --- a/README.rst +++ b/README.rst @@ -24,7 +24,7 @@ Features * Registration via django-allauth_ * Procfile_ for deploying to Heroku * Grunt build for compass and livereload -* Basic e-mail configurations for send emails via SendGrid_ +* Basic e-mail configurations for send emails via Mailgun_ * Media storage using Amazon S3 * Serve static files from Amazon S3 or Whitenoise_ (optional) @@ -35,7 +35,7 @@ Features .. _django-allauth: https://github.com/pennersr/django-allauth .. _django-avatar: https://github.com/jezdez/django-avatar/ .. _Procfile: https://devcenter.heroku.com/articles/procfile -.. _SendGrid: https://sendgrid.com/ +.. _Mailgun: https://mailgun.com/ .. _Whitenoise: https://whitenoise.readthedocs.org/ diff --git a/{{cookiecutter.repo_name}}/README.rst b/{{cookiecutter.repo_name}}/README.rst index f746aa96..9f89972c 100644 --- a/{{cookiecutter.repo_name}}/README.rst +++ b/{{cookiecutter.repo_name}}/README.rst @@ -30,16 +30,19 @@ DJANGO_SECURE_FRAME_DENY SECURE_FRAME_DENY n/a DJANGO_SECURE_HSTS_INCLUDE_SUBDOMAINS HSTS_INCLUDE_SUBDOMAINS n/a True DJANGO_SESSION_COOKIE_HTTPONLY SESSION_COOKIE_HTTPONLY n/a True DJANGO_SESSION_COOKIE_SECURE SESSION_COOKIE_SECURE n/a False -DJANGO_EMAIL_BACKEND EMAIL_BACKEND django.core.mail.backends.console.EmailBackend django.core.mail.backends.smtp.EmailBackend -DJANGO_EMAIL_HOST EMAIL_HOST localhost smtp.sendgrid.com -EMAIL_PORT EMAIL_PORT 1025 587 -SENDGRID_USERNAME EMAIL_HOST_USER n/a raises error -SENDGRID_PASSWORD EMAIL_HOST_PASSWORD n/a raises error DJANGO_DEFAULT_FROM_EMAIL DEFAULT_FROM_EMAIL n/a "{{cookiecutter.project_name}} " +DJANGO_SERVER_EMAIL SERVER_EMAIL n/a "{{cookiecutter.project_name}} " EMAIL_SUBJECT_PREFIX EMAIL_SUBJECT_PREFIX n/a "[{{cookiecutter.project_name}}] " ======================================= =========================== ============================================== ====================================================================== -* TODO: Add vendor-added settings in another table +The following table lists settings and their defaults for third-party applications: + +======================================= =========================== ============================================== ====================================================================== +Environment Variable Django Setting Development Default Production Default +======================================= =========================== ============================================== ====================================================================== +MAILGUN_API_KEY MAILGUN_ACCESS_KEY n/a raises error +MAILGUN_SERVER_NAME MAILGUN_SERVER_NAME n/a raises error +======================================= =========================== ============================================== ====================================================================== Getting up and running ---------------------- @@ -126,7 +129,7 @@ Run these commands to deploy the project to Heroku: heroku pg:backups schedule DATABASE_URL heroku pg:promote DATABASE_URL - heroku addons:create sendgrid:starter + heroku addons:create mailgun heroku addons:create memcachier:dev heroku config:set DJANGO_SECRET_KEY=RANDOM_SECRET_KEY_HERE @@ -136,8 +139,7 @@ Run these commands to deploy the project to Heroku: heroku config:set DJANGO_AWS_SECRET_ACCESS_KEY=YOUR_AWS_SECRET_ACCESS_KEY_HERE heroku config:set DJANGO_AWS_STORAGE_BUCKET_NAME=YOUR_AWS_S3_BUCKET_NAME_HERE - heroku config:set SENDGRID_USERNAME=YOUR_SENDGRID_USERNAME - heroku config:set SENDGRID_PASSWORD=YOUR_SENDGRID_PASSWORD + heroku config:set MAILGUN_SERVER_NAME=YOUR_MALGUN_SERVER git push heroku master heroku run python manage.py migrate @@ -180,8 +182,8 @@ You can then deploy by running the following commands. ssh -t dokku@yourservername.com dokku config:set {{cookiecutter.repo_name}} DJANGO_AWS_ACCESS_KEY_ID=YOUR_AWS_ID_HERE ssh -t dokku@yourservername.com dokku config:set {{cookiecutter.repo_name}} DJANGO_AWS_SECRET_ACCESS_KEY=YOUR_AWS_SECRET_ACCESS_KEY_HERE ssh -t dokku@yourservername.com dokku config:set {{cookiecutter.repo_name}} DJANGO_AWS_STORAGE_BUCKET_NAME=YOUR_AWS_S3_BUCKET_NAME_HERE - ssh -t dokku@yourservername.com dokku config:set {{cookiecutter.repo_name}} SENDGRID_USERNAME=YOUR_SENDGRID_USERNAME - ssh -t dokku@yourservername.com dokku config:set {{cookiecutter.repo_name}} SENDGRID_PASSWORD=YOUR_SENDGRID_PASSWORD + ssh -t dokku@yourservername.com dokku config:set {{cookiecutter.repo_name}} MAILGUN_API_KEY=YOUR_MAILGUN_API_KEY + ssh -t dokku@yourservername.com dokku config:set {{cookiecutter.repo_name}} MAILGUN_SERVER_NAME=YOUR_MAILGUN_SERVER ssh -t dokku@yourservername.com dokku run {{cookiecutter.repo_name}} python manage.py migrate ssh -t dokku@yourservername.com dokku run {{cookiecutter.repo_name}} python manage.py createsuperuser diff --git a/{{cookiecutter.repo_name}}/config/settings/production.py b/{{cookiecutter.repo_name}}/config/settings/production.py index d229cfb7..acbb01de 100644 --- a/{{cookiecutter.repo_name}}/config/settings/production.py +++ b/{{cookiecutter.repo_name}}/config/settings/production.py @@ -102,13 +102,11 @@ INSTALLED_APPS = ('collectfast', ) + INSTALLED_APPS # ------------------------------------------------------------------------------ DEFAULT_FROM_EMAIL = env('DJANGO_DEFAULT_FROM_EMAIL', default='{{cookiecutter.project_name}} ') -EMAIL_HOST = env("DJANGO_EMAIL_HOST", default='smtp.sendgrid.com') -EMAIL_HOST_PASSWORD = env("SENDGRID_PASSWORD") -EMAIL_HOST_USER = env('SENDGRID_USERNAME') -EMAIL_PORT = env.int("EMAIL_PORT", default=587) +EMAIL_BACKEND = 'django_mailgun.MailgunBackend' +MAILGUN_ACCESS_KEY = env('MAILGUN_API_KEY') +MAILGUN_SERVER_NAME = env('MAILGUN_SERVER_NAME') EMAIL_SUBJECT_PREFIX = env("EMAIL_SUBJECT_PREFIX", default='[{{cookiecutter.project_name}}] ') -EMAIL_USE_TLS = True -SERVER_EMAIL = EMAIL_HOST_USER +SERVER_EMAIL = env('DJANGO_SERVER_EMAIL', DEFAULT_FROM_EMAIL) # TEMPLATE CONFIGURATION # ------------------------------------------------------------------------------ diff --git a/{{cookiecutter.repo_name}}/requirements/production.txt b/{{cookiecutter.repo_name}}/requirements/production.txt index 9549e730..b30edce5 100644 --- a/{{cookiecutter.repo_name}}/requirements/production.txt +++ b/{{cookiecutter.repo_name}}/requirements/production.txt @@ -14,3 +14,7 @@ django-storages-redux==1.2.3 {% if cookiecutter.use_whitenoise != 'y' -%} Collectfast==0.2.3 {%- endif %} + +# Mailgun Support +# --------------- +django-mailgun==0.2.2 From ec58914ea7dd49ea3e6dbffb7ddf798cb819b6b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20C=2E=20Barrionuevo=20da=20Luz?= Date: Tue, 7 Jul 2015 08:17:03 -0300 Subject: [PATCH 2/5] add Burhan Khalid to CONTRIBUTORS list --- CONTRIBUTORS.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 89c8e3cc..9bbbfd4b 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -46,6 +46,7 @@ Daniele Tricoli / @eriol Harry Percival / @hjwp Cullen Rhodes / @c-rhodes Audrey Roy Greenfeld / @audreyr (and creator/maintainer of cookiecutter) * +Burhan Khalid / @burhan * Possesses commit rights From e5dc8b97c118ad5530c1d74fd6eb186992d6e376 Mon Sep 17 00:00:00 2001 From: "Fabio C. Barrioneuvo da Luz" Date: Tue, 7 Jul 2015 09:15:26 -0300 Subject: [PATCH 3/5] update dependencies versions update pylibmc version to 1.5.0 django-allauth to 0.21.0 Pillow to 2.9.0 whitenoise to 2.0.2 --- {{cookiecutter.repo_name}}/requirements.txt | 2 +- {{cookiecutter.repo_name}}/requirements/base.txt | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/{{cookiecutter.repo_name}}/requirements.txt b/{{cookiecutter.repo_name}}/requirements.txt index 4311d9c2..afd13bfc 100644 --- a/{{cookiecutter.repo_name}}/requirements.txt +++ b/{{cookiecutter.repo_name}}/requirements.txt @@ -1,5 +1,5 @@ # This file is here because many Platforms as a Service look for # requirements.txt in the root directory of a project. -pylibmc==1.4.3 +pylibmc==1.5.0 django-heroku-memcacheify==0.8 -r requirements/production.txt diff --git a/{{cookiecutter.repo_name}}/requirements/base.txt b/{{cookiecutter.repo_name}}/requirements/base.txt index 3bf39542..d9dc0c35 100644 --- a/{{cookiecutter.repo_name}}/requirements/base.txt +++ b/{{cookiecutter.repo_name}}/requirements/base.txt @@ -5,7 +5,7 @@ django==1.8.2 django-environ==0.3.0 django-secure==1.0.1 {% if cookiecutter.use_whitenoise == 'y' -%} -whitenoise==2.0 +whitenoise==2.0.2 {%- endif %} @@ -18,11 +18,11 @@ django-floppyforms==1.4.1 django-model-utils==2.2 # Images -Pillow==2.8.2 +Pillow==2.9.0 # For user registration, either via email or social # Well-built with regular release cycles! -django-allauth==0.20.0 +django-allauth==0.21.0 # For the persistence stores psycopg2==2.6.1 From 740483f0e70a2c3e4b340ce16f021f38f90b11bb Mon Sep 17 00:00:00 2001 From: Burhan Khalid Date: Tue, 7 Jul 2015 22:06:46 +0300 Subject: [PATCH 4/5] unifying environment variables --- {{cookiecutter.repo_name}}/README.rst | 12 ++++++------ .../config/settings/production.py | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/{{cookiecutter.repo_name}}/README.rst b/{{cookiecutter.repo_name}}/README.rst index 9f89972c..ef6155af 100644 --- a/{{cookiecutter.repo_name}}/README.rst +++ b/{{cookiecutter.repo_name}}/README.rst @@ -16,9 +16,6 @@ For configuration purposes, the following table maps the '{{cookiecutter.project ======================================= =========================== ============================================== ====================================================================== Environment Variable Django Setting Development Default Production Default ======================================= =========================== ============================================== ====================================================================== -DJANGO_AWS_ACCESS_KEY_ID AWS_ACCESS_KEY_ID n/a raises error -DJANGO_AWS_SECRET_ACCESS_KEY AWS_SECRET_ACCESS_KEY n/a raises error -DJANGO_AWS_STORAGE_BUCKET_NAME AWS_STORAGE_BUCKET_NAME n/a raises error DJANGO_CACHES CACHES (default) locmem memcached DJANGO_DATABASES DATABASES (default) See code See code DJANGO_DEBUG DEBUG True False @@ -32,7 +29,7 @@ DJANGO_SESSION_COOKIE_HTTPONLY SESSION_COOKIE_HTTPONLY n/a DJANGO_SESSION_COOKIE_SECURE SESSION_COOKIE_SECURE n/a False DJANGO_DEFAULT_FROM_EMAIL DEFAULT_FROM_EMAIL n/a "{{cookiecutter.project_name}} " DJANGO_SERVER_EMAIL SERVER_EMAIL n/a "{{cookiecutter.project_name}} " -EMAIL_SUBJECT_PREFIX EMAIL_SUBJECT_PREFIX n/a "[{{cookiecutter.project_name}}] " +DJANGO_EMAIL_SUBJECT_PREFIX EMAIL_SUBJECT_PREFIX n/a "[{{cookiecutter.project_name}}] " ======================================= =========================== ============================================== ====================================================================== The following table lists settings and their defaults for third-party applications: @@ -40,8 +37,11 @@ The following table lists settings and their defaults for third-party applicatio ======================================= =========================== ============================================== ====================================================================== Environment Variable Django Setting Development Default Production Default ======================================= =========================== ============================================== ====================================================================== -MAILGUN_API_KEY MAILGUN_ACCESS_KEY n/a raises error -MAILGUN_SERVER_NAME MAILGUN_SERVER_NAME n/a raises error +DJANGO_AWS_ACCESS_KEY_ID AWS_ACCESS_KEY_ID n/a raises error +DJANGO_AWS_SECRET_ACCESS_KEY AWS_SECRET_ACCESS_KEY n/a raises error +DJANGO_AWS_STORAGE_BUCKET_NAME AWS_STORAGE_BUCKET_NAME n/a raises error +DJANGO_MAILGUN_API_KEY MAILGUN_ACCESS_KEY n/a raises error +DJANGO_MAILGUN_SERVER_NAME MAILGUN_SERVER_NAME n/a raises error ======================================= =========================== ============================================== ====================================================================== Getting up and running diff --git a/{{cookiecutter.repo_name}}/config/settings/production.py b/{{cookiecutter.repo_name}}/config/settings/production.py index acbb01de..1c103f3b 100644 --- a/{{cookiecutter.repo_name}}/config/settings/production.py +++ b/{{cookiecutter.repo_name}}/config/settings/production.py @@ -4,7 +4,7 @@ Production Configurations - Use djangosecure - Use Amazon's S3 for storing static files and uploaded media -- Use sendgrid to send emails +- Use mailgun to send emails - Use MEMCACHIER on Heroku ''' from __future__ import absolute_import, unicode_literals @@ -103,9 +103,9 @@ INSTALLED_APPS = ('collectfast', ) + INSTALLED_APPS DEFAULT_FROM_EMAIL = env('DJANGO_DEFAULT_FROM_EMAIL', default='{{cookiecutter.project_name}} ') EMAIL_BACKEND = 'django_mailgun.MailgunBackend' -MAILGUN_ACCESS_KEY = env('MAILGUN_API_KEY') -MAILGUN_SERVER_NAME = env('MAILGUN_SERVER_NAME') -EMAIL_SUBJECT_PREFIX = env("EMAIL_SUBJECT_PREFIX", default='[{{cookiecutter.project_name}}] ') +MAILGUN_ACCESS_KEY = env('DJANGO_MAILGUN_API_KEY') +MAILGUN_SERVER_NAME = env('DJANGO_MAILGUN_SERVER_NAME') +EMAIL_SUBJECT_PREFIX = env("DJANGO_EMAIL_SUBJECT_PREFIX", default='[{{cookiecutter.project_name}}] ') SERVER_EMAIL = env('DJANGO_SERVER_EMAIL', DEFAULT_FROM_EMAIL) # TEMPLATE CONFIGURATION From 076c7c21c62150b659be3cba8258d20bcc40a82e Mon Sep 17 00:00:00 2001 From: Burhan Khalid Date: Tue, 7 Jul 2015 22:29:41 +0300 Subject: [PATCH 5/5] set correct variables for heroku/doku --- {{cookiecutter.repo_name}}/README.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/{{cookiecutter.repo_name}}/README.rst b/{{cookiecutter.repo_name}}/README.rst index ef6155af..9c0859bc 100644 --- a/{{cookiecutter.repo_name}}/README.rst +++ b/{{cookiecutter.repo_name}}/README.rst @@ -139,7 +139,7 @@ Run these commands to deploy the project to Heroku: heroku config:set DJANGO_AWS_SECRET_ACCESS_KEY=YOUR_AWS_SECRET_ACCESS_KEY_HERE heroku config:set DJANGO_AWS_STORAGE_BUCKET_NAME=YOUR_AWS_S3_BUCKET_NAME_HERE - heroku config:set MAILGUN_SERVER_NAME=YOUR_MALGUN_SERVER + heroku config:set DJANGO_MAILGUN_SERVER_NAME=YOUR_MALGUN_SERVER git push heroku master heroku run python manage.py migrate @@ -182,8 +182,8 @@ You can then deploy by running the following commands. ssh -t dokku@yourservername.com dokku config:set {{cookiecutter.repo_name}} DJANGO_AWS_ACCESS_KEY_ID=YOUR_AWS_ID_HERE ssh -t dokku@yourservername.com dokku config:set {{cookiecutter.repo_name}} DJANGO_AWS_SECRET_ACCESS_KEY=YOUR_AWS_SECRET_ACCESS_KEY_HERE ssh -t dokku@yourservername.com dokku config:set {{cookiecutter.repo_name}} DJANGO_AWS_STORAGE_BUCKET_NAME=YOUR_AWS_S3_BUCKET_NAME_HERE - ssh -t dokku@yourservername.com dokku config:set {{cookiecutter.repo_name}} MAILGUN_API_KEY=YOUR_MAILGUN_API_KEY - ssh -t dokku@yourservername.com dokku config:set {{cookiecutter.repo_name}} MAILGUN_SERVER_NAME=YOUR_MAILGUN_SERVER + ssh -t dokku@yourservername.com dokku config:set {{cookiecutter.repo_name}} DJANGO_MAILGUN_API_KEY=YOUR_MAILGUN_API_KEY + ssh -t dokku@yourservername.com dokku config:set {{cookiecutter.repo_name}} DJANGO_MAILGUN_SERVER_NAME=YOUR_MAILGUN_SERVER ssh -t dokku@yourservername.com dokku run {{cookiecutter.repo_name}} python manage.py migrate ssh -t dokku@yourservername.com dokku run {{cookiecutter.repo_name}} python manage.py createsuperuser