diff --git a/.pyup.yml b/.pyup.yml index 4978524e8..a215e841e 100644 --- a/.pyup.yml +++ b/.pyup.yml @@ -8,10 +8,11 @@ update: all # allowed: True, False pin: True -# Specify requirement files by hand, pyup seems to struggle to +# Specify requirement files by hand, pyup seems to struggle to # find the ones in the project_slug folder requirements: - "requirements.txt" - "{{cookiecutter.project_slug}}/requirements/base.txt" - - "{{cookiecutter.project_slug}}/requirements/local.txt" + - "{{cookiecutter.project_slug}}/requirements/dev.txt" - "{{cookiecutter.project_slug}}/requirements/production.txt" + - "{{cookiecutter.project_slug}}/requirements/test.txt" diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index e6aef1da6..968c0f73e 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -212,7 +212,6 @@ def set_flags_in_envs(postgres_user, celery_flower_user, debug=False): local_django_envs_path = os.path.join(".envs", "dev", "django") production_django_envs_path = os.path.join(".envs", "prod", "django") local_postgres_envs_path = os.path.join(".envs", "dev", "postgres") - production_postgres_envs_path = os.path.join(".envs", "prod", "postgres") set_django_secret_key(production_django_envs_path) set_django_admin_url(production_django_envs_path) @@ -221,10 +220,6 @@ def set_flags_in_envs(postgres_user, celery_flower_user, debug=False): set_postgres_password( local_postgres_envs_path, value=DEBUG_VALUE if debug else None ) - set_postgres_user(production_postgres_envs_path, value=postgres_user) - set_postgres_password( - production_postgres_envs_path, value=DEBUG_VALUE if debug else None - ) set_celery_flower_user(local_django_envs_path, value=celery_flower_user) set_celery_flower_password( @@ -250,10 +245,18 @@ def remove_envs_and_associated_files(): os.remove(os.path.join("bin", "merge_production_dotenvs_in_dotenv.py")) +def create_dev_settings(): + shutil.copy( + os.path.join("{{ cookiecutter.project_slug }}", "settings", "dev_template.py"), + os.path.join("{{ cookiecutter.project_slug }}", "settings", "dev.py"), + ) + + def main(): set_flags_in_envs(generate_random_user(), generate_random_user()) set_flags_in_settings_files() + create_dev_settings() if "{{ cookiecutter.open_source_license }}" == "Not open source": remove_open_source_files() diff --git a/{{cookiecutter.project_slug}}/.travis.yml b/{{cookiecutter.project_slug}}/.travis.yml index 2d86ac31c..767ca7fbd 100644 --- a/{{cookiecutter.project_slug}}/.travis.yml +++ b/{{cookiecutter.project_slug}}/.travis.yml @@ -12,6 +12,6 @@ language: python python: - "3.6" install: - - pip install -r requirements/local.txt + - pip install -r requirements/test.txt script: - "pytest" diff --git a/{{cookiecutter.project_slug}}/local.yml b/{{cookiecutter.project_slug}}/local.yml index 47a369c60..9b23c7ec0 100644 --- a/{{cookiecutter.project_slug}}/local.yml +++ b/{{cookiecutter.project_slug}}/local.yml @@ -40,12 +40,11 @@ services: image: mailhog/mailhog:v1.0.0 ports: - "8025:8025" - {%- endif %} - {%- if cookiecutter.use_celery == 'y' %} redis: image: redis:5.0 + {%- if cookiecutter.use_celery == 'y' %} celeryworker: <<: *django diff --git a/{{cookiecutter.project_slug}}/manage.py b/{{cookiecutter.project_slug}}/manage.py index 7e9c99e04..8003b5b00 100755 --- a/{{cookiecutter.project_slug}}/manage.py +++ b/{{cookiecutter.project_slug}}/manage.py @@ -3,7 +3,7 @@ import os import sys if __name__ == "__main__": - os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.local") + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ cookiecutter.project_slug }}.settings") try: from django.core.management import execute_from_command_line diff --git a/{{cookiecutter.project_slug}}/requirements/base.txt b/{{cookiecutter.project_slug}}/requirements/base.txt index 8b1151eb1..eb656acf8 100644 --- a/{{cookiecutter.project_slug}}/requirements/base.txt +++ b/{{cookiecutter.project_slug}}/requirements/base.txt @@ -21,7 +21,6 @@ django==2.2.3 # pyup: < 3.0 # https://www.djangoproject.com/ django-environ==0.4.5 # https://github.com/joke2k/django-environ django-model-utils==3.2.0 # https://github.com/jazzband/django-model-utils django-allauth==0.39.1 # https://github.com/pennersr/django-allauth -django-crispy-forms==1.7.2 # https://github.com/django-crispy-forms/django-crispy-forms {%- if cookiecutter.use_compressor == "y" %} django-compressor==2.3 # https://github.com/django-compressor/django-compressor {%- endif %} diff --git a/{{cookiecutter.project_slug}}/requirements/dev.txt b/{{cookiecutter.project_slug}}/requirements/dev.txt index c3c8b4069..6a806c964 100644 --- a/{{cookiecutter.project_slug}}/requirements/dev.txt +++ b/{{cookiecutter.project_slug}}/requirements/dev.txt @@ -1,31 +1,8 @@ -r ./base.txt +-r ./test.txt Werkzeug==0.14.1 # pyup: < 0.15 # https://github.com/pallets/werkzeug ipdb==0.12 # https://github.com/gotcha/ipdb -Sphinx==2.1.2 # https://github.com/sphinx-doc/sphinx psycopg2-binary==2.8.3 # https://github.com/psycopg/psycopg2 - -# Testing -# ------------------------------------------------------------------------------ -mypy==0.720 # https://github.com/python/mypy -pytest==5.0.1 # https://github.com/pytest-dev/pytest -pytest-sugar==0.9.2 # https://github.com/Frozenball/pytest-sugar - -# Code quality -# ------------------------------------------------------------------------------ -flake8==3.7.8 # https://github.com/PyCQA/flake8 -coverage==4.5.3 # https://github.com/nedbat/coveragepy -black==19.3b0 # https://github.com/ambv/black -pylint-django==2.0.11 # https://github.com/PyCQA/pylint-django -{%- if cookiecutter.use_celery == 'y' %} -pylint-celery==0.3 # https://github.com/PyCQA/pylint-celery -{%- endif %} - -# Django -# ------------------------------------------------------------------------------ -factory-boy==2.12.0 # https://github.com/FactoryBoy/factory_boy - django-debug-toolbar==2.0 # https://github.com/jazzband/django-debug-toolbar django-extensions==2.1.9 # https://github.com/django-extensions/django-extensions -django-coverage-plugin==1.6.0 # https://github.com/nedbat/django_coverage_plugin -pytest-django==3.5.1 # https://github.com/pytest-dev/pytest-django diff --git a/{{cookiecutter.project_slug}}/requirements/production.txt b/{{cookiecutter.project_slug}}/requirements/production.txt index f5e5ffea0..ff1bbf3c2 100644 --- a/{{cookiecutter.project_slug}}/requirements/production.txt +++ b/{{cookiecutter.project_slug}}/requirements/production.txt @@ -4,9 +4,6 @@ gunicorn==19.9.0 # https://github.com/benoitc/gunicorn psycopg2==2.8.3 --no-binary psycopg2 # https://github.com/psycopg/psycopg2 -{%- if cookiecutter.use_whitenoise == 'n' %} -Collectfast==0.6.2 # https://github.com/antonagestam/collectfast -{%- endif %} {%- if cookiecutter.use_sentry == "y" %} sentry-sdk==0.10.2 # https://github.com/getsentry/sentry-python {%- endif %} @@ -17,5 +14,7 @@ sentry-sdk==0.10.2 # https://github.com/getsentry/sentry-python django-storages[boto3]==1.7.1 # https://github.com/jschneier/django-storages {%- elif cookiecutter.cloud_provider == 'GCP' %} django-storages[google]==1.7.1 # https://github.com/jschneier/django-storages +{%- elif cookiecutter.cloud_provider == 'Azure' %} +django-storages[azure]==1.7.1 # https://github.com/jschneier/django-storages {%- endif %} django-anymail[mailgun]==6.1.0 # https://github.com/anymail/django-anymail diff --git a/{{cookiecutter.project_slug}}/requirements/test.txt b/{{cookiecutter.project_slug}}/requirements/test.txt new file mode 100644 index 000000000..87ed0971a --- /dev/null +++ b/{{cookiecutter.project_slug}}/requirements/test.txt @@ -0,0 +1,25 @@ +# Documentation +# ------------------------------------------------------------------------------ +Sphinx==2.1.2 # https://github.com/sphinx-doc/sphinx + +# Testing +# ------------------------------------------------------------------------------ +mypy==0.720 # https://github.com/python/mypy +pytest==5.0.1 # https://github.com/pytest-dev/pytest +pytest-sugar==0.9.2 # https://github.com/Frozenball/pytest-sugar + +# Code quality +# ------------------------------------------------------------------------------ +flake8==3.7.8 # https://github.com/PyCQA/flake8 +coverage==4.5.3 # https://github.com/nedbat/coveragepy +black==19.3b0 # https://github.com/ambv/black +pylint-django==2.0.11 # https://github.com/PyCQA/pylint-django +{%- if cookiecutter.use_celery == 'y' %} +pylint-celery==0.3 # https://github.com/PyCQA/pylint-celery +{%- endif %} + +# Django plugins for testing +# ------------------------------------------------------------------------------ +factory-boy==2.12.0 # https://github.com/FactoryBoy/factory_boy +django-coverage-plugin==1.6.0 # https://github.com/nedbat/django_coverage_plugin +pytest-django==3.5.1 # https://github.com/pytest-dev/pytest-django diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/celery_app.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/celery_app.py index e275f054f..f71d5a52c 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/celery_app.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/celery_app.py @@ -2,7 +2,7 @@ import os from celery import Celery # set the default Django settings module for the 'celery' program. -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.local") +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{cookiecutter.project_slug}}.settings") app = Celery("{{cookiecutter.project_slug}}")