post_get_project.py hook

This commit is contained in:
Krzysztof Szumny 2015-08-18 12:02:58 +02:00
parent 912aa36505
commit 7f747b9264
4 changed files with 28 additions and 3 deletions

View File

@ -37,7 +37,7 @@ Features
* Pre configured Celery_ (optional)
* Integration with Maildump_ for local email testing (optional)
* Integration with Sentry_ for error logging (optional)
* Docker support using docker-compose_ for dev and prod
* Docker support using docker-compose_ for dev (with debug) and prod
.. _Hitch: https://github.com/hitchtest/hitchtest
.. _Bootstrap: https://github.com/twbs/bootstrap

View File

@ -13,6 +13,6 @@
"use_celery": "n",
"use_maildump": "n",
"use_sentry": "n",
"docker": "y",
"use_docker": "n",
"windows": "n"
}

25
hooks/post_gen_project.py Normal file
View File

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
import os
import shutil
project_directory = os.path.realpath(os.path.curdir)
docker = '{{cookiecutter.use_docker}}' == 'y'
docker_files = [
'debug.yml',
'dev.yml',
'docker-compose.yml',
'Dockerfile'
]
docker_dirs = [
'compose/',
]
if not docker:
for path in docker_files:
os.remove(os.path.join(project_directory, path))
for path in docker_dirs:
shutil.rmtree(os.path.join(project_directory, path))

View File

@ -99,7 +99,7 @@ MANAGERS = ADMINS
# See: https://docs.djangoproject.com/en/dev/ref/settings/#databases
DATABASES = {
# Raises ImproperlyConfigured exception if DATABASE_URL not in os.environ
{% if cookiecutter.docker == 'y' %}
{% if cookiecutter.use_docker == 'y' %}
'default': 'postgres://postgres@postgres/postgres'),
{% else %}
'default': env.db("DATABASE_URL", default="postgres://{% if cookiecutter.windows == 'y' %}localhost{% endif %}/{{cookiecutter.repo_name}}"),