From 8a682818b33efab41fb8bc460c01d3a4c8972640 Mon Sep 17 00:00:00 2001 From: Krzysztof Szumny Date: Mon, 18 Apr 2016 23:10:49 +0200 Subject: [PATCH] Additional conditions with use_docker --- docs/developing-locally.rst | 11 ++++++++++- {{cookiecutter.repo_name}}/.gitignore | 4 ++++ {{cookiecutter.repo_name}}/Gruntfile.js | 6 ++++++ {{cookiecutter.repo_name}}/README.rst | 17 ++++++++++++++++- 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/docs/developing-locally.rst b/docs/developing-locally.rst index b31990c5..14e72046 100644 --- a/docs/developing-locally.rst +++ b/docs/developing-locally.rst @@ -41,14 +41,23 @@ You can now run the usual Django ``migrate`` and ``runserver`` commands:: django-allauth sends an email to verify users (and superusers) after signup and login (if they are still not verified). To send email you need to `configure your email backend`_ .. _configure your email backend: http://docs.djangoproject.com/en/1.9/topics/email/#smtp-backend - +{% if cookiecutter.use_docker == 'y' %} In development you can (optionally) use MailHog_ for email testing. MailHog is added as docker-container. To use MailHog:: 1. Make sure, that ``mailhog`` docker container is up and running 2. Open your browser and go to ``http://127.0.0.1:8025`` .. _Mailhog: https://github.com/mailhog/MailHog/ +{% else %} +In development you can (optionally) use MailHog_ for email testing. MailHog is built with Go so there are no dependencies. To use MailHog:: +1. `Download the latest release`_ for your operating system +2. Rename the executable to ``mailhog`` and copy it to the root of your project directory +3. Make sure it is executable (e.g. ``chmod +x mailhog``) + +.. _Mailhog: https://github.com/mailhog/MailHog/ +.. _Download the latest release: https://github.com/mailhog/MailHog/releases +{% endif %} Alternatively simply output emails to the console via: ``EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'`` In production basic email configuration is setup to send emails with Mailgun_ diff --git a/{{cookiecutter.repo_name}}/.gitignore b/{{cookiecutter.repo_name}}/.gitignore index 8e9a45ef..aebef599 100644 --- a/{{cookiecutter.repo_name}}/.gitignore +++ b/{{cookiecutter.repo_name}}/.gitignore @@ -70,3 +70,7 @@ node_modules/ # Hitch directory tests/.hitch +{% if cookiecutter.use_mailhog == 'y' and cookiecutter.use_docker == 'n'%} +# MailHog binary +mailhog +{% endif %} diff --git a/{{cookiecutter.repo_name}}/Gruntfile.js b/{{cookiecutter.repo_name}}/Gruntfile.js index cf3f25c7..e5fbccee 100644 --- a/{{cookiecutter.repo_name}}/Gruntfile.js +++ b/{{cookiecutter.repo_name}}/Gruntfile.js @@ -112,10 +112,16 @@ module.exports = function (grunt) { runDjango: { cmd: 'python <%= paths.manageScript %> runserver' }, + {% if cookiecutter.use_mailhog == "y" and cookiecutter.use_docker == 'n' -%}runMailHog: { + cmd: './mailhog' + },{%- endif %} } }); grunt.registerTask('serve', [ + {% if cookiecutter.use_mailhog == "y" and cookiecutter.use_docker == 'n' -%} + 'bgShell:runMailHog', + {%- endif %} 'bgShell:runDjango', 'watch' ]); diff --git a/{{cookiecutter.repo_name}}/README.rst b/{{cookiecutter.repo_name}}/README.rst index 56957719..bfdbff3c 100644 --- a/{{cookiecutter.repo_name}}/README.rst +++ b/{{cookiecutter.repo_name}}/README.rst @@ -77,7 +77,7 @@ Please note: For Celery's import magic to work, it is important *where* the cele Email Server ^^^^^^^^^^^^ - +{% if cookiecutter.use_docker == 'y' %} In development, it is often nice to be able to see emails that are being sent from your application. For that reason local SMTP server `MailHog`_ with a web interface is available as docker container. .. _mailhog: https://github.com/mailhog/MailHog @@ -86,7 +86,22 @@ Container mailhog will start automatically when you will run all docker containe Please check `cookiecutter-django Docker documentation`_ for more details how to start all containers. With MailHog running, to view messages that are sent by your application, open your browser and go to ``http://127.0.0.1:8025`` +{% else %} +In development, it is often nice to be able to see emails that are being sent from your application. If you choose to use `MailHog`_ when generating the project a local SMTP server with a web interface will be available. +.. _mailhog: https://github.com/mailhog/MailHog + +To start the service, make sure you have nodejs installed, and then type the following:: + + $ npm install + $ grunt serve + +(After the first run you only need to type ``grunt serve``) This will start an email server that listens on ``127.0.0.1:1025`` in addition to starting your Django project and a watch task for live reload. + +To view messages that are sent by your application, open your browser and go to ``http://127.0.0.1:8025`` + +The email server will exit when you exit the Grunt task on the CLI with Ctrl+C. +{% endif %} {% endif %} {% if cookiecutter.use_sentry == "y" %}