From ec80a05671b31cd8359a0189ec96b26026278972 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jules=20Ch=C3=A9ron?= Date: Mon, 8 Jul 2019 00:35:09 +0200 Subject: [PATCH 001/182] Handle path with pathlib - Update config/settings/base.py - Update merge_production_dotenvs_in_dotenv.py - Update wsgi.py - Update manage.py --- CONTRIBUTORS.rst | 2 ++ .../config/settings/base.py | 22 +++++++++---------- {{cookiecutter.project_slug}}/config/wsgi.py | 7 +++--- {{cookiecutter.project_slug}}/manage.py | 5 +++-- .../merge_production_dotenvs_in_dotenv.py | 17 +++++++------- 5 files changed, 28 insertions(+), 25 deletions(-) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index 5a650b90..d45d79e8 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -122,6 +122,7 @@ Listed in alphabetical order. Jerome Leclanche `@jleclanche`_ @Adys Jimmy Gitonga `@afrowave`_ @afrowave John Cass `@jcass77`_ @cass_john + Jules Cheron `@jules-ch`_ Julien Almarcha `@sladinji`_ Julio Castillo `@juliocc`_ Kaido Kert `@kaidokert`_ @@ -274,6 +275,7 @@ Listed in alphabetical order. .. _@jazztpt: https://github.com/jazztpt .. _@jcass77: https://github.com/jcass77 .. _@jleclanche: https://github.com/jleclanche +.. _@jules-ch: https://github.com/jules-ch .. _@juliocc: https://github.com/juliocc .. _@jvanbrug: https://github.com/jvanbrug .. _@ka7eh: https://github.com/ka7eh diff --git a/{{cookiecutter.project_slug}}/config/settings/base.py b/{{cookiecutter.project_slug}}/config/settings/base.py index 7def8f48..67c52418 100644 --- a/{{cookiecutter.project_slug}}/config/settings/base.py +++ b/{{cookiecutter.project_slug}}/config/settings/base.py @@ -4,17 +4,17 @@ Base settings to build other settings files upon. import environ -ROOT_DIR = ( - environ.Path(__file__) - 3 -) # ({{ cookiecutter.project_slug }}/config/settings/base.py - 3 = {{ cookiecutter.project_slug }}/) -APPS_DIR = ROOT_DIR.path("{{ cookiecutter.project_slug }}") +from pathlib import Path +ROOT_DIR = Path(__file__).parents[2] +# {{ cookiecutter.project_slug }}/) +APPS_DIR = ROOT_DIR / "{{ cookiecutter.project_slug }}" env = environ.Env() READ_DOT_ENV_FILE = env.bool("DJANGO_READ_DOT_ENV_FILE", default=False) if READ_DOT_ENV_FILE: # OS environment variables take precedence over variables from .env - env.read_env(str(ROOT_DIR.path(".env"))) + env.read_env(str(ROOT_DIR / ".env")) # GENERAL # ------------------------------------------------------------------------------ @@ -36,7 +36,7 @@ USE_L10N = True # https://docs.djangoproject.com/en/dev/ref/settings/#use-tz USE_TZ = True # https://docs.djangoproject.com/en/dev/ref/settings/#locale-paths -LOCALE_PATHS = [ROOT_DIR.path("locale")] +LOCALE_PATHS = [str(ROOT_DIR / "locale")] # DATABASES # ------------------------------------------------------------------------------ @@ -143,11 +143,11 @@ MIDDLEWARE = [ # STATIC # ------------------------------------------------------------------------------ # https://docs.djangoproject.com/en/dev/ref/settings/#static-root -STATIC_ROOT = str(ROOT_DIR("staticfiles")) +STATIC_ROOT = str(ROOT_DIR / "staticfiles") # https://docs.djangoproject.com/en/dev/ref/settings/#static-url STATIC_URL = "/static/" # https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:setting-STATICFILES_DIRS -STATICFILES_DIRS = [str(APPS_DIR.path("static"))] +STATICFILES_DIRS = [str(APPS_DIR / "static")] # https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#staticfiles-finders STATICFILES_FINDERS = [ "django.contrib.staticfiles.finders.FileSystemFinder", @@ -157,7 +157,7 @@ STATICFILES_FINDERS = [ # MEDIA # ------------------------------------------------------------------------------ # https://docs.djangoproject.com/en/dev/ref/settings/#media-root -MEDIA_ROOT = str(APPS_DIR("media")) +MEDIA_ROOT = str(APPS_DIR / "media") # https://docs.djangoproject.com/en/dev/ref/settings/#media-url MEDIA_URL = "/media/" @@ -169,7 +169,7 @@ TEMPLATES = [ # https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-TEMPLATES-BACKEND "BACKEND": "django.template.backends.django.DjangoTemplates", # https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs - "DIRS": [str(APPS_DIR.path("templates"))], + "DIRS": [str(APPS_DIR / "templates")], "OPTIONS": { # https://docs.djangoproject.com/en/dev/ref/settings/#template-loaders # https://docs.djangoproject.com/en/dev/ref/templates/api/#loader-types @@ -197,7 +197,7 @@ CRISPY_TEMPLATE_PACK = "bootstrap4" # FIXTURES # ------------------------------------------------------------------------------ # https://docs.djangoproject.com/en/dev/ref/settings/#fixture-dirs -FIXTURE_DIRS = (str(APPS_DIR.path("fixtures")),) +FIXTURE_DIRS = (str(APPS_DIR / "fixtures"),) # SECURITY # ------------------------------------------------------------------------------ diff --git a/{{cookiecutter.project_slug}}/config/wsgi.py b/{{cookiecutter.project_slug}}/config/wsgi.py index 1899a30c..b5755c5c 100644 --- a/{{cookiecutter.project_slug}}/config/wsgi.py +++ b/{{cookiecutter.project_slug}}/config/wsgi.py @@ -17,13 +17,12 @@ import os import sys from django.core.wsgi import get_wsgi_application +from pathlib import Path # This allows easy placement of apps within the interior # {{ cookiecutter.project_slug }} directory. -app_path = os.path.abspath( - os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir) -) -sys.path.append(os.path.join(app_path, "{{ cookiecutter.project_slug }}")) +app_path = Path(__file__).parents[1].resolve() +sys.path.append(str(app_path / "{{ cookiecutter.project_slug }}")) # We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks # if running multiple sites in the same mod_wsgi process. To fix this, use # mod_wsgi daemon mode with each site in its own daemon process, or use diff --git a/{{cookiecutter.project_slug}}/manage.py b/{{cookiecutter.project_slug}}/manage.py index 7e9c99e0..c44cc826 100755 --- a/{{cookiecutter.project_slug}}/manage.py +++ b/{{cookiecutter.project_slug}}/manage.py @@ -1,6 +1,7 @@ #!/usr/bin/env python import os import sys +from pathlib import Path if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.local") @@ -24,7 +25,7 @@ if __name__ == "__main__": # This allows easy placement of apps within the interior # {{ cookiecutter.project_slug }} directory. - current_path = os.path.dirname(os.path.abspath(__file__)) - sys.path.append(os.path.join(current_path, "{{ cookiecutter.project_slug }}")) + current_path = Path(__file__).parent.resolve() + sys.path.append(str(current_path / "{{ cookiecutter.project_slug }}")) execute_from_command_line(sys.argv) diff --git a/{{cookiecutter.project_slug}}/merge_production_dotenvs_in_dotenv.py b/{{cookiecutter.project_slug}}/merge_production_dotenvs_in_dotenv.py index 4e70e2ad..b204494e 100644 --- a/{{cookiecutter.project_slug}}/merge_production_dotenvs_in_dotenv.py +++ b/{{cookiecutter.project_slug}}/merge_production_dotenvs_in_dotenv.py @@ -1,15 +1,16 @@ import os from typing import Sequence +from pathlib import Path import pytest -ROOT_DIR_PATH = os.path.dirname(os.path.realpath(__file__)) -PRODUCTION_DOTENVS_DIR_PATH = os.path.join(ROOT_DIR_PATH, ".envs", ".production") +ROOT_DIR_PATH = Path(__file__).parent.resolve() +PRODUCTION_DOTENVS_DIR_PATH = ROOT_DIR_PATH.joinpath(".envs", ".production") PRODUCTION_DOTENV_FILE_PATHS = [ - os.path.join(PRODUCTION_DOTENVS_DIR_PATH, ".django"), - os.path.join(PRODUCTION_DOTENVS_DIR_PATH, ".postgres"), + PRODUCTION_DOTENVS_DIR_PATH / ".django", + PRODUCTION_DOTENVS_DIR_PATH / ".postgres", ] -DOTENV_FILE_PATH = os.path.join(ROOT_DIR_PATH, ".env") +DOTENV_FILE_PATH = ROOT_DIR_PATH / ".env" def merge( @@ -31,9 +32,9 @@ def main(): @pytest.mark.parametrize("merged_file_count", range(3)) @pytest.mark.parametrize("append_linesep", [True, False]) def test_merge(tmpdir_factory, merged_file_count: int, append_linesep: bool): - tmp_dir_path = str(tmpdir_factory.getbasetemp()) + tmp_dir_path = Path(str(tmpdir_factory.getbasetemp())) - output_file_path = os.path.join(tmp_dir_path, ".env") + output_file_path = tmp_dir_path / ".env" expected_output_file_content = "" merged_file_paths = [] @@ -41,7 +42,7 @@ def test_merge(tmpdir_factory, merged_file_count: int, append_linesep: bool): merged_file_ord = i + 1 merged_filename = ".service{}".format(merged_file_ord) - merged_file_path = os.path.join(tmp_dir_path, merged_filename) + merged_file_path = tmp_dir_path / merged_filename merged_file_content = merged_filename * merged_file_ord From 2a6ee05782d73f0539dcdccdb3d30bcb47871da6 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Sun, 2 Feb 2020 11:00:30 +0000 Subject: [PATCH 002/182] Update redis from 3.3.11 to 3.4.1 --- {{cookiecutter.project_slug}}/requirements/base.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/base.txt b/{{cookiecutter.project_slug}}/requirements/base.txt index dabc10c9..92898a24 100644 --- a/{{cookiecutter.project_slug}}/requirements/base.txt +++ b/{{cookiecutter.project_slug}}/requirements/base.txt @@ -8,7 +8,7 @@ argon2-cffi==19.2.0 # https://github.com/hynek/argon2_cffi {%- if cookiecutter.use_whitenoise == 'y' %} whitenoise==5.0.1 # https://github.com/evansd/whitenoise {%- endif %} -redis==3.3.11 # pyup: != 3.4.0 # https://github.com/andymccurdy/redis-py +redis==3.4.1 # pyup: != 3.4.0 # https://github.com/andymccurdy/redis-py {%- if cookiecutter.use_celery == "y" %} celery==4.4.0 # pyup: < 5.0 # https://github.com/celery/celery django-celery-beat==1.6.0 # https://github.com/celery/django-celery-beat From 06c7628a4c9162ac8f124a68fa3e3eca5c4abe8e Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Mon, 3 Feb 2020 01:45:39 -0800 Subject: [PATCH 003/182] Update pytest-cookies from 0.4.0 to 0.5.0 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index afc125ad..e05cff3f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,6 +12,6 @@ flake8==3.7.9 tox==3.14.3 pytest==5.3.5 pytest_cases==1.12.1 -pytest-cookies==0.4.0 +pytest-cookies==0.5.0 pytest-xdist==1.31.0 pyyaml==5.3 From b49e0f2e39bfa129744cab8d4ad807778039dd09 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Mon, 3 Feb 2020 11:00:31 +0000 Subject: [PATCH 004/182] Update django-storages from 1.8 to 1.9 --- {{cookiecutter.project_slug}}/requirements/production.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/production.txt b/{{cookiecutter.project_slug}}/requirements/production.txt index 38420a38..0a1975c2 100644 --- a/{{cookiecutter.project_slug}}/requirements/production.txt +++ b/{{cookiecutter.project_slug}}/requirements/production.txt @@ -14,7 +14,7 @@ sentry-sdk==0.14.1 # https://github.com/getsentry/sentry-python # Django # ------------------------------------------------------------------------------ {%- if cookiecutter.cloud_provider == 'AWS' %} -django-storages[boto3]==1.8 # https://github.com/jschneier/django-storages +django-storages[boto3]==1.9 # https://github.com/jschneier/django-storages {%- elif cookiecutter.cloud_provider == 'GCP' %} django-storages[google]==1.8 # https://github.com/jschneier/django-storages {%- endif %} From f6f78c9da849e3fa766842e5c311c5e7f99afebd Mon Sep 17 00:00:00 2001 From: browniebroke Date: Mon, 3 Feb 2020 11:00:32 +0000 Subject: [PATCH 005/182] Update django-storages from 1.8 to 1.9 --- {{cookiecutter.project_slug}}/requirements/production.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/production.txt b/{{cookiecutter.project_slug}}/requirements/production.txt index 0a1975c2..0f21e11a 100644 --- a/{{cookiecutter.project_slug}}/requirements/production.txt +++ b/{{cookiecutter.project_slug}}/requirements/production.txt @@ -16,6 +16,6 @@ sentry-sdk==0.14.1 # https://github.com/getsentry/sentry-python {%- if cookiecutter.cloud_provider == 'AWS' %} django-storages[boto3]==1.9 # https://github.com/jschneier/django-storages {%- elif cookiecutter.cloud_provider == 'GCP' %} -django-storages[google]==1.8 # https://github.com/jschneier/django-storages +django-storages[google]==1.9 # https://github.com/jschneier/django-storages {%- endif %} django-anymail[mailgun]==7.0.0 # https://github.com/anymail/django-anymail From e8a946dc7b61140b182354e968bd709b39f2efea Mon Sep 17 00:00:00 2001 From: browniebroke Date: Mon, 3 Feb 2020 11:00:35 +0000 Subject: [PATCH 006/182] Update django from 2.2.9 to 2.2.10 --- {{cookiecutter.project_slug}}/requirements/base.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/base.txt b/{{cookiecutter.project_slug}}/requirements/base.txt index dabc10c9..1347b6b2 100644 --- a/{{cookiecutter.project_slug}}/requirements/base.txt +++ b/{{cookiecutter.project_slug}}/requirements/base.txt @@ -19,7 +19,7 @@ flower==0.9.3 # https://github.com/mher/flower # Django # ------------------------------------------------------------------------------ -django==2.2.9 # pyup: < 3.0 # https://www.djangoproject.com/ +django==2.2.10 # pyup: < 3.0 # https://www.djangoproject.com/ django-environ==0.4.5 # https://github.com/joke2k/django-environ django-model-utils==4.0.0 # https://github.com/jazzband/django-model-utils django-allauth==0.41.0 # https://github.com/pennersr/django-allauth From 2f6cb4e8f68fa67fb14553bb90a18d3c2b91c5a1 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Mon, 3 Feb 2020 12:29:37 +0000 Subject: [PATCH 007/182] Fix deprecation warning --- tests/test_cookiecutter_generation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_cookiecutter_generation.py b/tests/test_cookiecutter_generation.py index 40e6cf1b..39b05d7c 100755 --- a/tests/test_cookiecutter_generation.py +++ b/tests/test_cookiecutter_generation.py @@ -3,7 +3,7 @@ import re import pytest from cookiecutter.exceptions import FailedHookException -from pytest_cases import pytest_fixture_plus +from pytest_cases import fixture_plus import sh import yaml from binaryornot.check import is_binary @@ -26,7 +26,7 @@ def context(): } -@pytest_fixture_plus +@fixture_plus @pytest.mark.parametrize("windows", ["y", "n"], ids=lambda yn: f"win:{yn}") @pytest.mark.parametrize("use_docker", ["y", "n"], ids=lambda yn: f"docker:{yn}") @pytest.mark.parametrize("use_celery", ["y", "n"], ids=lambda yn: f"celery:{yn}") From 37ec5a45bbbab1e3b00e191264e5b3af6e6eb2af Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Mon, 3 Feb 2020 12:56:37 +0000 Subject: [PATCH 008/182] Remove pyup filter --- {{cookiecutter.project_slug}}/requirements/base.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/base.txt b/{{cookiecutter.project_slug}}/requirements/base.txt index 35727e1a..5427f1d0 100644 --- a/{{cookiecutter.project_slug}}/requirements/base.txt +++ b/{{cookiecutter.project_slug}}/requirements/base.txt @@ -8,7 +8,7 @@ argon2-cffi==19.2.0 # https://github.com/hynek/argon2_cffi {%- if cookiecutter.use_whitenoise == 'y' %} whitenoise==5.0.1 # https://github.com/evansd/whitenoise {%- endif %} -redis==3.4.1 # pyup: != 3.4.0 # https://github.com/andymccurdy/redis-py +redis==3.4.1 # https://github.com/andymccurdy/redis-py {%- if cookiecutter.use_celery == "y" %} celery==4.4.0 # pyup: < 5.0 # https://github.com/celery/celery django-celery-beat==1.6.0 # https://github.com/celery/django-celery-beat From 8fd0d42de0e7c3c8fea92bb4d1d2df3e4af6aa31 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Mon, 3 Feb 2020 14:29:20 +0000 Subject: [PATCH 009/182] Don't include POSTGRES_... environment in the PyCharm start script when not using Docker --- {{cookiecutter.project_slug}}/.idea/workspace.xml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/.idea/workspace.xml b/{{cookiecutter.project_slug}}/.idea/workspace.xml index a5d73c18..deb28ba1 100644 --- a/{{cookiecutter.project_slug}}/.idea/workspace.xml +++ b/{{cookiecutter.project_slug}}/.idea/workspace.xml @@ -1,6 +1,11 @@ - {%- if cookiecutter.use_celery == 'y' %} + {%- if cookiecutter.use_docker == 'n' %} + + + {%- elif cookiecutter.use_celery == 'y' %} From e9c6b3d9e9243a96814ce71c41809c302c86c4d7 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Tue, 4 Feb 2020 11:00:30 +0000 Subject: [PATCH 010/182] Update django-storages from 1.9 to 1.9.1 --- {{cookiecutter.project_slug}}/requirements/production.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/production.txt b/{{cookiecutter.project_slug}}/requirements/production.txt index 0f21e11a..7b8e4b49 100644 --- a/{{cookiecutter.project_slug}}/requirements/production.txt +++ b/{{cookiecutter.project_slug}}/requirements/production.txt @@ -14,7 +14,7 @@ sentry-sdk==0.14.1 # https://github.com/getsentry/sentry-python # Django # ------------------------------------------------------------------------------ {%- if cookiecutter.cloud_provider == 'AWS' %} -django-storages[boto3]==1.9 # https://github.com/jschneier/django-storages +django-storages[boto3]==1.9.1 # https://github.com/jschneier/django-storages {%- elif cookiecutter.cloud_provider == 'GCP' %} django-storages[google]==1.9 # https://github.com/jschneier/django-storages {%- endif %} From c7a6dbdd1039dbb4f349a39a2082e8973f69b6f2 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Tue, 4 Feb 2020 11:00:31 +0000 Subject: [PATCH 011/182] Update django-storages from 1.9 to 1.9.1 --- {{cookiecutter.project_slug}}/requirements/production.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/production.txt b/{{cookiecutter.project_slug}}/requirements/production.txt index 7b8e4b49..9c1de827 100644 --- a/{{cookiecutter.project_slug}}/requirements/production.txt +++ b/{{cookiecutter.project_slug}}/requirements/production.txt @@ -16,6 +16,6 @@ sentry-sdk==0.14.1 # https://github.com/getsentry/sentry-python {%- if cookiecutter.cloud_provider == 'AWS' %} django-storages[boto3]==1.9.1 # https://github.com/jschneier/django-storages {%- elif cookiecutter.cloud_provider == 'GCP' %} -django-storages[google]==1.9 # https://github.com/jschneier/django-storages +django-storages[google]==1.9.1 # https://github.com/jschneier/django-storages {%- endif %} django-anymail[mailgun]==7.0.0 # https://github.com/anymail/django-anymail From 86c9b3cb282a4e0fc9a47b2ffa991fbc72486b20 Mon Sep 17 00:00:00 2001 From: Demetris Stavrou <1180929+demestav@users.noreply.github.com> Date: Tue, 4 Feb 2020 15:04:47 +0200 Subject: [PATCH 012/182] Flower now served by Traefik --- .../compose/production/traefik/traefik.yml | 19 ++++++++++++++++++- {{cookiecutter.project_slug}}/production.yml | 2 -- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/{{cookiecutter.project_slug}}/compose/production/traefik/traefik.yml b/{{cookiecutter.project_slug}}/compose/production/traefik/traefik.yml index 324c62af..bb3be150 100644 --- a/{{cookiecutter.project_slug}}/compose/production/traefik/traefik.yml +++ b/{{cookiecutter.project_slug}}/compose/production/traefik/traefik.yml @@ -10,6 +10,9 @@ entryPoints: # https address: ":443" + flower: + address: ":5555" + certificatesResolvers: letsencrypt: # https://docs.traefik.io/master/https/acme/#lets-encrypt @@ -42,6 +45,15 @@ http: # https://docs.traefik.io/master/routing/routers/#certresolver certResolver: letsencrypt + flower-secure-router: + rule: "Host(`{{ cookiecutter.domain_name }}`)" + entryPoints: + - flower + service: flower + tls: + # https://docs.traefik.io/master/routing/routers/#certresolver + certResolver: letsencrypt + middlewares: redirect: # https://docs.traefik.io/master/middlewares/redirectscheme/ @@ -52,7 +64,7 @@ http: # https://docs.traefik.io/master/middlewares/headers/#hostsproxyheaders # https://docs.djangoproject.com/en/dev/ref/csrf/#ajax headers: - hostsProxyHeaders: ['X-CSRFToken'] + hostsProxyHeaders: ["X-CSRFToken"] services: django: @@ -60,6 +72,11 @@ http: servers: - url: http://django:5000 + flower: + loadBalancer: + servers: + - url: http://flower:5555 + providers: # https://docs.traefik.io/master/providers/file/ file: diff --git a/{{cookiecutter.project_slug}}/production.yml b/{{cookiecutter.project_slug}}/production.yml index 62ec9d82..125d4876 100644 --- a/{{cookiecutter.project_slug}}/production.yml +++ b/{{cookiecutter.project_slug}}/production.yml @@ -60,8 +60,6 @@ services: flower: <<: *django image: {{ cookiecutter.project_slug }}_production_flower - ports: - - "5555:5555" command: /start-flower {%- endif %} From 25a70c5b846f7e17ff416385decbc0bd16251797 Mon Sep 17 00:00:00 2001 From: Demetris Stavrou <1180929+demestav@users.noreply.github.com> Date: Tue, 4 Feb 2020 22:47:56 +0200 Subject: [PATCH 013/182] Added Flower access documentation for production. --- docs/deployment-with-docker.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/deployment-with-docker.rst b/docs/deployment-with-docker.rst index 0df50ff4..8a206885 100644 --- a/docs/deployment-with-docker.rst +++ b/docs/deployment-with-docker.rst @@ -25,7 +25,9 @@ Provided you have opted for Celery (via setting ``use_celery`` to ``y``) there a * ``celeryworker`` running a Celery worker process; * ``celerybeat`` running a Celery beat process; -* ``flower`` running Flower_ (for more info, check out :ref:`CeleryFlower` instructions for local environment). +* ``flower`` running Flower_. + +The ``flower`` service is served by Traefik over HTTPS, through the port ``5555``. For more information about Flower and its login credentials, check out :ref:`CeleryFlower` instructions for local environment. .. _`Flower`: https://github.com/mher/flower From 45c353241b06391d9778b0abec411e55bbb505a7 Mon Sep 17 00:00:00 2001 From: Leonardo Date: Thu, 6 Feb 2020 05:37:31 -0400 Subject: [PATCH 014/182] Include `use_drf` option on documentation --- docs/project-generation-options.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/project-generation-options.rst b/docs/project-generation-options.rst index ae47b097..2ed77fac 100644 --- a/docs/project-generation-options.rst +++ b/docs/project-generation-options.rst @@ -70,6 +70,9 @@ cloud_provider: Note that if you choose no cloud provider, media files won't work. +use_drf: + Indicates whether the project should be configured to use `Django Rest Framework`_. + custom_bootstrap_compilation: Indicates whether the project should support Bootstrap recompilation via the selected JavaScript task runner's task. This can be useful @@ -129,6 +132,8 @@ debug: .. _AWS: https://aws.amazon.com/s3/ .. _GCP: https://cloud.google.com/storage/ +.. _Django Rest Framework: https://github.com/encode/django-rest-framework/ + .. _Django Compressor: https://github.com/django-compressor/django-compressor .. _Celery: https://github.com/celery/celery From 6709fc64c9f16d534a2f156b48425061ec01c7a8 Mon Sep 17 00:00:00 2001 From: Andrew-Chen-Wang Date: Thu, 6 Feb 2020 15:17:46 -0500 Subject: [PATCH 015/182] Added all supported Anymail Providers in cookiecutter.json * Utilizes {% if %} since it's financially more wise to use AWS SES only if AWS is the cloud provider. * FIXME: If AWS is not cloud provider, there are two None options. This may require a little hack inside of cookiecutter that I may not be aware of. --- cookiecutter.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cookiecutter.json b/cookiecutter.json index 4e77d110..5efa745e 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -33,6 +33,18 @@ "GCP", "None" ], + "mail_service": [ + "{% if cookiecutter.cloud_provider == 'AWS' %}Amazon SES{% else %}Mailgun{% endif %}", + "{% if cookiecutter.cloud_provider == 'AWS' %}Mailgun{% else %}Mailjet{% endif %}", + "{% if cookiecutter.cloud_provider == 'AWS' %}Mailjet{% else %}Mandrill{% endif %}", + "{% if cookiecutter.cloud_provider == 'AWS' %}Mandrill{% else %}Postmark{% endif %}", + "{% if cookiecutter.cloud_provider == 'AWS' %}Postmark{% else %}Sendgrid{% endif %}", + "{% if cookiecutter.cloud_provider == 'AWS' %}Sendgrid{% else %}SendinBlue{% endif %}", + "{% if cookiecutter.cloud_provider == 'AWS' %}SendinBlue{% else %}SparkPost{% endif %}", + "{% if cookiecutter.cloud_provider == 'AWS' %}SparkPost{% else %}Plain Django-Anymail{% endif %}", + "{% if cookiecutter.cloud_provider == 'AWS' %}Plain Django-Anymail{% else %}None{% endif %}", + "{% if cookiecutter.cloud_provider == 'AWS' %}None{% else %}None{% endif %}" + ], "use_drf": "n", "custom_bootstrap_compilation": "n", "use_compressor": "n", From b7d3379f4405e38df62fe097b10a3df2a608e9a5 Mon Sep 17 00:00:00 2001 From: Andrew-Chen-Wang Date: Thu, 6 Feb 2020 15:36:51 -0500 Subject: [PATCH 016/182] Fixes the duplicate None in cookiecutter.json * The duplicate occurs if AWS is not the selected cloud provider --- cookiecutter.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cookiecutter.json b/cookiecutter.json index 5efa745e..cbe3cbf7 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -34,16 +34,16 @@ "None" ], "mail_service": [ - "{% if cookiecutter.cloud_provider == 'AWS' %}Amazon SES{% else %}Mailgun{% endif %}", - "{% if cookiecutter.cloud_provider == 'AWS' %}Mailgun{% else %}Mailjet{% endif %}", - "{% if cookiecutter.cloud_provider == 'AWS' %}Mailjet{% else %}Mandrill{% endif %}", - "{% if cookiecutter.cloud_provider == 'AWS' %}Mandrill{% else %}Postmark{% endif %}", - "{% if cookiecutter.cloud_provider == 'AWS' %}Postmark{% else %}Sendgrid{% endif %}", - "{% if cookiecutter.cloud_provider == 'AWS' %}Sendgrid{% else %}SendinBlue{% endif %}", - "{% if cookiecutter.cloud_provider == 'AWS' %}SendinBlue{% else %}SparkPost{% endif %}", - "{% if cookiecutter.cloud_provider == 'AWS' %}SparkPost{% else %}Plain Django-Anymail{% endif %}", - "{% if cookiecutter.cloud_provider == 'AWS' %}Plain Django-Anymail{% else %}None{% endif %}", - "{% if cookiecutter.cloud_provider == 'AWS' %}None{% else %}None{% endif %}" + {% if cookiecutter.cloud_provider == 'AWS' %}"Amazon SES",{% endif %} + "Mailgun", + "Mailjet", + "Mandrill", + "Postmark", + "Sendgrid", + "SendinBlue", + "SparkPost", + "Plain/Vanilla Django-Anymail", + "None" ], "use_drf": "n", "custom_bootstrap_compilation": "n", From 575dead7cb3e7c04ff7d7133575af32540c94bbf Mon Sep 17 00:00:00 2001 From: Andrew-Chen-Wang Date: Thu, 6 Feb 2020 16:00:32 -0500 Subject: [PATCH 017/182] More concise cookiecutter.json; removed several if statements * Unfortunately, with https://github.com/pydanny/cookiecutter-django/pull/2321#issuecomment-558796906, I don't think I am going to add AWS SES specifically if AWS is not chosen as cloud provider. In that case, we'll just deal with 2 None's when AWS is not selected. * FIXME 2 Nones --- cookiecutter.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookiecutter.json b/cookiecutter.json index cbe3cbf7..ae0576b5 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -34,7 +34,7 @@ "None" ], "mail_service": [ - {% if cookiecutter.cloud_provider == 'AWS' %}"Amazon SES",{% endif %} + "{% if cookiecutter.cloud_provider == 'AWS' %}Amazon SES{% else %}None{% endif %}", "Mailgun", "Mailjet", "Mandrill", From c8eb5462eb921313d3fbb9a9957125022d444cd3 Mon Sep 17 00:00:00 2001 From: Andrew-Chen-Wang Date: Thu, 6 Feb 2020 16:58:15 -0500 Subject: [PATCH 018/182] Configurations and Packages added * Production settings updated for all * Added env vars from production settings * Added packages requirements.txt --- .../.envs/.production/.django | 19 ++++++- .../config/settings/production.py | 52 ++++++++++++++++++- .../requirements/production.txt | 18 +++++++ 3 files changed, 87 insertions(+), 2 deletions(-) diff --git a/{{cookiecutter.project_slug}}/.envs/.production/.django b/{{cookiecutter.project_slug}}/.envs/.production/.django index 2c2e94f2..358b5e95 100644 --- a/{{cookiecutter.project_slug}}/.envs/.production/.django +++ b/{{cookiecutter.project_slug}}/.envs/.production/.django @@ -13,9 +13,26 @@ DJANGO_SECURE_SSL_REDIRECT=False # Email # ------------------------------------------------------------------------------ -MAILGUN_API_KEY= DJANGO_SERVER_EMAIL= +{% if cookiecutter.mail_service == 'Mailgun' %} +MAILGUN_API_KEY= MAILGUN_DOMAIN= +{% elif cookiecutter.mail_service == 'Mailjet' %} +MAILJET_API_KEY= +MAILJET_SECRET_KEY= +{% elif cookiecutter.mail_service == 'Mandrill' %} +MANDRILL_API_KEY= +{% elif cookiecutter.mail_service == 'Postmark' %} +POSTMARK_SERVER_TOKEN= +{% elif cookiecutter.mail_service == 'Sendgrid' %} +SENDGRID_API_KEY= +SENDGRID_GENERATE_MESSAGE_ID=True +SENDGRID_MERGE_FIELD_FORMAT=None +{% elif cookiecutter.mail_service == 'SendinBlue' %} +SENDINBLUE_API_KEY= +{% elif cookiecutter.mail_service == 'SparkPost' %} +SPARKPOST_API_KEY= +{% endif %} {% if cookiecutter.cloud_provider == 'AWS' %} # AWS # ------------------------------------------------------------------------------ diff --git a/{{cookiecutter.project_slug}}/config/settings/production.py b/{{cookiecutter.project_slug}}/config/settings/production.py index 36667b33..e0af4c59 100644 --- a/{{cookiecutter.project_slug}}/config/settings/production.py +++ b/{{cookiecutter.project_slug}}/config/settings/production.py @@ -182,16 +182,66 @@ EMAIL_SUBJECT_PREFIX = env( # Django Admin URL regex. ADMIN_URL = env("DJANGO_ADMIN_URL") -# Anymail (Mailgun) +# Anymail # ------------------------------------------------------------------------------ # https://anymail.readthedocs.io/en/stable/installation/#installing-anymail INSTALLED_APPS += ["anymail"] # noqa F405 +{%- if cookiecutter.mail_service == 'Amazon SES' %} +EMAIL_BACKEND = "anymail.backends.amazon_ses.EmailBackend" +# https://anymail.readthedocs.io/en/stable/esps/amazon_ses/ +{%- elif cookiecutter.mail_service == 'Mailgun' %} EMAIL_BACKEND = "anymail.backends.mailgun.EmailBackend" +# https://anymail.readthedocs.io/en/stable/esps/mailgun/ +{%- elif cookiecutter.mail_service == 'Mailjet' %} +EMAIL_BACKEND = "anymail.backends.mailjet.EmailBackend" +# https://anymail.readthedocs.io/en/stable/esps/mailjet/ +{%- elif cookiecutter.mail_service == 'Mandrill' %} +EMAIL_BACKEND = "anymail.backends.mandrill.EmailBackend" +# https://anymail.readthedocs.io/en/stable/esps/mandrill/ +{%- elif cookiecutter.mail_service == 'Postmark' %} +EMAIL_BACKEND = "anymail.backends.postmark.EmailBackend" +# https://anymail.readthedocs.io/en/stable/esps/postmark/ +{%- elif cookiecutter.mail_service == 'Sendgrid' %} +EMAIL_BACKEND = "anymail.backends.sendgrid.EmailBackend" +# https://anymail.readthedocs.io/en/stable/esps/sendgrid/ +{%- elif cookiecutter.mail_service == 'SendinBlue' %} +EMAIL_BACKEND = "anymail.backends.sendinblue.EmailBackend" +# https://anymail.readthedocs.io/en/stable/esps/sendinblue/ +{%- elif cookiecutter.mail_service == 'SparkPost' %} +EMAIL_BACKEND = "anymail.backends.sparkpost.EmailBackend" +# https://anymail.readthedocs.io/en/stable/esps/sparkpost/ +{%- elif cookiecutter.mail_service == 'Plain/Vanilla Django-Anymail' %} +EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend" +# https://docs.djangoproject.com/en/3.0/ref/settings/#email-backend +{%- endif %} # https://anymail.readthedocs.io/en/stable/installation/#anymail-settings-reference ANYMAIL = { + {%- if cookiecutter.mail_service == 'Mailgun' %} "MAILGUN_API_KEY": env("MAILGUN_API_KEY"), "MAILGUN_SENDER_DOMAIN": env("MAILGUN_DOMAIN"), "MAILGUN_API_URL": env("MAILGUN_API_URL", default="https://api.mailgun.net/v3"), + {%- elif cookiecutter.mail_service == 'Mailjet' %} + "MAILJET_API_KEY": env("MAILJET_API_KEY"), + "MAILJET_SECRET_KEY": env("MAILJET_SECRET_KEY"), + "MAILJET_API_URL": env("MAILJET_API_URL", default="https://api.mailjet.com/v3"), + {%- elif cookiecutter.mail_service == 'Mandrill' %} + "MANDRILL_API_KEY": env("MANDRILL_API_KEY"), + "MANDRILL_API_URL": env("MANDRILL_API_URL", default="https://mandrillapp.com/api/1.0"), + {%- elif cookiecutter.mail_service == 'Postmark' %} + "POSTMARK_SERVER_TOKEN": env("POSTMARK_SERVER_TOKEN"), + "POSTMARK_API_URL": env("POSTMARK_API_URL", default="https://api.postmarkapp.com/"), + {%- elif cookiecutter.mail_service == 'Sendgrid' %} + "SENDGRID_API_KEY": env("SENDGRID_API_KEY"), + "SENDGRID_GENERATE_MESSAGE_ID": env("SENDGRID_GENERATE_MESSAGE_ID"), + "SENDGRID_MERGE_FIELD_FORMAT": env("SENDGRID_MERGE_FIELD_FORMAT"), + "SENDGRID_API_URL": env("SENDGRID_API_URL", default="https://api.sendgrid.com/v3/"), + {%- elif cookiecutter.mail_service == 'SendinBlue' %} + "SENDINBLUE_API_KEY": env("SENDINBLUE_API_KEY"), + "SENDINBLUE_API_URL": env("SENDINBLUE_API_URL", default="https://api.sendinblue.com/v3/"), + {%- elif cookiecutter.mail_service == 'SparkPost' %} + "SPARKPOST_API_KEY": env("SPARKPOST_API_KEY"), + "SPARKPOST_API_URL": env("SPARKPOST_API_URL", default="https://api.sparkpost.com/api/v1"), + {%- endif %} } {% if cookiecutter.use_compressor == 'y' -%} diff --git a/{{cookiecutter.project_slug}}/requirements/production.txt b/{{cookiecutter.project_slug}}/requirements/production.txt index 9c1de827..3e1d8515 100644 --- a/{{cookiecutter.project_slug}}/requirements/production.txt +++ b/{{cookiecutter.project_slug}}/requirements/production.txt @@ -18,4 +18,22 @@ django-storages[boto3]==1.9.1 # https://github.com/jschneier/django-storages {%- elif cookiecutter.cloud_provider == 'GCP' %} django-storages[google]==1.9.1 # https://github.com/jschneier/django-storages {%- endif %} +{%- if cookiecutter.mail_service == 'Amazon SES' %} +django-anymail[amazon_ses]==7.0.0 # https://github.com/anymail/django-anymail +{%- elif cookiecutter.mail_service == 'Mailgun' %} django-anymail[mailgun]==7.0.0 # https://github.com/anymail/django-anymail +{%- elif cookiecutter.mail_service == 'Mailjet' %} +django-anymail[mailjet]==7.0.0 # https://github.com/anymail/django-anymail +{%- elif cookiecutter.mail_service == 'Mandrill' %} +django-anymail[mandrill]==7.0.0 # https://github.com/anymail/django-anymail +{%- elif cookiecutter.mail_service == 'Postmark' %} +django-anymail[postmark]==7.0.0 # https://github.com/anymail/django-anymail +{%- elif cookiecutter.mail_service == 'Sendgrid' %} +django-anymail[sendgrid]==7.0.0 # https://github.com/anymail/django-anymail +{%- elif cookiecutter.mail_service == 'SendinBlue' %} +django-anymail[sendinblue]==7.0.0 # https://github.com/anymail/django-anymail +{%- elif cookiecutter.mail_service == 'SparkPost' %} +django-anymail[sparkpost]==7.0.0 # https://github.com/anymail/django-anymail +{%- elif cookiecutter.mail_service == 'Plain/Vanilla Django-Anymail' %} +django-anymail==7.0.0 # https://github.com/anymail/django-anymail +{%- endif %} From fecf9e0037885bac16228ac3bd8060f04f83375b Mon Sep 17 00:00:00 2001 From: Andrew-Chen-Wang Date: Thu, 6 Feb 2020 16:59:42 -0500 Subject: [PATCH 019/182] Add @Andrew-Chen-Wang to CONTRIBUTORS --- CONTRIBUTORS.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index 2554d2cf..6dca6ddb 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -56,6 +56,7 @@ Listed in alphabetical order. Andreas Meistad `@ameistad`_ Andres Gonzalez `@andresgz`_ Andrew Mikhnevich `@zcho`_ + Andrew Chen Wang `@Andrew-Chen-Wang`_ Andy Rose Anna Callahan `@jazztpt`_ Anna Sidwell `@takkaria`_ @@ -228,6 +229,7 @@ Listed in alphabetical order. .. _@andor-pierdelacabeza: https://github.com/andor-pierdelacabeza .. _@andresgz: https://github.com/andresgz .. _@antoniablair: https://github.com/antoniablair +.. _@Andrew-Chen-Wang: https://github.com/Andrew-Chen-Wang .. _@apirobot: https://github.com/apirobot .. _@archinal: https://github.com/archinal .. _@areski: https://github.com/areski From 0621929cd2889892106d853a9a2cd3b0a491f73c Mon Sep 17 00:00:00 2001 From: Andrew-Chen-Wang Date: Thu, 6 Feb 2020 18:41:30 -0500 Subject: [PATCH 020/182] Removed None option for mail service * This is necessary in order to be compatible with Django-allauth --- cookiecutter.json | 5 ++--- .../config/settings/production.py | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cookiecutter.json b/cookiecutter.json index ae0576b5..5e85af48 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -34,7 +34,7 @@ "None" ], "mail_service": [ - "{% if cookiecutter.cloud_provider == 'AWS' %}Amazon SES{% else %}None{% endif %}", + "{% if cookiecutter.cloud_provider == 'AWS' %}Amazon SES{% else %}Plain/Vanilla Django-Anymail{% endif %}", "Mailgun", "Mailjet", "Mandrill", @@ -42,8 +42,7 @@ "Sendgrid", "SendinBlue", "SparkPost", - "Plain/Vanilla Django-Anymail", - "None" + "Plain/Vanilla Django-Anymail" ], "use_drf": "n", "custom_bootstrap_compilation": "n", diff --git a/{{cookiecutter.project_slug}}/config/settings/production.py b/{{cookiecutter.project_slug}}/config/settings/production.py index e0af4c59..6d431800 100644 --- a/{{cookiecutter.project_slug}}/config/settings/production.py +++ b/{{cookiecutter.project_slug}}/config/settings/production.py @@ -188,59 +188,60 @@ ADMIN_URL = env("DJANGO_ADMIN_URL") INSTALLED_APPS += ["anymail"] # noqa F405 {%- if cookiecutter.mail_service == 'Amazon SES' %} EMAIL_BACKEND = "anymail.backends.amazon_ses.EmailBackend" -# https://anymail.readthedocs.io/en/stable/esps/amazon_ses/ {%- elif cookiecutter.mail_service == 'Mailgun' %} EMAIL_BACKEND = "anymail.backends.mailgun.EmailBackend" -# https://anymail.readthedocs.io/en/stable/esps/mailgun/ {%- elif cookiecutter.mail_service == 'Mailjet' %} EMAIL_BACKEND = "anymail.backends.mailjet.EmailBackend" -# https://anymail.readthedocs.io/en/stable/esps/mailjet/ {%- elif cookiecutter.mail_service == 'Mandrill' %} EMAIL_BACKEND = "anymail.backends.mandrill.EmailBackend" -# https://anymail.readthedocs.io/en/stable/esps/mandrill/ {%- elif cookiecutter.mail_service == 'Postmark' %} EMAIL_BACKEND = "anymail.backends.postmark.EmailBackend" -# https://anymail.readthedocs.io/en/stable/esps/postmark/ {%- elif cookiecutter.mail_service == 'Sendgrid' %} EMAIL_BACKEND = "anymail.backends.sendgrid.EmailBackend" -# https://anymail.readthedocs.io/en/stable/esps/sendgrid/ {%- elif cookiecutter.mail_service == 'SendinBlue' %} EMAIL_BACKEND = "anymail.backends.sendinblue.EmailBackend" -# https://anymail.readthedocs.io/en/stable/esps/sendinblue/ {%- elif cookiecutter.mail_service == 'SparkPost' %} EMAIL_BACKEND = "anymail.backends.sparkpost.EmailBackend" -# https://anymail.readthedocs.io/en/stable/esps/sparkpost/ {%- elif cookiecutter.mail_service == 'Plain/Vanilla Django-Anymail' %} EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend" # https://docs.djangoproject.com/en/3.0/ref/settings/#email-backend {%- endif %} # https://anymail.readthedocs.io/en/stable/installation/#anymail-settings-reference ANYMAIL = { - {%- if cookiecutter.mail_service == 'Mailgun' %} + {%- if cookiecutter.mail_service == 'Amazon SES' %} + # https://anymail.readthedocs.io/en/stable/esps/amazon_ses/ + {%- elif cookiecutter.mail_service == 'Mailgun' %} "MAILGUN_API_KEY": env("MAILGUN_API_KEY"), "MAILGUN_SENDER_DOMAIN": env("MAILGUN_DOMAIN"), "MAILGUN_API_URL": env("MAILGUN_API_URL", default="https://api.mailgun.net/v3"), + # https://anymail.readthedocs.io/en/stable/esps/mailgun/ {%- elif cookiecutter.mail_service == 'Mailjet' %} "MAILJET_API_KEY": env("MAILJET_API_KEY"), "MAILJET_SECRET_KEY": env("MAILJET_SECRET_KEY"), "MAILJET_API_URL": env("MAILJET_API_URL", default="https://api.mailjet.com/v3"), + # https://anymail.readthedocs.io/en/stable/esps/mailjet/ {%- elif cookiecutter.mail_service == 'Mandrill' %} "MANDRILL_API_KEY": env("MANDRILL_API_KEY"), "MANDRILL_API_URL": env("MANDRILL_API_URL", default="https://mandrillapp.com/api/1.0"), + # https://anymail.readthedocs.io/en/stable/esps/mandrill/ {%- elif cookiecutter.mail_service == 'Postmark' %} "POSTMARK_SERVER_TOKEN": env("POSTMARK_SERVER_TOKEN"), "POSTMARK_API_URL": env("POSTMARK_API_URL", default="https://api.postmarkapp.com/"), + # https://anymail.readthedocs.io/en/stable/esps/postmark/ {%- elif cookiecutter.mail_service == 'Sendgrid' %} "SENDGRID_API_KEY": env("SENDGRID_API_KEY"), "SENDGRID_GENERATE_MESSAGE_ID": env("SENDGRID_GENERATE_MESSAGE_ID"), "SENDGRID_MERGE_FIELD_FORMAT": env("SENDGRID_MERGE_FIELD_FORMAT"), "SENDGRID_API_URL": env("SENDGRID_API_URL", default="https://api.sendgrid.com/v3/"), + # https://anymail.readthedocs.io/en/stable/esps/sendgrid/ {%- elif cookiecutter.mail_service == 'SendinBlue' %} "SENDINBLUE_API_KEY": env("SENDINBLUE_API_KEY"), "SENDINBLUE_API_URL": env("SENDINBLUE_API_URL", default="https://api.sendinblue.com/v3/"), + # https://anymail.readthedocs.io/en/stable/esps/sendinblue/ {%- elif cookiecutter.mail_service == 'SparkPost' %} "SPARKPOST_API_KEY": env("SPARKPOST_API_KEY"), "SPARKPOST_API_URL": env("SPARKPOST_API_URL", default="https://api.sparkpost.com/api/v1"), + # https://anymail.readthedocs.io/en/stable/esps/sparkpost/ {%- endif %} } From ac884f3f75fa7f5b25f6a754a452193cd037b318 Mon Sep 17 00:00:00 2001 From: Andrew-Chen-Wang Date: Thu, 6 Feb 2020 20:18:49 -0500 Subject: [PATCH 021/182] Updated mail service docs * Trying to appease the Black-linter god... --- README.rst | 4 +-- docs/project-generation-options.rst | 23 ++++++++++++ docs/settings.rst | 15 ++++++++ .../config/settings/production.py | 36 +++++++++++++++---- 4 files changed, 69 insertions(+), 9 deletions(-) diff --git a/README.rst b/README.rst index 6e534b0f..1d43b84e 100644 --- a/README.rst +++ b/README.rst @@ -46,7 +46,7 @@ Features * Registration via django-allauth_ * Comes with custom user model ready to go * Optional custom static build using Gulp and livereload -* Send emails via Anymail_ (using Mailgun_ by default, but switchable) +* Send emails via Anymail_ (using Mailgun_ by default or Amazon SES if AWS is selected cloud provider, but switchable) * Media storage using Amazon S3 or Google Cloud Storage * Docker support using docker-compose_ for development and production (using Traefik_ with LetsEncrypt_ support) * Procfile_ for deploying to Heroku @@ -85,7 +85,7 @@ Optional Integrations .. _PythonAnywhere: https://www.pythonanywhere.com/ .. _Traefik: https://traefik.io/ .. _LetsEncrypt: https://letsencrypt.org/ -.. _pre-commit: https://github.com/pre-commit/pre-commit +.. _pre-commit: https://github.com/pre-commit/pre-commit Constraints ----------- diff --git a/docs/project-generation-options.rst b/docs/project-generation-options.rst index 2ed77fac..87ae90b1 100644 --- a/docs/project-generation-options.rst +++ b/docs/project-generation-options.rst @@ -70,6 +70,19 @@ cloud_provider: Note that if you choose no cloud provider, media files won't work. +mail_service: + Select an email service that Django-Anymail provides + + 1. Amazon SES_ + 2. Mailgun_ + 3. Mailjet_ + 4. Mandrill_ + 5. Postmark_ + 6. SendGrid_ + 7. SendinBlue_ + 8. SparkPost_ + 9. Plain/Vanilla Django-Anymail_ + use_drf: Indicates whether the project should be configured to use `Django Rest Framework`_. @@ -132,6 +145,16 @@ debug: .. _AWS: https://aws.amazon.com/s3/ .. _GCP: https://cloud.google.com/storage/ +.. _SES: https://aws.amazon.com/ses/ +.. _Mailgun: https://www.mailgun.com +.. _Mailjet: https://www.mailjet.com +.. _Mandrill: http://mandrill.com +.. _Postmark: https://postmarkapp.com +.. _SendGrid: https://sendgrid.com +.. _SendinBlue: https://www.sendinblue.com +.. _SparkPost: https://www.sparkpost.com +.. _Django-Anymail: https://anymail.readthedocs.io/en/stable/ + .. _Django Rest Framework: https://github.com/encode/django-rest-framework/ .. _Django Compressor: https://github.com/django-compressor/django-compressor diff --git a/docs/settings.rst b/docs/settings.rst index e586c963..2ae8814e 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -52,6 +52,21 @@ DJANGO_SENTRY_LOG_LEVEL SENTRY_LOG_LEVEL n/a MAILGUN_API_KEY MAILGUN_API_KEY n/a raises error MAILGUN_DOMAIN MAILGUN_SENDER_DOMAIN n/a raises error MAILGUN_API_URL n/a n/a "https://api.mailgun.net/v3" +MAILJET_API_KEY MAILJET_API_KEY n/a raises error +MAILJET_SECRET_KEY MAILJET_SECRET_KEY n/a raises error +MAILJET_API_URL n/a n/a "https://api.mailjet.com/v3" +MANDRILL_API_KEY MANDRILL_API_KEY n/a raises error +MANDRILL_API_URL n/a n/a "https://mandrillapp.com/api/1.0" +POSTMARK_SERVER_TOKEN POSTMARK_SERVER_TOKEN n/a raises error +POSTMARK_API_URL n/a n/a "https://api.postmarkapp.com/" +SENDGRID_API_KEY SENDGRID_API_KEY n/a raises error +SENDGRID_GENERATE_MESSAGE_ID True n/a raises error +SENDGRID_MERGE_FIELD_FORMAT None n/a raises error +SENDGRID_API_URL n/a n/a "https://api.sendgrid.com/v3/" +SENDINBLUE_API_KEY SENDINBLUE_API_KEY n/a raises error +SENDINBLUE_API_URL n/a n/a "https://api.sendinblue.com/v3/" +SPARKPOST_API_KEY SPARKPOST_API_KEY n/a raises error +SPARKPOST_API_URL n/a n/a "https://api.sparkpost.com/api/v1" ======================================= =========================== ============================================== ====================================================================== -------------------------- diff --git a/{{cookiecutter.project_slug}}/config/settings/production.py b/{{cookiecutter.project_slug}}/config/settings/production.py index 6d431800..57b8eb39 100644 --- a/{{cookiecutter.project_slug}}/config/settings/production.py +++ b/{{cookiecutter.project_slug}}/config/settings/production.py @@ -208,39 +208,61 @@ EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend" {%- endif %} # https://anymail.readthedocs.io/en/stable/installation/#anymail-settings-reference ANYMAIL = { + # https://anymail.readthedocs.io/en/stable/esps/ {%- if cookiecutter.mail_service == 'Amazon SES' %} # https://anymail.readthedocs.io/en/stable/esps/amazon_ses/ {%- elif cookiecutter.mail_service == 'Mailgun' %} "MAILGUN_API_KEY": env("MAILGUN_API_KEY"), "MAILGUN_SENDER_DOMAIN": env("MAILGUN_DOMAIN"), - "MAILGUN_API_URL": env("MAILGUN_API_URL", default="https://api.mailgun.net/v3"), + "MAILGUN_API_URL": env( + "MAILGUN_API_URL", + default="https://api.mailgun.net/v3" + ), # https://anymail.readthedocs.io/en/stable/esps/mailgun/ {%- elif cookiecutter.mail_service == 'Mailjet' %} "MAILJET_API_KEY": env("MAILJET_API_KEY"), "MAILJET_SECRET_KEY": env("MAILJET_SECRET_KEY"), - "MAILJET_API_URL": env("MAILJET_API_URL", default="https://api.mailjet.com/v3"), + "MAILJET_API_URL": env( + "MAILJET_API_URL", + default="https://api.mailjet.com/v3" + ), # https://anymail.readthedocs.io/en/stable/esps/mailjet/ {%- elif cookiecutter.mail_service == 'Mandrill' %} "MANDRILL_API_KEY": env("MANDRILL_API_KEY"), - "MANDRILL_API_URL": env("MANDRILL_API_URL", default="https://mandrillapp.com/api/1.0"), + "MANDRILL_API_URL": env( + "MANDRILL_API_URL", + default="https://mandrillapp.com/api/1.0" + ), # https://anymail.readthedocs.io/en/stable/esps/mandrill/ {%- elif cookiecutter.mail_service == 'Postmark' %} "POSTMARK_SERVER_TOKEN": env("POSTMARK_SERVER_TOKEN"), - "POSTMARK_API_URL": env("POSTMARK_API_URL", default="https://api.postmarkapp.com/"), + "POSTMARK_API_URL": env( + "POSTMARK_API_URL", + default="https://api.postmarkapp.com/" + ), # https://anymail.readthedocs.io/en/stable/esps/postmark/ {%- elif cookiecutter.mail_service == 'Sendgrid' %} "SENDGRID_API_KEY": env("SENDGRID_API_KEY"), "SENDGRID_GENERATE_MESSAGE_ID": env("SENDGRID_GENERATE_MESSAGE_ID"), "SENDGRID_MERGE_FIELD_FORMAT": env("SENDGRID_MERGE_FIELD_FORMAT"), - "SENDGRID_API_URL": env("SENDGRID_API_URL", default="https://api.sendgrid.com/v3/"), + "SENDGRID_API_URL": env( + "SENDGRID_API_URL", + default="https://api.sendgrid.com/v3/" + ), # https://anymail.readthedocs.io/en/stable/esps/sendgrid/ {%- elif cookiecutter.mail_service == 'SendinBlue' %} "SENDINBLUE_API_KEY": env("SENDINBLUE_API_KEY"), - "SENDINBLUE_API_URL": env("SENDINBLUE_API_URL", default="https://api.sendinblue.com/v3/"), + "SENDINBLUE_API_URL": env( + "SENDINBLUE_API_URL", + default="https://api.sendinblue.com/v3/" + ), # https://anymail.readthedocs.io/en/stable/esps/sendinblue/ {%- elif cookiecutter.mail_service == 'SparkPost' %} "SPARKPOST_API_KEY": env("SPARKPOST_API_KEY"), - "SPARKPOST_API_URL": env("SPARKPOST_API_URL", default="https://api.sparkpost.com/api/v1"), + "SPARKPOST_API_URL": env( + "SPARKPOST_API_URL", + default="https://api.sparkpost.com/api/v1" + ), # https://anymail.readthedocs.io/en/stable/esps/sparkpost/ {%- endif %} } From 0df8cfdb901882f1bcbfba51da59450911fd4343 Mon Sep 17 00:00:00 2001 From: Andrew-Chen-Wang Date: Thu, 6 Feb 2020 21:03:49 -0500 Subject: [PATCH 022/182] Added mail service pytests in test_cookiecutter_generation.py --- tests/test_cookiecutter_generation.py | 55 +++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/tests/test_cookiecutter_generation.py b/tests/test_cookiecutter_generation.py index 39b05d7c..5a569961 100755 --- a/tests/test_cookiecutter_generation.py +++ b/tests/test_cookiecutter_generation.py @@ -46,6 +46,41 @@ def context(): ], ids=lambda id: f"wnoise:{id[0]}-cloud:{id[1]}", ) +@pytest.mark.parametrize( + "cloud_provider,mail_service", + [ + ("AWS", "Amazon SES"), + ("AWS", "Mailgun"), + ("AWS", "Mailjet"), + ("AWS", "Mandrill"), + ("AWS", "Postmark"), + ("AWS", "Sendgrid"), + ("AWS", "SendinBlue"), + ("AWS", "SparkPost"), + ("AWS", "Plain/Vanilla Django-Anymail"), + + ("GCP", "Mailgun"), + ("GCP", "Mailjet"), + ("GCP", "Mandrill"), + ("GCP", "Postmark"), + ("GCP", "Sendgrid"), + ("GCP", "SendinBlue"), + ("GCP", "SparkPost"), + ("GCP", "Plain/Vanilla Django-Anymail"), + + ("None", "Mailgun"), + ("None", "Mailjet"), + ("None", "Mandrill"), + ("None", "Postmark"), + ("None", "Sendgrid"), + ("None", "SendinBlue"), + ("None", "SparkPost"), + ("None", "Plain/Vanilla Django-Anymail"), + + # GCP or None (i.e. no cloud provider) + Amazon SES is not supported + ], + ids=lambda id: f"cloud:{id[0]}-mail:{id[1]}", +) def context_combination( windows, use_docker, @@ -56,6 +91,7 @@ def context_combination( use_whitenoise, use_drf, cloud_provider, + mail_service, ): """Fixture that parametrize the function where it's used.""" return { @@ -68,6 +104,7 @@ def context_combination( "use_whitenoise": use_whitenoise, "use_drf": use_drf, "cloud_provider": cloud_provider, + "mail_service": mail_service, } @@ -194,3 +231,21 @@ def test_no_whitenoise_and_no_cloud_provider(cookies, context): assert result.exit_code != 0 assert isinstance(result.exception, FailedHookException) + + +def test_gcp_with_aws_ses_mail_service(cookies, context): + """It should not generate project if SES is set with GCP cloud provider""" + context.update({"cloud_provider": "GCP", "mail_service": "Amazon SES"}) + result = cookies.bake(extra_context=context) + + assert result.exit_code != 0 + assert isinstance(result.exception, FailedHookException) + + +def test_no_cloud_provider_with_aws_ses_mail_service(cookies, context): + """It should not generate project if SES is set with no cloud provider""" + context.update({"cloud_provider": "None", "mail_service": "Amazon SES"}) + result = cookies.bake(extra_context=context) + + assert result.exit_code != 0 + assert isinstance(result.exception, FailedHookException) From c839862aefded2e2f09f51afd448c8a3d015c409 Mon Sep 17 00:00:00 2001 From: Andrew-Chen-Wang Date: Thu, 6 Feb 2020 22:12:30 -0500 Subject: [PATCH 023/182] Testing mail service does not raise KeyError * KeyError raised when cloud_provider was used twice in mark parametrization. * Tox isn't working properly for me (collecting 17,000 files; obviously neglecting tox.ini and/or pytest.ini) --- tests/test_cookiecutter_generation.py | 41 +++++++-------------------- 1 file changed, 11 insertions(+), 30 deletions(-) diff --git a/tests/test_cookiecutter_generation.py b/tests/test_cookiecutter_generation.py index 5a569961..e8b341c9 100755 --- a/tests/test_cookiecutter_generation.py +++ b/tests/test_cookiecutter_generation.py @@ -47,39 +47,20 @@ def context(): ids=lambda id: f"wnoise:{id[0]}-cloud:{id[1]}", ) @pytest.mark.parametrize( - "cloud_provider,mail_service", + "mail_service", [ - ("AWS", "Amazon SES"), - ("AWS", "Mailgun"), - ("AWS", "Mailjet"), - ("AWS", "Mandrill"), - ("AWS", "Postmark"), - ("AWS", "Sendgrid"), - ("AWS", "SendinBlue"), - ("AWS", "SparkPost"), - ("AWS", "Plain/Vanilla Django-Anymail"), - - ("GCP", "Mailgun"), - ("GCP", "Mailjet"), - ("GCP", "Mandrill"), - ("GCP", "Postmark"), - ("GCP", "Sendgrid"), - ("GCP", "SendinBlue"), - ("GCP", "SparkPost"), - ("GCP", "Plain/Vanilla Django-Anymail"), - - ("None", "Mailgun"), - ("None", "Mailjet"), - ("None", "Mandrill"), - ("None", "Postmark"), - ("None", "Sendgrid"), - ("None", "SendinBlue"), - ("None", "SparkPost"), - ("None", "Plain/Vanilla Django-Anymail"), - + "Amazon SES", + "Mailgun", + "MailJet", + "Mandrill", + "Postmark", + "Sendgrid", + "SendinBlue", + "SparkPost", + "Plain/Vanilla Django-Anymail" # GCP or None (i.e. no cloud provider) + Amazon SES is not supported ], - ids=lambda id: f"cloud:{id[0]}-mail:{id[1]}", + ids=lambda id: f"mail:{id[0]}", ) def context_combination( windows, From 816fb1c44b5a5c4d82f3d154db1288cba3991524 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Fri, 7 Feb 2020 11:00:30 +0000 Subject: [PATCH 024/182] Update werkzeug from 0.16.1 to 1.0.0 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index f7782f0d..151dc67e 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -1,6 +1,6 @@ -r ./base.txt -Werkzeug==0.16.1 # https://github.com/pallets/werkzeug +Werkzeug==1.0.0 # https://github.com/pallets/werkzeug ipdb==0.12.3 # https://github.com/gotcha/ipdb Sphinx==2.3.1 # https://github.com/sphinx-doc/sphinx {%- if cookiecutter.use_docker == 'y' %} From be019ea54a20ca2008260bcdfc49446b3ea5d5f2 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Sun, 9 Feb 2020 11:00:30 +0000 Subject: [PATCH 025/182] Update sphinx from 2.3.1 to 2.4.0 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index f7782f0d..f7d8b368 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -2,7 +2,7 @@ Werkzeug==0.16.1 # https://github.com/pallets/werkzeug ipdb==0.12.3 # https://github.com/gotcha/ipdb -Sphinx==2.3.1 # https://github.com/sphinx-doc/sphinx +Sphinx==2.4.0 # https://github.com/sphinx-doc/sphinx {%- if cookiecutter.use_docker == 'y' %} psycopg2==2.8.4 --no-binary psycopg2 # https://github.com/psycopg/psycopg2 {%- else %} From 311e0dfc241199c9681c2b439a0b8b976ac67068 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Tue, 11 Feb 2020 11:00:30 +0000 Subject: [PATCH 026/182] Update django-extensions from 2.2.6 to 2.2.8 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index f7782f0d..f949d90d 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -32,6 +32,6 @@ pre-commit==2.0.1 # https://github.com/pre-commit/pre-commit factory-boy==2.12.0 # https://github.com/FactoryBoy/factory_boy django-debug-toolbar==2.2 # https://github.com/jazzband/django-debug-toolbar -django-extensions==2.2.6 # https://github.com/django-extensions/django-extensions +django-extensions==2.2.8 # https://github.com/django-extensions/django-extensions django-coverage-plugin==1.8.0 # https://github.com/nedbat/django_coverage_plugin pytest-django==3.8.0 # https://github.com/pytest-dev/pytest-django From a8e668d659c2c06a7ac3cd7d6674ac2448c2d5a4 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Wed, 12 Feb 2020 11:00:32 +0000 Subject: [PATCH 027/182] Update sphinx from 2.4.0 to 2.4.1 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index 98cb19e6..81d793cb 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -2,7 +2,7 @@ Werkzeug==1.0.0 # https://github.com/pallets/werkzeug ipdb==0.12.3 # https://github.com/gotcha/ipdb -Sphinx==2.4.0 # https://github.com/sphinx-doc/sphinx +Sphinx==2.4.1 # https://github.com/sphinx-doc/sphinx {%- if cookiecutter.use_docker == 'y' %} psycopg2==2.8.4 --no-binary psycopg2 # https://github.com/psycopg/psycopg2 {%- else %} From b64cb03b17e7872f99ff03f7d6b803d7465b3d9c Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Thu, 13 Feb 2020 16:59:38 -0800 Subject: [PATCH 028/182] Update tox from 3.14.3 to 3.14.4 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index e05cff3f..0e72e65b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,7 +9,7 @@ flake8==3.7.9 # Testing # ------------------------------------------------------------------------------ -tox==3.14.3 +tox==3.14.4 pytest==5.3.5 pytest_cases==1.12.1 pytest-cookies==0.5.0 From 8c945af82a94ccc61de99038457510b375043826 Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Fri, 14 Feb 2020 08:34:04 -0800 Subject: [PATCH 029/182] Update pytest-cookies from 0.5.0 to 0.5.1 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 0e72e65b..4b0a2087 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,6 +12,6 @@ flake8==3.7.9 tox==3.14.4 pytest==5.3.5 pytest_cases==1.12.1 -pytest-cookies==0.5.0 +pytest-cookies==0.5.1 pytest-xdist==1.31.0 pyyaml==5.3 From a857038e13c35eb31615da50ffa4a8ca8d6099a7 Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Mon, 17 Feb 2020 02:52:00 -0800 Subject: [PATCH 030/182] Update tox from 3.14.4 to 3.14.5 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 4b0a2087..7d68e3f4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,7 +9,7 @@ flake8==3.7.9 # Testing # ------------------------------------------------------------------------------ -tox==3.14.4 +tox==3.14.5 pytest==5.3.5 pytest_cases==1.12.1 pytest-cookies==0.5.1 From 10be405c890743cad7a833d78a565260256a97a1 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Mon, 17 Feb 2020 11:00:34 +0000 Subject: [PATCH 031/182] Update collectfast from 1.3.1 to 1.3.2 --- {{cookiecutter.project_slug}}/requirements/production.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/production.txt b/{{cookiecutter.project_slug}}/requirements/production.txt index 9c1de827..974ae1e6 100644 --- a/{{cookiecutter.project_slug}}/requirements/production.txt +++ b/{{cookiecutter.project_slug}}/requirements/production.txt @@ -5,7 +5,7 @@ gunicorn==20.0.4 # https://github.com/benoitc/gunicorn psycopg2==2.8.4 --no-binary psycopg2 # https://github.com/psycopg/psycopg2 {%- if cookiecutter.use_whitenoise == 'n' %} -Collectfast==1.3.1 # https://github.com/antonagestam/collectfast +Collectfast==1.3.2 # https://github.com/antonagestam/collectfast {%- endif %} {%- if cookiecutter.use_sentry == "y" %} sentry-sdk==0.14.1 # https://github.com/getsentry/sentry-python From 1a7bcccd945bc7c79b5c395a2682b818a5725bce Mon Sep 17 00:00:00 2001 From: Demetris Stavrou <1180929+demestav@users.noreply.github.com> Date: Tue, 18 Feb 2020 11:01:56 +0200 Subject: [PATCH 032/182] Added celery cookiecutter condition in Traefik configuration --- .../compose/production/traefik/traefik.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/{{cookiecutter.project_slug}}/compose/production/traefik/traefik.yml b/{{cookiecutter.project_slug}}/compose/production/traefik/traefik.yml index bb3be150..923774f4 100644 --- a/{{cookiecutter.project_slug}}/compose/production/traefik/traefik.yml +++ b/{{cookiecutter.project_slug}}/compose/production/traefik/traefik.yml @@ -9,9 +9,11 @@ entryPoints: web-secure: # https address: ":443" + {%- if cookiecutter.use_celery == 'y' %} flower: address: ":5555" + {%- endif %} certificatesResolvers: letsencrypt: @@ -44,6 +46,7 @@ http: tls: # https://docs.traefik.io/master/routing/routers/#certresolver certResolver: letsencrypt + {%- if cookiecutter.use_celery == 'y' %} flower-secure-router: rule: "Host(`{{ cookiecutter.domain_name }}`)" @@ -53,6 +56,7 @@ http: tls: # https://docs.traefik.io/master/routing/routers/#certresolver certResolver: letsencrypt + {%- endif %} middlewares: redirect: @@ -71,11 +75,13 @@ http: loadBalancer: servers: - url: http://django:5000 + {%- if cookiecutter.use_celery == 'y' %} flower: loadBalancer: servers: - url: http://flower:5555 + {%- endif %} providers: # https://docs.traefik.io/master/providers/file/ From b84017a8a856d6fdce5109f7d388a2f63c17f2a5 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Wed, 19 Feb 2020 11:00:32 +0000 Subject: [PATCH 033/182] Update pytest_cases from 1.12.1 to 1.12.2 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 7d68e3f4..06f5a80e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,7 +11,7 @@ flake8==3.7.9 # ------------------------------------------------------------------------------ tox==3.14.5 pytest==5.3.5 -pytest_cases==1.12.1 +pytest_cases==1.12.2 pytest-cookies==0.5.1 pytest-xdist==1.31.0 pyyaml==5.3 From 15e8e667e50750e37206e5a73b4b2c89a1d8d5b3 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Wed, 19 Feb 2020 11:00:36 +0000 Subject: [PATCH 034/182] Update sphinx from 2.4.1 to 2.4.2 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index 81d793cb..57a01559 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -2,7 +2,7 @@ Werkzeug==1.0.0 # https://github.com/pallets/werkzeug ipdb==0.12.3 # https://github.com/gotcha/ipdb -Sphinx==2.4.1 # https://github.com/sphinx-doc/sphinx +Sphinx==2.4.2 # https://github.com/sphinx-doc/sphinx {%- if cookiecutter.use_docker == 'y' %} psycopg2==2.8.4 --no-binary psycopg2 # https://github.com/psycopg/psycopg2 {%- else %} From d5edf1fa4dbccb838b815b742c7dcf6db5762fdd Mon Sep 17 00:00:00 2001 From: browniebroke Date: Wed, 19 Feb 2020 11:00:39 +0000 Subject: [PATCH 035/182] Update pre-commit from 2.0.1 to 2.1.0 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index 81d793cb..d3cfa24a 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -25,7 +25,7 @@ pylint-django==2.0.13 # https://github.com/PyCQA/pylint-django {%- if cookiecutter.use_celery == 'y' %} pylint-celery==0.3 # https://github.com/PyCQA/pylint-celery {%- endif %} -pre-commit==2.0.1 # https://github.com/pre-commit/pre-commit +pre-commit==2.1.0 # https://github.com/pre-commit/pre-commit # Django # ------------------------------------------------------------------------------ From 2fb739fed2d5794204a2a9189c66d67169dd4105 Mon Sep 17 00:00:00 2001 From: "Vicente G. Reyes" Date: Thu, 20 Feb 2020 02:02:48 +0800 Subject: [PATCH 036/182] Update README.rst Update command $ pip install "cookiecutter>=1.7.0" on docs --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 6e534b0f..0ae86d05 100644 --- a/README.rst +++ b/README.rst @@ -135,7 +135,7 @@ and then editing the results to include your name, email, and various configurat First, get Cookiecutter. Trust me, it's awesome:: - $ pip install "cookiecutter>=1.4.0" + $ pip install "cookiecutter>=1.7.0" Now run it against this repo:: From d1c417b63d8729e3fdb431a73032e798b116e9da Mon Sep 17 00:00:00 2001 From: "Vicente G. Reyes" Date: Thu, 20 Feb 2020 02:06:20 +0800 Subject: [PATCH 037/182] Update CONTRIBUTORS.rst added myself --- CONTRIBUTORS.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index 2554d2cf..130d7e6e 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -205,6 +205,7 @@ Listed in alphabetical order. Tubo Shi `@Tubo`_ Umair Ashraf `@umrashrf`_ @fabumair Vadim Iskuchekov `@Egregors`_ @egregors + Vicente G. Reyes `@reyesvicente`_ @highcenburg Vitaly Babiy Vivian Guillen `@viviangb`_ Vlad Doster `@vladdoster`_ From 161d8bcf9e749b235757cbf8c542c16b68accdee Mon Sep 17 00:00:00 2001 From: "Vicente G. Reyes" Date: Thu, 20 Feb 2020 02:39:21 +0800 Subject: [PATCH 038/182] Update CONTRIBUTORS.rst fixed conflict --- CONTRIBUTORS.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index 130d7e6e..a07ea8e9 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -341,6 +341,7 @@ Listed in alphabetical order. .. _@purplediane: https://github.com/purplediane .. _@raonyguimaraes: https://github.com/raonyguimaraes .. _@reggieriser: https://github.com/reggieriser +.. _@reyesvicente: https://github.com/reyesvicente .. _@rm--: https://github.com/rm-- .. _@rolep: https://github.com/rolep .. _@romanosipenko: https://github.com/romanosipenko From e8b36af72fb371a528ee20acceea6e7ed4ef4d52 Mon Sep 17 00:00:00 2001 From: Cole Maclean Date: Wed, 19 Feb 2020 13:13:10 -0800 Subject: [PATCH 039/182] Remove coreapi requirement --- {{cookiecutter.project_slug}}/requirements/base.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/base.txt b/{{cookiecutter.project_slug}}/requirements/base.txt index 5427f1d0..31a6a32b 100644 --- a/{{cookiecutter.project_slug}}/requirements/base.txt +++ b/{{cookiecutter.project_slug}}/requirements/base.txt @@ -31,4 +31,3 @@ django-redis==4.11.0 # https://github.com/niwinz/django-redis # Django REST Framework djangorestframework==3.11.0 # https://github.com/encode/django-rest-framework -coreapi==2.3.3 # https://github.com/core-api/python-client From 54dd167501b2049e70acfd786ba856e3e2ed0845 Mon Sep 17 00:00:00 2001 From: Cole Maclean Date: Wed, 19 Feb 2020 13:17:02 -0800 Subject: [PATCH 040/182] Add myself to contributors --- CONTRIBUTORS.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index 2554d2cf..5859bc3a 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -87,6 +87,7 @@ Listed in alphabetical order. Chris Pappalardo `@ChrisPappalardo`_ Christopher Clarke `@chrisdev`_ Cole Mackenzie `@cmackenzie1`_ + Cole Maclean `@cole`_ @cole Collederas `@Collederas`_ Craig Margieson `@cmargieson`_ Cristian Vargas `@cdvv7788`_ @@ -258,6 +259,7 @@ Listed in alphabetical order. .. _@chuckus: https://github.com/chuckus .. _@cmackenzie1: https://github.com/cmackenzie1 .. _@cmargieson: https://github.com/cmargieson +.. _@cole: https://github.com/cole .. _@Collederas: https://github.com/Collederas .. _@curtisstpierre: https://github.com/curtisstpierre .. _@dadokkio: https://github.com/dadokkio From f6a63a5f0c69bc074655304098478b3fa9aae2c7 Mon Sep 17 00:00:00 2001 From: Demetris Stavrou <1180929+demestav@users.noreply.github.com> Date: Fri, 21 Feb 2020 10:08:10 +0200 Subject: [PATCH 041/182] Added 5555 port mapping to traefik service --- {{cookiecutter.project_slug}}/production.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/{{cookiecutter.project_slug}}/production.yml b/{{cookiecutter.project_slug}}/production.yml index 125d4876..45e1c447 100644 --- a/{{cookiecutter.project_slug}}/production.yml +++ b/{{cookiecutter.project_slug}}/production.yml @@ -42,6 +42,7 @@ services: ports: - "0.0.0.0:80:80" - "0.0.0.0:443:443" + - "0.0.0.0:5555:5555" redis: image: redis:5.0 From e3d7ea0e108a76827e96002e05eb8726768eaa7a Mon Sep 17 00:00:00 2001 From: Demetris Stavrou <1180929+demestav@users.noreply.github.com> Date: Sat, 22 Feb 2020 21:29:40 +0200 Subject: [PATCH 042/182] Added condition for Flower port mapping --- {{cookiecutter.project_slug}}/production.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/{{cookiecutter.project_slug}}/production.yml b/{{cookiecutter.project_slug}}/production.yml index 45e1c447..2cd2af13 100644 --- a/{{cookiecutter.project_slug}}/production.yml +++ b/{{cookiecutter.project_slug}}/production.yml @@ -42,7 +42,9 @@ services: ports: - "0.0.0.0:80:80" - "0.0.0.0:443:443" + {%- if cookiecutter.use_celery == 'y' %} - "0.0.0.0:5555:5555" + {%- endif %} redis: image: redis:5.0 From 405d33d99e5f45d18a9db3b39b352027ed54187c Mon Sep 17 00:00:00 2001 From: browniebroke Date: Sun, 23 Feb 2020 11:00:30 +0000 Subject: [PATCH 043/182] Update sphinx from 2.4.2 to 2.4.3 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index e2f2b581..2c7fc85b 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -2,7 +2,7 @@ Werkzeug==1.0.0 # https://github.com/pallets/werkzeug ipdb==0.12.3 # https://github.com/gotcha/ipdb -Sphinx==2.4.2 # https://github.com/sphinx-doc/sphinx +Sphinx==2.4.3 # https://github.com/sphinx-doc/sphinx {%- if cookiecutter.use_docker == 'y' %} psycopg2==2.8.4 --no-binary psycopg2 # https://github.com/psycopg/psycopg2 {%- else %} From 7df671611a280a3171c9280a9e13a4e603ae15a5 Mon Sep 17 00:00:00 2001 From: Pawan Chaurasia Date: Mon, 24 Feb 2020 18:46:01 +0530 Subject: [PATCH 044/182] fixed pre-commit not loading the flake8 config. added path of setup.cfg in .pre-commit-config.yaml --- {{cookiecutter.project_slug}}/.pre-commit-config.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml index b9d69a9a..4b72ee80 100644 --- a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml +++ b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml @@ -16,4 +16,5 @@ repos: entry: flake8 language: python types: [python] + args: ['--config=setup.cfg'] From c5ef5bf757555135e9703c2fd830bf30ef8d135f Mon Sep 17 00:00:00 2001 From: Pawan Chaurasia Date: Mon, 24 Feb 2020 18:49:13 +0530 Subject: [PATCH 045/182] added name in contributors.rst --- CONTRIBUTORS.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index 691b43ca..1069a951 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -176,6 +176,7 @@ Listed in alphabetical order. Oleg Russkin `@rolep`_ Pablo `@oubiga`_ Parbhat Puri `@parbhat`_ + Pawan Chaurasia `@rjsnh1522`_ Peter Bittner `@bittner`_ Peter Coles `@mrcoles`_ Philipp Matthies `@canonnervio`_ From 786b2beb44efcc0a3e52e9eb365e2aafed02d278 Mon Sep 17 00:00:00 2001 From: Pawan Chaurasia Date: Tue, 25 Feb 2020 10:06:49 +0530 Subject: [PATCH 046/182] fixed broken link in contributors.rst --- CONTRIBUTORS.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index 1069a951..86804b69 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -339,6 +339,7 @@ Listed in alphabetical order. .. _@originell: https://github.com/originell .. _@oubiga: https://github.com/oubiga .. _@parbhat: https://github.com/parbhat +.. _@rjsnh1522: https://github.com/rjsnh1522 .. _@pchiquet: https://github.com/pchiquet .. _@phiberjenz: https://github.com/phiberjenz .. _@purplediane: https://github.com/purplediane From 487ed35bc5e7c13ade498c68752f9a2f25d7dec9 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Tue, 25 Feb 2020 11:00:32 +0000 Subject: [PATCH 047/182] Update collectfast from 1.3.2 to 2.0.1 --- {{cookiecutter.project_slug}}/requirements/production.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/production.txt b/{{cookiecutter.project_slug}}/requirements/production.txt index 974ae1e6..82155008 100644 --- a/{{cookiecutter.project_slug}}/requirements/production.txt +++ b/{{cookiecutter.project_slug}}/requirements/production.txt @@ -5,7 +5,7 @@ gunicorn==20.0.4 # https://github.com/benoitc/gunicorn psycopg2==2.8.4 --no-binary psycopg2 # https://github.com/psycopg/psycopg2 {%- if cookiecutter.use_whitenoise == 'n' %} -Collectfast==1.3.2 # https://github.com/antonagestam/collectfast +Collectfast==2.0.1 # https://github.com/antonagestam/collectfast {%- endif %} {%- if cookiecutter.use_sentry == "y" %} sentry-sdk==0.14.1 # https://github.com/getsentry/sentry-python From a36f6a7495ccc141f1b8d565e4acbc925b66d807 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Tue, 25 Feb 2020 11:00:36 +0000 Subject: [PATCH 048/182] Update pylint-django from 2.0.13 to 2.0.14 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index 2c7fc85b..5011f3c3 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -21,7 +21,7 @@ pytest-sugar==0.9.2 # https://github.com/Frozenball/pytest-sugar flake8==3.7.9 # https://github.com/PyCQA/flake8 coverage==5.0.3 # https://github.com/nedbat/coveragepy black==19.10b0 # https://github.com/ambv/black -pylint-django==2.0.13 # https://github.com/PyCQA/pylint-django +pylint-django==2.0.14 # https://github.com/PyCQA/pylint-django {%- if cookiecutter.use_celery == 'y' %} pylint-celery==0.3 # https://github.com/PyCQA/pylint-celery {%- endif %} From f9b0c4846b1d09c7c0c470ab8ced814b5df6513b Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Tue, 25 Feb 2020 12:58:45 +0000 Subject: [PATCH 049/182] Update pre-commit from 2.1.0 to 2.1.1 (#2463) --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index 5011f3c3..194e25d5 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -25,7 +25,7 @@ pylint-django==2.0.14 # https://github.com/PyCQA/pylint-django {%- if cookiecutter.use_celery == 'y' %} pylint-celery==0.3 # https://github.com/PyCQA/pylint-celery {%- endif %} -pre-commit==2.1.0 # https://github.com/pre-commit/pre-commit +pre-commit==2.1.1 # https://github.com/pre-commit/pre-commit # Django # ------------------------------------------------------------------------------ From fe7a70be6606b5516a02b71ae0ed5a95e9174b0b Mon Sep 17 00:00:00 2001 From: browniebroke Date: Thu, 27 Feb 2020 11:00:32 +0000 Subject: [PATCH 050/182] Update sentry-sdk from 0.14.1 to 0.14.2 --- {{cookiecutter.project_slug}}/requirements/production.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/production.txt b/{{cookiecutter.project_slug}}/requirements/production.txt index 82155008..62fe3e40 100644 --- a/{{cookiecutter.project_slug}}/requirements/production.txt +++ b/{{cookiecutter.project_slug}}/requirements/production.txt @@ -8,7 +8,7 @@ psycopg2==2.8.4 --no-binary psycopg2 # https://github.com/psycopg/psycopg2 Collectfast==2.0.1 # https://github.com/antonagestam/collectfast {%- endif %} {%- if cookiecutter.use_sentry == "y" %} -sentry-sdk==0.14.1 # https://github.com/getsentry/sentry-python +sentry-sdk==0.14.2 # https://github.com/getsentry/sentry-python {%- endif %} # Django From c54345e5f8a572045aa08634af5fdcd1cc45edaa Mon Sep 17 00:00:00 2001 From: Daniel Roy Greenfeld Date: Thu, 27 Feb 2020 21:07:31 -0800 Subject: [PATCH 051/182] Switch sponsorship to Django Crash Course --- README.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.rst b/README.rst index 0ae86d05..3add09cf 100644 --- a/README.rst +++ b/README.rst @@ -105,16 +105,16 @@ This project is run by volunteers. Please support them in their efforts to maint Projects that provide financial support to the maintainers: -Two Scoops of Django 1.11 +Django Crash Course ~~~~~~~~~~~~~~~~~~~~~~~~~ -.. image:: https://cdn.shopify.com/s/files/1/0304/6901/products/2017-06-29-tsd11-sticker-02.png - :name: Two Scoops of Django 1.11 Cover +.. image:: https://cdn.shopify.com/s/files/1/0304/6901/files/Django-Crash-Course-300x436.jpg + :name: Django Crash Course: Covers Django 3.0 and Python 3.8 :align: center - :alt: Two Scoops of Django - :target: http://twoscoopspress.com/products/two-scoops-of-django-1-11 + :alt: Django Crash Course + :target: https://www.roygreenfeld.com/products/django-crash-course -Two Scoops of Django is the best dessert-themed Django reference in the universe +Django Crash Course for Django 3.0 and Python 3.8 is the best cheese-themed Django reference in the universe! pyup ~~~~~~~~~~~~~~~~~~ From 89f85f1255598578126776372f41ceb8eaa0e5af Mon Sep 17 00:00:00 2001 From: James Williams Date: Tue, 11 Feb 2020 20:17:50 +0000 Subject: [PATCH 052/182] - configure compressor when not using s3 - update django start script to compress if using whitenoise and compress enabled - add to contributors.rst --- CONTRIBUTORS.rst | 1 + .../compose/production/django/start | 6 ++++++ .../config/settings/production.py | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index 86804b69..043312b0 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -129,6 +129,7 @@ Listed in alphabetical order. Irfan Ahmad `@erfaan`_ @erfaan Isaac12x `@Isaac12x`_ Ivan Khomutov `@ikhomutov`_ + James Williams `@jameswilliams1`_ Jan Van Bruggen `@jvanbrug`_ Jelmer Draaijer `@foarsitter`_ Jerome Caisip `@jeromecaisip`_ diff --git a/{{cookiecutter.project_slug}}/compose/production/django/start b/{{cookiecutter.project_slug}}/compose/production/django/start index 709c1dd0..a3aa1161 100644 --- a/{{cookiecutter.project_slug}}/compose/production/django/start +++ b/{{cookiecutter.project_slug}}/compose/production/django/start @@ -6,4 +6,10 @@ set -o nounset python /app/manage.py collectstatic --noinput +{%- if cookiecutter.use_whitenoise == 'y' and cookiecutter.use_compressor == 'y' %} +if [ "${COMPRESS_ENABLED:-}" = "True" ]; +then + python /app/manage.py compress +fi +{%- endif %} /usr/local/bin/gunicorn config.wsgi --bind 0.0.0.0:5000 --chdir=/app diff --git a/{{cookiecutter.project_slug}}/config/settings/production.py b/{{cookiecutter.project_slug}}/config/settings/production.py index 36667b33..a3e4b9c2 100644 --- a/{{cookiecutter.project_slug}}/config/settings/production.py +++ b/{{cookiecutter.project_slug}}/config/settings/production.py @@ -200,9 +200,27 @@ ANYMAIL = { # https://django-compressor.readthedocs.io/en/latest/settings/#django.conf.settings.COMPRESS_ENABLED COMPRESS_ENABLED = env.bool("COMPRESS_ENABLED", default=True) # https://django-compressor.readthedocs.io/en/latest/settings/#django.conf.settings.COMPRESS_STORAGE +{%- if cookiecutter.cloud_provider == 'AWS' %} COMPRESS_STORAGE = "storages.backends.s3boto3.S3Boto3Storage" +{%- elif cookiecutter.cloud_provider == 'GCP' %} +COMPRESS_STORAGE = "storages.backends.gcloud.GoogleCloudStorage" +{%- elif cookiecutter.cloud_provider == 'None' %} +COMPRESS_STORAGE = "compressor.storage.GzipCompressorFileStorage" +{%- endif %} # https://django-compressor.readthedocs.io/en/latest/settings/#django.conf.settings.COMPRESS_URL COMPRESS_URL = STATIC_URL{% if cookiecutter.use_whitenoise == 'y' or cookiecutter.cloud_provider == 'None' %} # noqa F405{% endif %} +{%- if cookiecutter.use_whitenoise == 'y' %} +# https://django-compressor.readthedocs.io/en/latest/settings/#django.conf.settings.COMPRESS_OFFLINE +COMPRESS_OFFLINE = True # Offline compression is required when using Whitenoise +{%- endif %} +# https://django-compressor.readthedocs.io/en/latest/settings/#django.conf.settings.COMPRESS_FILTERS +COMPRESS_FILTERS = { + "css": [ + "compressor.filters.css_default.CssAbsoluteFilter", + "compressor.filters.cssmin.rCSSMinFilter", + ], + "js": ["compressor.filters.jsmin.JSMinFilter"], +} {% endif %} {%- if cookiecutter.use_whitenoise == 'n' -%} # Collectfast From e1cb30b699460dc8dbdef9587d20c8423d022b1a Mon Sep 17 00:00:00 2001 From: James Williams Date: Fri, 28 Feb 2020 16:08:20 +0000 Subject: [PATCH 053/182] fix broken contributors link --- CONTRIBUTORS.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index 043312b0..beba320b 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -299,6 +299,7 @@ Listed in alphabetical order. .. _@howiezhao: https://github.com/howiezhao .. _@IanLee1521: https://github.com/IanLee1521 .. _@ikhomutov: https://github.com/ikhomutov +.. _@jameswilliams1: https://github.com/jameswilliams1 .. _@ikkebr: https://github.com/ikkebr .. _@Isaac12x: https://github.com/Isaac12x .. _@iynaix: https://github.com/iynaix From d3db7a867fbf58b80ceea4dc05829a2fcbbdbe60 Mon Sep 17 00:00:00 2001 From: James Williams Date: Fri, 28 Feb 2020 17:04:15 +0000 Subject: [PATCH 054/182] fix compresss offline never runs using environ --- .../compose/production/django/start | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/{{cookiecutter.project_slug}}/compose/production/django/start b/{{cookiecutter.project_slug}}/compose/production/django/start index a3aa1161..4985aeed 100644 --- a/{{cookiecutter.project_slug}}/compose/production/django/start +++ b/{{cookiecutter.project_slug}}/compose/production/django/start @@ -6,9 +6,24 @@ set -o nounset python /app/manage.py collectstatic --noinput -{%- if cookiecutter.use_whitenoise == 'y' and cookiecutter.use_compressor == 'y' %} -if [ "${COMPRESS_ENABLED:-}" = "True" ]; -then +{% if cookiecutter.use_whitenoise == 'y' and cookiecutter.use_compressor == 'y' %} +compress_enabled() { +python << END +import sys + +from environ import Env + +env = Env(COMPRESS_ENABLED=(bool, True)) +if env('COMPRESS_ENABLED'): + sys.exit(0) +else: + sys.exit(1) + +END +} + +if compress_enabled; then + # NOTE this command will fail if django-compressor is disabled python /app/manage.py compress fi {%- endif %} From 7e0f86b4ba0666dc03cbb3dc6644b53291e74d26 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Sat, 29 Feb 2020 11:00:30 +0000 Subject: [PATCH 055/182] Update django-celery-beat from 1.6.0 to 2.0.0 --- {{cookiecutter.project_slug}}/requirements/base.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/base.txt b/{{cookiecutter.project_slug}}/requirements/base.txt index 31a6a32b..0d6d1407 100644 --- a/{{cookiecutter.project_slug}}/requirements/base.txt +++ b/{{cookiecutter.project_slug}}/requirements/base.txt @@ -11,7 +11,7 @@ whitenoise==5.0.1 # https://github.com/evansd/whitenoise redis==3.4.1 # https://github.com/andymccurdy/redis-py {%- if cookiecutter.use_celery == "y" %} celery==4.4.0 # pyup: < 5.0 # https://github.com/celery/celery -django-celery-beat==1.6.0 # https://github.com/celery/django-celery-beat +django-celery-beat==2.0.0 # https://github.com/celery/django-celery-beat {%- if cookiecutter.use_docker == 'y' %} flower==0.9.3 # https://github.com/mher/flower {%- endif %} From ccfe97972a189b877fc499f965bbe1bf6f954d55 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Sat, 29 Feb 2020 11:00:33 +0000 Subject: [PATCH 056/182] Update django-crispy-forms from 1.8.1 to 1.9.0 --- {{cookiecutter.project_slug}}/requirements/base.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/base.txt b/{{cookiecutter.project_slug}}/requirements/base.txt index 31a6a32b..182dd224 100644 --- a/{{cookiecutter.project_slug}}/requirements/base.txt +++ b/{{cookiecutter.project_slug}}/requirements/base.txt @@ -23,7 +23,7 @@ django==2.2.10 # pyup: < 3.0 # https://www.djangoproject.com/ django-environ==0.4.5 # https://github.com/joke2k/django-environ django-model-utils==4.0.0 # https://github.com/jazzband/django-model-utils django-allauth==0.41.0 # https://github.com/pennersr/django-allauth -django-crispy-forms==1.8.1 # https://github.com/django-crispy-forms/django-crispy-forms +django-crispy-forms==1.9.0 # https://github.com/django-crispy-forms/django-crispy-forms {%- if cookiecutter.use_compressor == "y" %} django-compressor==2.4 # https://github.com/django-compressor/django-compressor {%- endif %} From 37652710159de08a322771d549b19d2097afeac9 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Sat, 29 Feb 2020 11:00:36 +0000 Subject: [PATCH 057/182] Update ipdb from 0.12.3 to 0.13.1 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index 194e25d5..e70cb63f 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -1,7 +1,7 @@ -r ./base.txt Werkzeug==1.0.0 # https://github.com/pallets/werkzeug -ipdb==0.12.3 # https://github.com/gotcha/ipdb +ipdb==0.13.1 # https://github.com/gotcha/ipdb Sphinx==2.4.3 # https://github.com/sphinx-doc/sphinx {%- if cookiecutter.use_docker == 'y' %} psycopg2==2.8.4 --no-binary psycopg2 # https://github.com/psycopg/psycopg2 From 33f210abc432c79ad2b6e619629a8b9633237d2f Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Sat, 29 Feb 2020 17:15:35 +0000 Subject: [PATCH 058/182] Simplify setup for the automated tests --- .travis.yml | 4 - pytest.ini | 3 - requirements.txt | 1 - tests/test_cookiecutter_generation.py | 146 +++++++++++++------------- tox.ini | 12 +-- 5 files changed, 75 insertions(+), 91 deletions(-) diff --git a/.travis.yml b/.travis.yml index 925d82e7..52786a17 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,10 +15,6 @@ matrix: include: - name: Test results script: tox -e py37 - - name: Run flake8 on result - script: tox -e flake8 - - name: Run black on result - script: tox -e black - name: Black template script: tox -e black-template - name: Basic Docker diff --git a/pytest.ini b/pytest.ini index 89aeb302..5d5a9c93 100644 --- a/pytest.ini +++ b/pytest.ini @@ -2,6 +2,3 @@ addopts = -x --tb=short python_paths = . norecursedirs = .tox .git */migrations/* */static/* docs venv */{{cookiecutter.project_slug}}/* -markers = - flake8: Run flake8 on all possible template combinations - black: Run black on all possible template combinations diff --git a/requirements.txt b/requirements.txt index 06f5a80e..853ae4eb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,7 +11,6 @@ flake8==3.7.9 # ------------------------------------------------------------------------------ tox==3.14.5 pytest==5.3.5 -pytest_cases==1.12.2 pytest-cookies==0.5.1 pytest-xdist==1.31.0 pyyaml==5.3 diff --git a/tests/test_cookiecutter_generation.py b/tests/test_cookiecutter_generation.py index 39b05d7c..964c91d7 100755 --- a/tests/test_cookiecutter_generation.py +++ b/tests/test_cookiecutter_generation.py @@ -3,7 +3,6 @@ import re import pytest from cookiecutter.exceptions import FailedHookException -from pytest_cases import fixture_plus import sh import yaml from binaryornot.check import is_binary @@ -26,49 +25,62 @@ def context(): } -@fixture_plus -@pytest.mark.parametrize("windows", ["y", "n"], ids=lambda yn: f"win:{yn}") -@pytest.mark.parametrize("use_docker", ["y", "n"], ids=lambda yn: f"docker:{yn}") -@pytest.mark.parametrize("use_celery", ["y", "n"], ids=lambda yn: f"celery:{yn}") -@pytest.mark.parametrize("use_mailhog", ["y", "n"], ids=lambda yn: f"mailhog:{yn}") -@pytest.mark.parametrize("use_sentry", ["y", "n"], ids=lambda yn: f"sentry:{yn}") -@pytest.mark.parametrize("use_compressor", ["y", "n"], ids=lambda yn: f"cmpr:{yn}") -@pytest.mark.parametrize("use_drf", ["y", "n"], ids=lambda yn: f"drf:{yn}") -@pytest.mark.parametrize( - "use_whitenoise,cloud_provider", - [ - ("y", "AWS"), - ("y", "GCP"), - ("y", "None"), - ("n", "AWS"), - ("n", "GCP"), - # no whitenoise + no cloud provider is not supported - ], - ids=lambda id: f"wnoise:{id[0]}-cloud:{id[1]}", -) -def context_combination( - windows, - use_docker, - use_celery, - use_mailhog, - use_sentry, - use_compressor, - use_whitenoise, - use_drf, - cloud_provider, -): - """Fixture that parametrize the function where it's used.""" - return { - "windows": windows, - "use_docker": use_docker, - "use_compressor": use_compressor, - "use_celery": use_celery, - "use_mailhog": use_mailhog, - "use_sentry": use_sentry, - "use_whitenoise": use_whitenoise, - "use_drf": use_drf, - "cloud_provider": cloud_provider, - } +SUPPORTED_COMBINATIONS = [ + {"open_source_license": "MIT"}, + {"open_source_license": "BSD"}, + {"open_source_license": "GPLv3"}, + {"open_source_license": "Apache Software License 2.0"}, + {"open_source_license": "Not open source"}, + {"windows": "y"}, + {"windows": "n"}, + {"use_pycharm": "y"}, + {"use_pycharm": "n"}, + {"use_docker": "y"}, + {"use_docker": "n"}, + {"postgresql_version": "11.3"}, + {"postgresql_version": "10.8"}, + {"postgresql_version": "9.6"}, + {"postgresql_version": "9.5"}, + {"postgresql_version": "9.4"}, + {"cloud_provider": "AWS", "use_whitenoise": "y"}, + {"cloud_provider": "AWS", "use_whitenoise": "n"}, + {"cloud_provider": "GCP", "use_whitenoise": "y"}, + {"cloud_provider": "GCP", "use_whitenoise": "n"}, + {"cloud_provider": "None", "use_whitenoise": "y"}, + # Note: cloud_provider=None AND use_whitenoise=n is not supported + {"use_drf": "y"}, + {"use_drf": "n"}, + {"js_task_runner": "None"}, + {"js_task_runner": "Gulp"}, + {"custom_bootstrap_compilation": "y"}, + {"custom_bootstrap_compilation": "n"}, + {"use_compressor": "y"}, + {"use_compressor": "n"}, + {"use_celery": "y"}, + {"use_celery": "n"}, + {"use_mailhog": "y"}, + {"use_mailhog": "n"}, + {"use_sentry": "y"}, + {"use_sentry": "n"}, + {"use_whitenoise": "y"}, + {"use_whitenoise": "n"}, + {"use_heroku": "y"}, + {"use_heroku": "n"}, + {"ci_tool": "None"}, + {"ci_tool": "Travis"}, + {"ci_tool": "Gitlab"}, + {"keep_local_envs_in_vcs": "y"}, + {"keep_local_envs_in_vcs": "n"}, + {"debug": "y"}, + {"debug": "n"}, +] + +UNSUPPORTED_COMBINATIONS = [{"cloud_provider": "None", "use_whitenoise": "n"}] + + +def _fixture_id(ctx): + """Helper to get a user friendly test name from the parametrized context.""" + return "-".join(f"{key}:{value}" for key, value in ctx.items()) def build_files_list(root_dir): @@ -81,9 +93,7 @@ def build_files_list(root_dir): def check_paths(paths): - """Method to check all paths have correct substitutions, - used by other tests cases - """ + """Method to check all paths have correct substitutions.""" # Assert that no match is found in any of the files for path in paths: if is_binary(path): @@ -95,13 +105,10 @@ def check_paths(paths): assert match is None, msg.format(path) -def test_project_generation(cookies, context, context_combination): - """ - Test that project is generated and fully rendered. - - This is parametrized for each combination from ``context_combination`` fixture - """ - result = cookies.bake(extra_context={**context, **context_combination}) +@pytest.mark.parametrize("context_override", SUPPORTED_COMBINATIONS, ids=_fixture_id) +def test_project_generation(cookies, context, context_override): + """Test that project is generated and fully rendered.""" + result = cookies.bake(extra_context={**context, **context_override}) assert result.exit_code == 0 assert result.exception is None assert result.project.basename == context["project_slug"] @@ -112,14 +119,10 @@ def test_project_generation(cookies, context, context_combination): check_paths(paths) -@pytest.mark.flake8 -def test_flake8_passes(cookies, context_combination): - """ - Generated project should pass flake8. - - This is parametrized for each combination from ``context_combination`` fixture - """ - result = cookies.bake(extra_context=context_combination) +@pytest.mark.parametrize("context_override", SUPPORTED_COMBINATIONS, ids=_fixture_id) +def test_flake8_passes(cookies, context_override): + """Generated project should pass flake8.""" + result = cookies.bake(extra_context=context_override) try: sh.flake8(str(result.project)) @@ -127,14 +130,10 @@ def test_flake8_passes(cookies, context_combination): pytest.fail(e) -@pytest.mark.black -def test_black_passes(cookies, context_combination): - """ - Generated project should pass black. - - This is parametrized for each combination from ``context_combination`` fixture - """ - result = cookies.bake(extra_context=context_combination) +@pytest.mark.parametrize("context_override", SUPPORTED_COMBINATIONS, ids=_fixture_id) +def test_black_passes(cookies, context_override): + """Generated project should pass black.""" + result = cookies.bake(extra_context=context_override) try: sh.black("--check", "--diff", "--exclude", "migrations", f"{result.project}/") @@ -187,9 +186,10 @@ def test_invalid_slug(cookies, context, slug): assert isinstance(result.exception, FailedHookException) -def test_no_whitenoise_and_no_cloud_provider(cookies, context): - """It should not generate project if neither whitenoise or cloud provider are set""" - context.update({"use_whitenoise": "n", "cloud_provider": "None"}) +@pytest.mark.parametrize("invalid_context", UNSUPPORTED_COMBINATIONS) +def test_error_if_incompatible(cookies, context, invalid_context): + """It should not generate project an incompatible combination is selected.""" + context.update(invalid_context) result = cookies.bake(extra_context=context) assert result.exit_code != 0 diff --git a/tox.ini b/tox.ini index 1c83465c..737b26e7 100644 --- a/tox.ini +++ b/tox.ini @@ -1,18 +1,10 @@ [tox] skipsdist = true -envlist = py37,flake8,black,black-template +envlist = py37,black-template [testenv] deps = -rrequirements.txt -commands = pytest -m "not flake8" -m "not black" {posargs:./tests} - -[testenv:flake8] -deps = -rrequirements.txt -commands = pytest -m flake8 {posargs:./tests} - -[testenv:black] -deps = -rrequirements.txt -commands = pytest -m black {posargs:./tests} +commands = pytest {posargs:./tests} [testenv:black-template] deps = black From fa6ca7b1c853f46a2124ef2f69bb29967409cb13 Mon Sep 17 00:00:00 2001 From: jeromecaisip Date: Mon, 2 Mar 2020 19:16:33 +0100 Subject: [PATCH 059/182] Add rest_framework.authtoken on installed apps. Add rest_framework.authtoken on installed apps when the option to use DRF is selected, because the endpoint '/auth-token/" depends on the said app. --- {{cookiecutter.project_slug}}/config/settings/base.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/{{cookiecutter.project_slug}}/config/settings/base.py b/{{cookiecutter.project_slug}}/config/settings/base.py index 6ad8e820..a771ed46 100644 --- a/{{cookiecutter.project_slug}}/config/settings/base.py +++ b/{{cookiecutter.project_slug}}/config/settings/base.py @@ -79,6 +79,10 @@ THIRD_PARTY_APPS = [ {%- if cookiecutter.use_celery == 'y' %} "django_celery_beat", {%- endif %} +{% if cookiecutter.use_drf == "y" -%} + "rest_framework.authtoken", +{%- endif %} + ] LOCAL_APPS = [ From bfe463fa7c5731d0219f113f5f192f9a421aa472 Mon Sep 17 00:00:00 2001 From: jeromecaisip Date: Mon, 2 Mar 2020 19:27:07 +0100 Subject: [PATCH 060/182] Update base.py --- {{cookiecutter.project_slug}}/config/settings/base.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/{{cookiecutter.project_slug}}/config/settings/base.py b/{{cookiecutter.project_slug}}/config/settings/base.py index a771ed46..22b1fed8 100644 --- a/{{cookiecutter.project_slug}}/config/settings/base.py +++ b/{{cookiecutter.project_slug}}/config/settings/base.py @@ -79,10 +79,9 @@ THIRD_PARTY_APPS = [ {%- if cookiecutter.use_celery == 'y' %} "django_celery_beat", {%- endif %} -{% if cookiecutter.use_drf == "y" -%} +{%- if cookiecutter.use_drf == "y" %} "rest_framework.authtoken", {%- endif %} - ] LOCAL_APPS = [ From 4fd15474b1806ea06554451efec59708f3a349a1 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Tue, 3 Mar 2020 11:00:31 +0000 Subject: [PATCH 061/182] Update collectfast from 2.0.1 to 2.1.0 --- {{cookiecutter.project_slug}}/requirements/production.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/production.txt b/{{cookiecutter.project_slug}}/requirements/production.txt index 62fe3e40..f0c4fed1 100644 --- a/{{cookiecutter.project_slug}}/requirements/production.txt +++ b/{{cookiecutter.project_slug}}/requirements/production.txt @@ -5,7 +5,7 @@ gunicorn==20.0.4 # https://github.com/benoitc/gunicorn psycopg2==2.8.4 --no-binary psycopg2 # https://github.com/psycopg/psycopg2 {%- if cookiecutter.use_whitenoise == 'n' %} -Collectfast==2.0.1 # https://github.com/antonagestam/collectfast +Collectfast==2.1.0 # https://github.com/antonagestam/collectfast {%- endif %} {%- if cookiecutter.use_sentry == "y" %} sentry-sdk==0.14.2 # https://github.com/getsentry/sentry-python From ff43635bb784e005593489368a72a101c79b865b Mon Sep 17 00:00:00 2001 From: browniebroke Date: Tue, 3 Mar 2020 11:00:36 +0000 Subject: [PATCH 062/182] Update celery from 4.4.0 to 4.4.1 --- {{cookiecutter.project_slug}}/requirements/base.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/base.txt b/{{cookiecutter.project_slug}}/requirements/base.txt index 99c9d4cd..44c2600f 100644 --- a/{{cookiecutter.project_slug}}/requirements/base.txt +++ b/{{cookiecutter.project_slug}}/requirements/base.txt @@ -10,7 +10,7 @@ whitenoise==5.0.1 # https://github.com/evansd/whitenoise {%- endif %} redis==3.4.1 # https://github.com/andymccurdy/redis-py {%- if cookiecutter.use_celery == "y" %} -celery==4.4.0 # pyup: < 5.0 # https://github.com/celery/celery +celery==4.4.1 # pyup: < 5.0 # https://github.com/celery/celery django-celery-beat==2.0.0 # https://github.com/celery/django-celery-beat {%- if cookiecutter.use_docker == 'y' %} flower==0.9.3 # https://github.com/mher/flower From 4825b932c7e81075db901abae019fcd358467a5c Mon Sep 17 00:00:00 2001 From: jeromecaisip Date: Tue, 3 Mar 2020 14:45:20 +0100 Subject: [PATCH 063/182] Optionally remove/add restframework according to choice --- {{cookiecutter.project_slug}}/requirements/base.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/{{cookiecutter.project_slug}}/requirements/base.txt b/{{cookiecutter.project_slug}}/requirements/base.txt index 99c9d4cd..601ee96f 100644 --- a/{{cookiecutter.project_slug}}/requirements/base.txt +++ b/{{cookiecutter.project_slug}}/requirements/base.txt @@ -29,5 +29,7 @@ django-compressor==2.4 # https://github.com/django-compressor/django-compressor {%- endif %} django-redis==4.11.0 # https://github.com/niwinz/django-redis +{%- if cookiecutter.use_drf == "y" %} # Django REST Framework djangorestframework==3.11.0 # https://github.com/encode/django-rest-framework +{%- endif %} From a24a6f337b6bf6c15b92df84937c0731d82f4401 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Tue, 3 Mar 2020 18:56:18 +0000 Subject: [PATCH 064/182] Add Heroku dyno for celery beat --- {{cookiecutter.project_slug}}/Procfile | 1 + 1 file changed, 1 insertion(+) diff --git a/{{cookiecutter.project_slug}}/Procfile b/{{cookiecutter.project_slug}}/Procfile index 5b8e9eaf..3838eafd 100644 --- a/{{cookiecutter.project_slug}}/Procfile +++ b/{{cookiecutter.project_slug}}/Procfile @@ -2,4 +2,5 @@ release: python manage.py migrate web: gunicorn config.wsgi:application {% if cookiecutter.use_celery == "y" -%} worker: celery worker --app=config.celery_app --loglevel=info +beat: celery beat --app=config.celery_app --loglevel=info {%- endif %} From 52dc302c9326dab67fe5f6673f032bfd15634f87 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Tue, 3 Mar 2020 19:37:27 +0000 Subject: [PATCH 065/182] Better error reporting in case of flake8 or black error --- tests/test_cookiecutter_generation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_cookiecutter_generation.py b/tests/test_cookiecutter_generation.py index 964c91d7..e51e4b9f 100755 --- a/tests/test_cookiecutter_generation.py +++ b/tests/test_cookiecutter_generation.py @@ -127,7 +127,7 @@ def test_flake8_passes(cookies, context_override): try: sh.flake8(str(result.project)) except sh.ErrorReturnCode as e: - pytest.fail(e) + pytest.fail(e.stdout.decode()) @pytest.mark.parametrize("context_override", SUPPORTED_COMBINATIONS, ids=_fixture_id) @@ -138,7 +138,7 @@ def test_black_passes(cookies, context_override): try: sh.black("--check", "--diff", "--exclude", "migrations", f"{result.project}/") except sh.ErrorReturnCode as e: - pytest.fail(e) + pytest.fail(e.stdout.decode()) def test_travis_invokes_pytest(cookies, context): From fab6b8724aea351dc9ef46e17245875bfaf719d2 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Tue, 3 Mar 2020 19:53:15 +0000 Subject: [PATCH 066/182] Test isort flake8-isort & fix issues fixes #2123 --- pytest.ini | 2 +- requirements.txt | 1 + {{cookiecutter.project_slug}}/.editorconfig | 4 ++-- {{cookiecutter.project_slug}}/config/api_router.py | 3 ++- {{cookiecutter.project_slug}}/config/celery_app.py | 1 + {{cookiecutter.project_slug}}/config/settings/production.py | 1 + {{cookiecutter.project_slug}}/config/urls.py | 6 +++--- {{cookiecutter.project_slug}}/requirements/local.txt | 1 + .../{{cookiecutter.project_slug}}/users/api/serializers.py | 1 + .../{{cookiecutter.project_slug}}/users/api/views.py | 2 +- .../{{cookiecutter.project_slug}}/users/forms.py | 2 +- .../{{cookiecutter.project_slug}}/users/tests/test_tasks.py | 1 - .../{{cookiecutter.project_slug}}/users/tests/test_urls.py | 2 +- .../{{cookiecutter.project_slug}}/users/urls.py | 2 +- .../{{cookiecutter.project_slug}}/users/views.py | 4 ++-- 15 files changed, 19 insertions(+), 14 deletions(-) diff --git a/pytest.ini b/pytest.ini index 5d5a9c93..edf3a7c3 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,4 +1,4 @@ [pytest] -addopts = -x --tb=short +addopts = --tb=short python_paths = . norecursedirs = .tox .git */migrations/* */static/* docs venv */{{cookiecutter.project_slug}}/* diff --git a/requirements.txt b/requirements.txt index 853ae4eb..56f72f9b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,6 +6,7 @@ binaryornot==0.4.4 # ------------------------------------------------------------------------------ black==19.10b0 flake8==3.7.9 +flake8-isort==2.8.0 # Testing # ------------------------------------------------------------------------------ diff --git a/{{cookiecutter.project_slug}}/.editorconfig b/{{cookiecutter.project_slug}}/.editorconfig index 792dd3b0..39c15f07 100644 --- a/{{cookiecutter.project_slug}}/.editorconfig +++ b/{{cookiecutter.project_slug}}/.editorconfig @@ -13,8 +13,8 @@ indent_style = space indent_size = 4 [*.py] -line_length = 120 -known_first_party = {{ cookiecutter.project_slug }} +line_length = 88 +known_first_party = {{cookiecutter.project_slug}},config multi_line_output = 3 default_section = THIRDPARTY recursive = true diff --git a/{{cookiecutter.project_slug}}/config/api_router.py b/{{cookiecutter.project_slug}}/config/api_router.py index 46a797a7..743069b2 100644 --- a/{{cookiecutter.project_slug}}/config/api_router.py +++ b/{{cookiecutter.project_slug}}/config/api_router.py @@ -1,5 +1,6 @@ -from rest_framework.routers import DefaultRouter, SimpleRouter from django.conf import settings +from rest_framework.routers import DefaultRouter, SimpleRouter + from {{ cookiecutter.project_slug }}.users.api.views import UserViewSet if settings.DEBUG: diff --git a/{{cookiecutter.project_slug}}/config/celery_app.py b/{{cookiecutter.project_slug}}/config/celery_app.py index e275f054..0728a649 100644 --- a/{{cookiecutter.project_slug}}/config/celery_app.py +++ b/{{cookiecutter.project_slug}}/config/celery_app.py @@ -1,4 +1,5 @@ import os + from celery import Celery # set the default Django settings module for the 'celery' program. diff --git a/{{cookiecutter.project_slug}}/config/settings/production.py b/{{cookiecutter.project_slug}}/config/settings/production.py index 36667b33..73ce4d64 100644 --- a/{{cookiecutter.project_slug}}/config/settings/production.py +++ b/{{cookiecutter.project_slug}}/config/settings/production.py @@ -1,3 +1,4 @@ +"""isort:skip_file""" {% if cookiecutter.use_sentry == 'y' -%} import logging diff --git a/{{cookiecutter.project_slug}}/config/urls.py b/{{cookiecutter.project_slug}}/config/urls.py index 382bf895..81860906 100644 --- a/{{cookiecutter.project_slug}}/config/urls.py +++ b/{{cookiecutter.project_slug}}/config/urls.py @@ -1,10 +1,10 @@ from django.conf import settings -from django.urls import include, path from django.conf.urls.static import static from django.contrib import admin -from django.views.generic import TemplateView +from django.urls import include, path from django.views import defaults as default_views -{% if cookiecutter.use_drf == 'y' -%} +from django.views.generic import TemplateView +{%- if cookiecutter.use_drf == 'y' %} from rest_framework.authtoken.views import obtain_auth_token {%- endif %} diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index e70cb63f..33c0dc36 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -19,6 +19,7 @@ pytest-sugar==0.9.2 # https://github.com/Frozenball/pytest-sugar # Code quality # ------------------------------------------------------------------------------ flake8==3.7.9 # https://github.com/PyCQA/flake8 +flake8-isort==2.8.0 # https://github.com/gforcada/flake8-isort coverage==5.0.3 # https://github.com/nedbat/coveragepy black==19.10b0 # https://github.com/ambv/black pylint-django==2.0.14 # https://github.com/PyCQA/pylint-django diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/api/serializers.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/api/serializers.py index bb52738b..04bf4c85 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/api/serializers.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/api/serializers.py @@ -1,4 +1,5 @@ from rest_framework import serializers + from {{ cookiecutter.project_slug }}.users.models import User diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/api/views.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/api/views.py index 7b5af999..288ea7ab 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/api/views.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/api/views.py @@ -1,7 +1,7 @@ from django.contrib.auth import get_user_model from rest_framework import status from rest_framework.decorators import action -from rest_framework.mixins import RetrieveModelMixin, ListModelMixin, UpdateModelMixin +from rest_framework.mixins import ListModelMixin, RetrieveModelMixin, UpdateModelMixin from rest_framework.response import Response from rest_framework.viewsets import GenericViewSet diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/forms.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/forms.py index 250cc904..25065419 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/forms.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/forms.py @@ -1,4 +1,4 @@ -from django.contrib.auth import get_user_model, forms +from django.contrib.auth import forms, get_user_model from django.core.exceptions import ValidationError from django.utils.translation import ugettext_lazy as _ diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_tasks.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_tasks.py index addb091d..61586b5c 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_tasks.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_tasks.py @@ -1,7 +1,6 @@ import pytest from celery.result import EagerResult - from {{ cookiecutter.project_slug }}.users.tasks import get_users_count from {{ cookiecutter.project_slug }}.users.tests.factories import UserFactory diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_urls.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_urls.py index 933396ba..aab6d0a8 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_urls.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_urls.py @@ -1,5 +1,5 @@ import pytest -from django.urls import reverse, resolve +from django.urls import resolve, reverse from {{ cookiecutter.project_slug }}.users.models import User diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/urls.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/urls.py index eff24dd0..8c8c7e2e 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/urls.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/urls.py @@ -1,9 +1,9 @@ from django.urls import path from {{ cookiecutter.project_slug }}.users.views import ( + user_detail_view, user_redirect_view, user_update_view, - user_detail_view, ) app_name = "users" diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/views.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/views.py index 5c0d5b5c..f0e81dff 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/views.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/views.py @@ -1,9 +1,9 @@ +from django.contrib import messages from django.contrib.auth import get_user_model from django.contrib.auth.mixins import LoginRequiredMixin from django.urls import reverse -from django.views.generic import DetailView, RedirectView, UpdateView -from django.contrib import messages from django.utils.translation import ugettext_lazy as _ +from django.views.generic import DetailView, RedirectView, UpdateView User = get_user_model() From e1141d699945d5dfbf1d163cea989e04dd06eb42 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Tue, 3 Mar 2020 20:33:44 +0000 Subject: [PATCH 067/182] Remove pytest-xdist to try get a better output --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 56f72f9b..bc876746 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,5 +13,4 @@ flake8-isort==2.8.0 tox==3.14.5 pytest==5.3.5 pytest-cookies==0.5.1 -pytest-xdist==1.31.0 pyyaml==5.3 From c8fc7cf119583018665b4dd71fa5c40f11a304b5 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Tue, 3 Mar 2020 20:46:13 +0000 Subject: [PATCH 068/182] Add pytest-instafail plugin to get failures earlier --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index bc876746..140dc2cd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,4 +13,5 @@ flake8-isort==2.8.0 tox==3.14.5 pytest==5.3.5 pytest-cookies==0.5.1 +pytest-instafail==0.4.1.post0 pyyaml==5.3 From 7f957564a19871022e7ee34b12de72f7eb4047ef Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Tue, 3 Mar 2020 20:46:35 +0000 Subject: [PATCH 069/182] Bump pytest verbosity --- pytest.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytest.ini b/pytest.ini index edf3a7c3..03ca1389 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,4 +1,4 @@ [pytest] -addopts = --tb=short +addopts = -v --tb=short python_paths = . norecursedirs = .tox .git */migrations/* */static/* docs venv */{{cookiecutter.project_slug}}/* From effb548b5de992349d86a27e1a50acc94eb92bae Mon Sep 17 00:00:00 2001 From: browniebroke Date: Wed, 4 Mar 2020 11:00:32 +0000 Subject: [PATCH 070/182] Update django from 2.2.10 to 2.2.11 --- {{cookiecutter.project_slug}}/requirements/base.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/base.txt b/{{cookiecutter.project_slug}}/requirements/base.txt index 44c2600f..e4bb31ba 100644 --- a/{{cookiecutter.project_slug}}/requirements/base.txt +++ b/{{cookiecutter.project_slug}}/requirements/base.txt @@ -19,7 +19,7 @@ flower==0.9.3 # https://github.com/mher/flower # Django # ------------------------------------------------------------------------------ -django==2.2.10 # pyup: < 3.0 # https://www.djangoproject.com/ +django==2.2.11 # pyup: < 3.0 # https://www.djangoproject.com/ django-environ==0.4.5 # https://github.com/joke2k/django-environ django-model-utils==4.0.0 # https://github.com/jazzband/django-model-utils django-allauth==0.41.0 # https://github.com/pennersr/django-allauth From 2fd0cf0e35aad2cf5743967c1620c1c5da7513d5 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Wed, 4 Mar 2020 11:00:36 +0000 Subject: [PATCH 071/182] Update ipdb from 0.13.1 to 0.13.2 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index 33c0dc36..80558f5c 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -1,7 +1,7 @@ -r ./base.txt Werkzeug==1.0.0 # https://github.com/pallets/werkzeug -ipdb==0.13.1 # https://github.com/gotcha/ipdb +ipdb==0.13.2 # https://github.com/gotcha/ipdb Sphinx==2.4.3 # https://github.com/sphinx-doc/sphinx {%- if cookiecutter.use_docker == 'y' %} psycopg2==2.8.4 --no-binary psycopg2 # https://github.com/psycopg/psycopg2 From 09fd30b6a87f004d0f319af28968c13ad317b01e Mon Sep 17 00:00:00 2001 From: browniebroke Date: Fri, 6 Mar 2020 11:00:31 +0000 Subject: [PATCH 072/182] Update sphinx from 2.4.3 to 2.4.4 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index 80558f5c..dcffd53e 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -2,7 +2,7 @@ Werkzeug==1.0.0 # https://github.com/pallets/werkzeug ipdb==0.13.2 # https://github.com/gotcha/ipdb -Sphinx==2.4.3 # https://github.com/sphinx-doc/sphinx +Sphinx==2.4.4 # https://github.com/sphinx-doc/sphinx {%- if cookiecutter.use_docker == 'y' %} psycopg2==2.8.4 --no-binary psycopg2 # https://github.com/psycopg/psycopg2 {%- else %} From 3a3550cd3f4abe2990298d2d9c5368e88bdf6817 Mon Sep 17 00:00:00 2001 From: jeromecaisip Date: Sun, 8 Mar 2020 17:55:19 +0100 Subject: [PATCH 073/182] Update base.txt --- {{cookiecutter.project_slug}}/requirements/base.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/base.txt b/{{cookiecutter.project_slug}}/requirements/base.txt index 601ee96f..3b72da7f 100644 --- a/{{cookiecutter.project_slug}}/requirements/base.txt +++ b/{{cookiecutter.project_slug}}/requirements/base.txt @@ -28,7 +28,6 @@ django-crispy-forms==1.9.0 # https://github.com/django-crispy-forms/django-cris django-compressor==2.4 # https://github.com/django-compressor/django-compressor {%- endif %} django-redis==4.11.0 # https://github.com/niwinz/django-redis - {%- if cookiecutter.use_drf == "y" %} # Django REST Framework djangorestframework==3.11.0 # https://github.com/encode/django-rest-framework From 9ec538962ec692a3a65241038b5b57906c01e559 Mon Sep 17 00:00:00 2001 From: Daniel Roy Greenfeld Date: Mon, 9 Mar 2020 13:51:23 -0700 Subject: [PATCH 074/182] Update FUNDING.yml --- .github/FUNDING.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 9f4c97f3..6ea27a8f 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,7 +1,7 @@ # These are supported funding model platforms github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] -patreon: danielroygreenfeld +patreon: roygreenfeld open_collective: # Replace with a single Open Collective username ko_fi: # Replace with a single Ko-fi username tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel From 427c69562e94063a650215f72a2524c6fe37c031 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Wed, 11 Mar 2020 11:00:31 +0000 Subject: [PATCH 075/182] Update mypy from 0.761 to 0.770 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index dcffd53e..ddc5d2a5 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -11,7 +11,7 @@ psycopg2-binary==2.8.4 # https://github.com/psycopg/psycopg2 # Testing # ------------------------------------------------------------------------------ -mypy==0.761 # https://github.com/python/mypy +mypy==0.770 # https://github.com/python/mypy django-stubs==1.4.0 # https://github.com/typeddjango/django-stubs pytest==5.3.5 # https://github.com/pytest-dev/pytest pytest-sugar==0.9.2 # https://github.com/Frozenball/pytest-sugar From 7e345d5fb3fa17bb1b547198dc1d223c2ef391c2 Mon Sep 17 00:00:00 2001 From: Agustin Scaramuzza Date: Wed, 11 Mar 2020 14:37:12 -0300 Subject: [PATCH 076/182] Add PYTHONDONTWRITEBYTECODE flag to local development Dockerfile --- CONTRIBUTORS.rst | 1 + {{cookiecutter.project_slug}}/compose/local/django/Dockerfile | 1 + 2 files changed, 2 insertions(+) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index 86804b69..edb2ccdd 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -49,6 +49,7 @@ Listed in alphabetical order. Adam Dobrawy `@ad-m`_ Adam Steele `@adammsteele`_ Agam Dua + Agustín Scaramuzza `@scaramagus`_ @scaramagus Alberto Sanchez `@alb3rto`_ Alex Tsai `@caffodian`_ Alvaro [Andor] `@andor-pierdelacabeza`_ diff --git a/{{cookiecutter.project_slug}}/compose/local/django/Dockerfile b/{{cookiecutter.project_slug}}/compose/local/django/Dockerfile index 94c79952..6a356ac6 100644 --- a/{{cookiecutter.project_slug}}/compose/local/django/Dockerfile +++ b/{{cookiecutter.project_slug}}/compose/local/django/Dockerfile @@ -1,6 +1,7 @@ FROM python:3.7-slim-buster ENV PYTHONUNBUFFERED 1 +ENV PYTHONDONTWRITEBYTECODE 1 RUN apt-get update \ # dependencies for building Python packages From 324e3074029cccb4d0e4b1ca155087798f7f88cc Mon Sep 17 00:00:00 2001 From: browniebroke Date: Fri, 13 Mar 2020 11:00:34 +0000 Subject: [PATCH 077/182] Update pre-commit from 2.1.1 to 2.2.0 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index ddc5d2a5..fd8c104a 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -26,7 +26,7 @@ pylint-django==2.0.14 # https://github.com/PyCQA/pylint-django {%- if cookiecutter.use_celery == 'y' %} pylint-celery==0.3 # https://github.com/PyCQA/pylint-celery {%- endif %} -pre-commit==2.1.1 # https://github.com/pre-commit/pre-commit +pre-commit==2.2.0 # https://github.com/pre-commit/pre-commit # Django # ------------------------------------------------------------------------------ From 81d9274e09fdbbd72ad959ac5daf1b8e93b0db57 Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Fri, 13 Mar 2020 07:21:10 -0700 Subject: [PATCH 078/182] Update pytest from 5.3.5 to 5.4.1 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 140dc2cd..bc8292a8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,7 +11,7 @@ flake8-isort==2.8.0 # Testing # ------------------------------------------------------------------------------ tox==3.14.5 -pytest==5.3.5 +pytest==5.4.1 pytest-cookies==0.5.1 pytest-instafail==0.4.1.post0 pyyaml==5.3 From 6d0a187addb1fb616568859f268ab503870d2d00 Mon Sep 17 00:00:00 2001 From: Daniel Roy Greenfeld Date: Fri, 13 Mar 2020 14:32:25 -0700 Subject: [PATCH 079/182] Update FUNDING.yml --- .github/FUNDING.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 6ea27a8f..5a5aefc7 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,6 +1,6 @@ # These are supported funding model platforms -github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +github: pydanny patreon: roygreenfeld open_collective: # Replace with a single Open Collective username ko_fi: # Replace with a single Ko-fi username From 397889050205bda8ee819200bb20920d3006b1d7 Mon Sep 17 00:00:00 2001 From: Andrew-Chen-Wang Date: Sat, 14 Mar 2020 13:43:37 -0400 Subject: [PATCH 080/182] Adjusted readability * Changed Vanilla/Plain Django-Anymail to Other SMTP * Made Mailgun default again * config/production.py adjusted if conditions according to @browniebroke --- cookiecutter.json | 4 +- .../config/settings/production.py | 81 ++++++++++--------- .../requirements/production.txt | 8 +- 3 files changed, 49 insertions(+), 44 deletions(-) diff --git a/cookiecutter.json b/cookiecutter.json index 5e85af48..cfa1b346 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -34,15 +34,15 @@ "None" ], "mail_service": [ - "{% if cookiecutter.cloud_provider == 'AWS' %}Amazon SES{% else %}Plain/Vanilla Django-Anymail{% endif %}", "Mailgun", + "Amazon SES", "Mailjet", "Mandrill", "Postmark", "Sendgrid", "SendinBlue", "SparkPost", - "Plain/Vanilla Django-Anymail" + "Other SMTP" ], "use_drf": "n", "custom_bootstrap_compilation": "n", diff --git a/{{cookiecutter.project_slug}}/config/settings/production.py b/{{cookiecutter.project_slug}}/config/settings/production.py index e227186e..6b07141d 100644 --- a/{{cookiecutter.project_slug}}/config/settings/production.py +++ b/{{cookiecutter.project_slug}}/config/settings/production.py @@ -187,62 +187,58 @@ ADMIN_URL = env("DJANGO_ADMIN_URL") # ------------------------------------------------------------------------------ # https://anymail.readthedocs.io/en/stable/installation/#installing-anymail INSTALLED_APPS += ["anymail"] # noqa F405 -{%- if cookiecutter.mail_service == 'Amazon SES' %} -EMAIL_BACKEND = "anymail.backends.amazon_ses.EmailBackend" -{%- elif cookiecutter.mail_service == 'Mailgun' %} -EMAIL_BACKEND = "anymail.backends.mailgun.EmailBackend" -{%- elif cookiecutter.mail_service == 'Mailjet' %} -EMAIL_BACKEND = "anymail.backends.mailjet.EmailBackend" -{%- elif cookiecutter.mail_service == 'Mandrill' %} -EMAIL_BACKEND = "anymail.backends.mandrill.EmailBackend" -{%- elif cookiecutter.mail_service == 'Postmark' %} -EMAIL_BACKEND = "anymail.backends.postmark.EmailBackend" -{%- elif cookiecutter.mail_service == 'Sendgrid' %} -EMAIL_BACKEND = "anymail.backends.sendgrid.EmailBackend" -{%- elif cookiecutter.mail_service == 'SendinBlue' %} -EMAIL_BACKEND = "anymail.backends.sendinblue.EmailBackend" -{%- elif cookiecutter.mail_service == 'SparkPost' %} -EMAIL_BACKEND = "anymail.backends.sparkpost.EmailBackend" -{%- elif cookiecutter.mail_service == 'Plain/Vanilla Django-Anymail' %} -EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend" -# https://docs.djangoproject.com/en/3.0/ref/settings/#email-backend -{%- endif %} +# https://docs.djangoproject.com/en/dev/ref/settings/#email-backend # https://anymail.readthedocs.io/en/stable/installation/#anymail-settings-reference +{%- if cookiecutter.mail_service == 'Mailgun' %} +# https://anymail.readthedocs.io/en/stable/esps/mailgun/ +EMAIL_BACKEND = "anymail.backends.mailgun.EmailBackend" ANYMAIL = { - # https://anymail.readthedocs.io/en/stable/esps/ - {%- if cookiecutter.mail_service == 'Amazon SES' %} - # https://anymail.readthedocs.io/en/stable/esps/amazon_ses/ - {%- elif cookiecutter.mail_service == 'Mailgun' %} "MAILGUN_API_KEY": env("MAILGUN_API_KEY"), "MAILGUN_SENDER_DOMAIN": env("MAILGUN_DOMAIN"), "MAILGUN_API_URL": env( "MAILGUN_API_URL", default="https://api.mailgun.net/v3" ), - # https://anymail.readthedocs.io/en/stable/esps/mailgun/ - {%- elif cookiecutter.mail_service == 'Mailjet' %} +} +{%- elif cookiecutter.mail_service == 'Amazon SES' %} +# https://anymail.readthedocs.io/en/stable/esps/amazon_ses/ +EMAIL_BACKEND = "anymail.backends.amazon_ses.EmailBackend" +ANYMAIL = {} +{%- elif cookiecutter.mail_service == 'Mailjet' %} +# https://anymail.readthedocs.io/en/stable/esps/mailjet/ +EMAIL_BACKEND = "anymail.backends.mailjet.EmailBackend" +ANYMAIL = { "MAILJET_API_KEY": env("MAILJET_API_KEY"), "MAILJET_SECRET_KEY": env("MAILJET_SECRET_KEY"), "MAILJET_API_URL": env( "MAILJET_API_URL", default="https://api.mailjet.com/v3" ), - # https://anymail.readthedocs.io/en/stable/esps/mailjet/ - {%- elif cookiecutter.mail_service == 'Mandrill' %} +} +{%- elif cookiecutter.mail_service == 'Mandrill' %} +# https://anymail.readthedocs.io/en/stable/esps/mandrill/ +EMAIL_BACKEND = "anymail.backends.mandrill.EmailBackend" +ANYMAIL = { "MANDRILL_API_KEY": env("MANDRILL_API_KEY"), "MANDRILL_API_URL": env( "MANDRILL_API_URL", default="https://mandrillapp.com/api/1.0" ), - # https://anymail.readthedocs.io/en/stable/esps/mandrill/ - {%- elif cookiecutter.mail_service == 'Postmark' %} +} +{%- elif cookiecutter.mail_service == 'Postmark' %} +# https://anymail.readthedocs.io/en/stable/esps/postmark/ +EMAIL_BACKEND = "anymail.backends.postmark.EmailBackend" +ANYMAIL = { "POSTMARK_SERVER_TOKEN": env("POSTMARK_SERVER_TOKEN"), "POSTMARK_API_URL": env( "POSTMARK_API_URL", default="https://api.postmarkapp.com/" ), - # https://anymail.readthedocs.io/en/stable/esps/postmark/ - {%- elif cookiecutter.mail_service == 'Sendgrid' %} +} +{%- elif cookiecutter.mail_service == 'Sendgrid' %} +# https://anymail.readthedocs.io/en/stable/esps/sendgrid/ +EMAIL_BACKEND = "anymail.backends.sendgrid.EmailBackend" +ANYMAIL = { "SENDGRID_API_KEY": env("SENDGRID_API_KEY"), "SENDGRID_GENERATE_MESSAGE_ID": env("SENDGRID_GENERATE_MESSAGE_ID"), "SENDGRID_MERGE_FIELD_FORMAT": env("SENDGRID_MERGE_FIELD_FORMAT"), @@ -250,23 +246,32 @@ ANYMAIL = { "SENDGRID_API_URL", default="https://api.sendgrid.com/v3/" ), - # https://anymail.readthedocs.io/en/stable/esps/sendgrid/ - {%- elif cookiecutter.mail_service == 'SendinBlue' %} +} +{%- elif cookiecutter.mail_service == 'SendinBlue' %} +# https://anymail.readthedocs.io/en/stable/esps/sendinblue/ +EMAIL_BACKEND = "anymail.backends.sendinblue.EmailBackend" +ANYMAIL = { "SENDINBLUE_API_KEY": env("SENDINBLUE_API_KEY"), "SENDINBLUE_API_URL": env( "SENDINBLUE_API_URL", default="https://api.sendinblue.com/v3/" ), - # https://anymail.readthedocs.io/en/stable/esps/sendinblue/ - {%- elif cookiecutter.mail_service == 'SparkPost' %} +} +{%- elif cookiecutter.mail_service == 'SparkPost' %} +# https://anymail.readthedocs.io/en/stable/esps/sparkpost/ +EMAIL_BACKEND = "anymail.backends.sparkpost.EmailBackend" +ANYMAIL = { "SPARKPOST_API_KEY": env("SPARKPOST_API_KEY"), "SPARKPOST_API_URL": env( "SPARKPOST_API_URL", default="https://api.sparkpost.com/api/v1" ), - # https://anymail.readthedocs.io/en/stable/esps/sparkpost/ - {%- endif %} } +{%- elif cookiecutter.mail_service == 'Other SMTP' %} +# https://anymail.readthedocs.io/en/stable/esps +EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend" +ANYMAIL = {} +{%- endif %} {% if cookiecutter.use_compressor == 'y' -%} # django-compressor diff --git a/{{cookiecutter.project_slug}}/requirements/production.txt b/{{cookiecutter.project_slug}}/requirements/production.txt index 06e2a4d2..da9cbc97 100644 --- a/{{cookiecutter.project_slug}}/requirements/production.txt +++ b/{{cookiecutter.project_slug}}/requirements/production.txt @@ -18,10 +18,10 @@ django-storages[boto3]==1.9.1 # https://github.com/jschneier/django-storages {%- elif cookiecutter.cloud_provider == 'GCP' %} django-storages[google]==1.9.1 # https://github.com/jschneier/django-storages {%- endif %} -{%- if cookiecutter.mail_service == 'Amazon SES' %} -django-anymail[amazon_ses]==7.0.0 # https://github.com/anymail/django-anymail -{%- elif cookiecutter.mail_service == 'Mailgun' %} +{%- if cookiecutter.mail_service == 'Mailgun' %} django-anymail[mailgun]==7.0.0 # https://github.com/anymail/django-anymail +{%- elif cookiecutter.mail_service == 'Amazon SES' %} +django-anymail[amazon_ses]==7.0.0 # https://github.com/anymail/django-anymail {%- elif cookiecutter.mail_service == 'Mailjet' %} django-anymail[mailjet]==7.0.0 # https://github.com/anymail/django-anymail {%- elif cookiecutter.mail_service == 'Mandrill' %} @@ -34,6 +34,6 @@ django-anymail[sendgrid]==7.0.0 # https://github.com/anymail/django-anymail django-anymail[sendinblue]==7.0.0 # https://github.com/anymail/django-anymail {%- elif cookiecutter.mail_service == 'SparkPost' %} django-anymail[sparkpost]==7.0.0 # https://github.com/anymail/django-anymail -{%- elif cookiecutter.mail_service == 'Plain/Vanilla Django-Anymail' %} +{%- elif cookiecutter.mail_service == 'Other SMTP' %} django-anymail==7.0.0 # https://github.com/anymail/django-anymail {%- endif %} From 5e1d1dd1c39b92bae280ae071b3e20cad1c88ae2 Mon Sep 17 00:00:00 2001 From: Andrew-Chen-Wang Date: Sat, 14 Mar 2020 15:09:05 -0400 Subject: [PATCH 081/182] Fixed tests for mail providers --- tests/test_cookiecutter_generation.py | 20 ++++++------- .../config/settings/production.py | 29 +++++-------------- 2 files changed, 16 insertions(+), 33 deletions(-) diff --git a/tests/test_cookiecutter_generation.py b/tests/test_cookiecutter_generation.py index d4db1085..91f44ae5 100755 --- a/tests/test_cookiecutter_generation.py +++ b/tests/test_cookiecutter_generation.py @@ -48,6 +48,15 @@ SUPPORTED_COMBINATIONS = [ {"cloud_provider": "GCP", "use_whitenoise": "n"}, {"cloud_provider": "None", "use_whitenoise": "y"}, # Note: cloud_provider=None AND use_whitenoise=n is not supported + {"mail_service": "Mailgun"}, + {"mail_service": "Amazon SES"}, + {"mail_service": "Mailjet"}, + {"mail_service": "Mandrill"}, + {"mail_service": "Postmark"}, + {"mail_service": "Sendgrid"}, + {"mail_service": "SendinBlue"}, + {"mail_service": "SparkPost"}, + {"mail_service": "Other SMTP"}, {"use_drf": "y"}, {"use_drf": "n"}, {"js_task_runner": "None"}, @@ -73,21 +82,10 @@ SUPPORTED_COMBINATIONS = [ {"keep_local_envs_in_vcs": "n"}, {"debug": "y"}, {"debug": "n"}, - {"mail_service", "AWS SES"}, - {"mail_service", "Mailgun"}, - {"mail_service", "Mailjet"}, - {"mail_service", "Mandrill"}, - {"mail_service", "Postmark"}, - {"mail_service", "Sendgrid"}, - {"mail_service", "SendinBlue"}, - {"mail_service", "SparkPost"}, - {"mail_service", "Other SMTP"}, ] UNSUPPORTED_COMBINATIONS = [ {"cloud_provider": "None", "use_whitenoise": "n"}, - {"cloud_provider": "GCP", "mail_service": "Amazon SES"}, - {"cloud_provider": "None", "mail_service": "Amazon SES"} ] diff --git a/{{cookiecutter.project_slug}}/config/settings/production.py b/{{cookiecutter.project_slug}}/config/settings/production.py index 6b07141d..13e8c697 100644 --- a/{{cookiecutter.project_slug}}/config/settings/production.py +++ b/{{cookiecutter.project_slug}}/config/settings/production.py @@ -195,10 +195,7 @@ EMAIL_BACKEND = "anymail.backends.mailgun.EmailBackend" ANYMAIL = { "MAILGUN_API_KEY": env("MAILGUN_API_KEY"), "MAILGUN_SENDER_DOMAIN": env("MAILGUN_DOMAIN"), - "MAILGUN_API_URL": env( - "MAILGUN_API_URL", - default="https://api.mailgun.net/v3" - ), + "MAILGUN_API_URL": env("MAILGUN_API_URL", default="https://api.mailgun.net/v3"), } {%- elif cookiecutter.mail_service == 'Amazon SES' %} # https://anymail.readthedocs.io/en/stable/esps/amazon_ses/ @@ -210,10 +207,7 @@ EMAIL_BACKEND = "anymail.backends.mailjet.EmailBackend" ANYMAIL = { "MAILJET_API_KEY": env("MAILJET_API_KEY"), "MAILJET_SECRET_KEY": env("MAILJET_SECRET_KEY"), - "MAILJET_API_URL": env( - "MAILJET_API_URL", - default="https://api.mailjet.com/v3" - ), + "MAILJET_API_URL": env("MAILJET_API_URL", default="https://api.mailjet.com/v3"), } {%- elif cookiecutter.mail_service == 'Mandrill' %} # https://anymail.readthedocs.io/en/stable/esps/mandrill/ @@ -221,8 +215,7 @@ EMAIL_BACKEND = "anymail.backends.mandrill.EmailBackend" ANYMAIL = { "MANDRILL_API_KEY": env("MANDRILL_API_KEY"), "MANDRILL_API_URL": env( - "MANDRILL_API_URL", - default="https://mandrillapp.com/api/1.0" + "MANDRILL_API_URL", default="https://mandrillapp.com/api/1.0" ), } {%- elif cookiecutter.mail_service == 'Postmark' %} @@ -230,10 +223,7 @@ ANYMAIL = { EMAIL_BACKEND = "anymail.backends.postmark.EmailBackend" ANYMAIL = { "POSTMARK_SERVER_TOKEN": env("POSTMARK_SERVER_TOKEN"), - "POSTMARK_API_URL": env( - "POSTMARK_API_URL", - default="https://api.postmarkapp.com/" - ), + "POSTMARK_API_URL": env("POSTMARK_API_URL", default="https://api.postmarkapp.com/"), } {%- elif cookiecutter.mail_service == 'Sendgrid' %} # https://anymail.readthedocs.io/en/stable/esps/sendgrid/ @@ -242,10 +232,7 @@ ANYMAIL = { "SENDGRID_API_KEY": env("SENDGRID_API_KEY"), "SENDGRID_GENERATE_MESSAGE_ID": env("SENDGRID_GENERATE_MESSAGE_ID"), "SENDGRID_MERGE_FIELD_FORMAT": env("SENDGRID_MERGE_FIELD_FORMAT"), - "SENDGRID_API_URL": env( - "SENDGRID_API_URL", - default="https://api.sendgrid.com/v3/" - ), + "SENDGRID_API_URL": env("SENDGRID_API_URL", default="https://api.sendgrid.com/v3/"), } {%- elif cookiecutter.mail_service == 'SendinBlue' %} # https://anymail.readthedocs.io/en/stable/esps/sendinblue/ @@ -253,8 +240,7 @@ EMAIL_BACKEND = "anymail.backends.sendinblue.EmailBackend" ANYMAIL = { "SENDINBLUE_API_KEY": env("SENDINBLUE_API_KEY"), "SENDINBLUE_API_URL": env( - "SENDINBLUE_API_URL", - default="https://api.sendinblue.com/v3/" + "SENDINBLUE_API_URL", default="https://api.sendinblue.com/v3/" ), } {%- elif cookiecutter.mail_service == 'SparkPost' %} @@ -263,8 +249,7 @@ EMAIL_BACKEND = "anymail.backends.sparkpost.EmailBackend" ANYMAIL = { "SPARKPOST_API_KEY": env("SPARKPOST_API_KEY"), "SPARKPOST_API_URL": env( - "SPARKPOST_API_URL", - default="https://api.sparkpost.com/api/v1" + "SPARKPOST_API_URL", default="https://api.sparkpost.com/api/v1" ), } {%- elif cookiecutter.mail_service == 'Other SMTP' %} From 95057c47695c4a7f0535dd7aba7b13c6f004eb1c Mon Sep 17 00:00:00 2001 From: browniebroke Date: Sun, 15 Mar 2020 11:00:30 +0000 Subject: [PATCH 082/182] Update django-stubs from 1.4.0 to 1.5.0 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index fd8c104a..ee2e1d41 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -12,7 +12,7 @@ psycopg2-binary==2.8.4 # https://github.com/psycopg/psycopg2 # Testing # ------------------------------------------------------------------------------ mypy==0.770 # https://github.com/python/mypy -django-stubs==1.4.0 # https://github.com/typeddjango/django-stubs +django-stubs==1.5.0 # https://github.com/typeddjango/django-stubs pytest==5.3.5 # https://github.com/pytest-dev/pytest pytest-sugar==0.9.2 # https://github.com/Frozenball/pytest-sugar From fa8311405d98bef284301424006c93cf4e7fc06e Mon Sep 17 00:00:00 2001 From: Guilherme Guy Date: Sun, 15 Mar 2020 09:23:21 -0300 Subject: [PATCH 083/182] Fixes gitlabCI failing due to postgres config --- {{cookiecutter.project_slug}}/.gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/{{cookiecutter.project_slug}}/.gitlab-ci.yml b/{{cookiecutter.project_slug}}/.gitlab-ci.yml index 15ff73b1..91ad7238 100644 --- a/{{cookiecutter.project_slug}}/.gitlab-ci.yml +++ b/{{cookiecutter.project_slug}}/.gitlab-ci.yml @@ -6,6 +6,7 @@ variables: POSTGRES_USER: '{{ cookiecutter.project_slug }}' POSTGRES_PASSWORD: '' POSTGRES_DB: 'test_{{ cookiecutter.project_slug }}' + POSTGRES_HOST_AUTH_METHOD: trust flake8: stage: lint From 0822add31145a6a8ba27ce8455087b841f29a3c8 Mon Sep 17 00:00:00 2001 From: Guilherme Guy Date: Sun, 15 Mar 2020 09:29:07 -0300 Subject: [PATCH 084/182] Adds @guilherme1guy to CONTRIBUTORS --- CONTRIBUTORS.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index 86804b69..fb65dc27 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -118,6 +118,7 @@ Listed in alphabetical order. Garry Cairns `@garry-cairns`_ Garry Polley `@garrypolley`_ Gilbishkosma `@Gilbishkosma`_ + Guilherme Guy `@guilherme1guy`_ Hamish Durkin `@durkode`_ Hana Quadara `@hanaquadara`_ Harry Moreno `@morenoh149`_ @morenoh149 @@ -275,6 +276,7 @@ Listed in alphabetical order. .. _@dhepper: https://github.com/dhepper .. _@dot2dotseurat: https://github.com/dot2dotseurat .. _@dsclementsen: https://github.com/dsclementsen +.. _@guilherme1guy: https://github.com/guilherme1guy .. _@durkode: https://github.com/durkode .. _@Egregors: https://github.com/Egregors .. _@epileptic-fish: https://gihub.com/epileptic-fish From 783e61bee7677bc31c8d614d775120430c22df6d Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Sun, 15 Mar 2020 19:11:43 +0000 Subject: [PATCH 085/182] Fix broken link in list of contributors --- CONTRIBUTORS.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index 32616572..d2418f8a 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -353,6 +353,7 @@ Listed in alphabetical order. .. _@rolep: https://github.com/rolep .. _@romanosipenko: https://github.com/romanosipenko .. _@saschalalala: https://github.com/saschalalala +.. _@scaramagus: https://github.com/scaramagus .. _@shireenrao: https://github.com/shireenrao .. _@show0k: https://github.com/show0k .. _@shultz: https://github.com/shultz From 530868d072248b4472fb09a42e511c6024f361dd Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Sun, 15 Mar 2020 19:20:44 +0000 Subject: [PATCH 086/182] Move "rest_framework" in THIRD_PARTY_APPS --- {{cookiecutter.project_slug}}/config/settings/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/config/settings/base.py b/{{cookiecutter.project_slug}}/config/settings/base.py index 22b1fed8..c3941fd9 100644 --- a/{{cookiecutter.project_slug}}/config/settings/base.py +++ b/{{cookiecutter.project_slug}}/config/settings/base.py @@ -75,11 +75,11 @@ THIRD_PARTY_APPS = [ "allauth", "allauth.account", "allauth.socialaccount", - "rest_framework", {%- if cookiecutter.use_celery == 'y' %} "django_celery_beat", {%- endif %} {%- if cookiecutter.use_drf == "y" %} + "rest_framework", "rest_framework.authtoken", {%- endif %} ] From 090b93c01ebc5333c477cc9f955c6a9924c90bbc Mon Sep 17 00:00:00 2001 From: James Williams <33026008+jameswilliams1@users.noreply.github.com> Date: Sun, 15 Mar 2020 22:16:40 +0000 Subject: [PATCH 087/182] remove setting compress_enabled to null in .django --- {{cookiecutter.project_slug}}/.envs/.production/.django | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/{{cookiecutter.project_slug}}/.envs/.production/.django b/{{cookiecutter.project_slug}}/.envs/.production/.django index 2c2e94f2..ae13ee01 100644 --- a/{{cookiecutter.project_slug}}/.envs/.production/.django +++ b/{{cookiecutter.project_slug}}/.envs/.production/.django @@ -31,11 +31,7 @@ DJANGO_GCP_STORAGE_BUCKET_NAME= # django-allauth # ------------------------------------------------------------------------------ DJANGO_ACCOUNT_ALLOW_REGISTRATION=True -{% if cookiecutter.use_compressor == 'y' %} -# django-compressor -# ------------------------------------------------------------------------------ -COMPRESS_ENABLED= -{% endif %} + # Gunicorn # ------------------------------------------------------------------------------ WEB_CONCURRENCY=4 From a553fa9aafe89a1daec41e7d1a6e509f0b867754 Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Mon, 16 Mar 2020 12:53:12 -0700 Subject: [PATCH 088/182] Update flake8-isort from 2.8.0 to 2.9.0 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index bc8292a8..6894fa8f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,7 +6,7 @@ binaryornot==0.4.4 # ------------------------------------------------------------------------------ black==19.10b0 flake8==3.7.9 -flake8-isort==2.8.0 +flake8-isort==2.9.0 # Testing # ------------------------------------------------------------------------------ From e3486dc782ad87cf994fb5f465a98dee6b23e019 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Tue, 17 Mar 2020 11:00:31 +0000 Subject: [PATCH 089/182] Update celery from 4.4.1 to 4.4.2 --- {{cookiecutter.project_slug}}/requirements/base.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/base.txt b/{{cookiecutter.project_slug}}/requirements/base.txt index d645dc05..7ef43601 100644 --- a/{{cookiecutter.project_slug}}/requirements/base.txt +++ b/{{cookiecutter.project_slug}}/requirements/base.txt @@ -10,7 +10,7 @@ whitenoise==5.0.1 # https://github.com/evansd/whitenoise {%- endif %} redis==3.4.1 # https://github.com/andymccurdy/redis-py {%- if cookiecutter.use_celery == "y" %} -celery==4.4.1 # pyup: < 5.0 # https://github.com/celery/celery +celery==4.4.2 # pyup: < 5.0 # https://github.com/celery/celery django-celery-beat==2.0.0 # https://github.com/celery/django-celery-beat {%- if cookiecutter.use_docker == 'y' %} flower==0.9.3 # https://github.com/mher/flower From 61476eaca1fdd60fbb038367378e903fb5f66bb2 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Tue, 17 Mar 2020 11:00:35 +0000 Subject: [PATCH 090/182] Update flake8-isort from 2.8.0 to 2.9.0 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index ee2e1d41..00f8bcd1 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -19,7 +19,7 @@ pytest-sugar==0.9.2 # https://github.com/Frozenball/pytest-sugar # Code quality # ------------------------------------------------------------------------------ flake8==3.7.9 # https://github.com/PyCQA/flake8 -flake8-isort==2.8.0 # https://github.com/gforcada/flake8-isort +flake8-isort==2.9.0 # https://github.com/gforcada/flake8-isort coverage==5.0.3 # https://github.com/nedbat/coveragepy black==19.10b0 # https://github.com/ambv/black pylint-django==2.0.14 # https://github.com/PyCQA/pylint-django From 06a880164a434df3b27618d60c12a89701329fc0 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Tue, 17 Mar 2020 11:00:39 +0000 Subject: [PATCH 091/182] Update coverage from 5.0.3 to 5.0.4 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index ee2e1d41..cba162d5 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -20,7 +20,7 @@ pytest-sugar==0.9.2 # https://github.com/Frozenball/pytest-sugar # ------------------------------------------------------------------------------ flake8==3.7.9 # https://github.com/PyCQA/flake8 flake8-isort==2.8.0 # https://github.com/gforcada/flake8-isort -coverage==5.0.3 # https://github.com/nedbat/coveragepy +coverage==5.0.4 # https://github.com/nedbat/coveragepy black==19.10b0 # https://github.com/ambv/black pylint-django==2.0.14 # https://github.com/PyCQA/pylint-django {%- if cookiecutter.use_celery == 'y' %} From 5498716c74542a604fe599956968c7bdc67f576b Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Tue, 17 Mar 2020 15:35:42 +0000 Subject: [PATCH 092/182] Fix isort --- {{cookiecutter.project_slug}}/config/settings/base.py | 3 +-- {{cookiecutter.project_slug}}/config/wsgi.py | 2 +- .../merge_production_dotenvs_in_dotenv.py | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/{{cookiecutter.project_slug}}/config/settings/base.py b/{{cookiecutter.project_slug}}/config/settings/base.py index fe2131c5..a0bf8f0a 100644 --- a/{{cookiecutter.project_slug}}/config/settings/base.py +++ b/{{cookiecutter.project_slug}}/config/settings/base.py @@ -1,11 +1,10 @@ """ Base settings to build other settings files upon. """ +from pathlib import Path import environ -from pathlib import Path - ROOT_DIR = Path(__file__).parents[2] # {{ cookiecutter.project_slug }}/) APPS_DIR = ROOT_DIR / "{{ cookiecutter.project_slug }}" diff --git a/{{cookiecutter.project_slug}}/config/wsgi.py b/{{cookiecutter.project_slug}}/config/wsgi.py index b5755c5c..fccfea35 100644 --- a/{{cookiecutter.project_slug}}/config/wsgi.py +++ b/{{cookiecutter.project_slug}}/config/wsgi.py @@ -15,9 +15,9 @@ framework. """ import os import sys +from pathlib import Path from django.core.wsgi import get_wsgi_application -from pathlib import Path # This allows easy placement of apps within the interior # {{ cookiecutter.project_slug }} directory. diff --git a/{{cookiecutter.project_slug}}/merge_production_dotenvs_in_dotenv.py b/{{cookiecutter.project_slug}}/merge_production_dotenvs_in_dotenv.py index b204494e..936e2406 100644 --- a/{{cookiecutter.project_slug}}/merge_production_dotenvs_in_dotenv.py +++ b/{{cookiecutter.project_slug}}/merge_production_dotenvs_in_dotenv.py @@ -1,6 +1,6 @@ import os -from typing import Sequence from pathlib import Path +from typing import Sequence import pytest From 984b5bcfbecf61f154b88bcb036fbba1fd717c65 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Tue, 17 Mar 2020 15:46:55 +0000 Subject: [PATCH 093/182] Nicer syntax to join paths --- .../merge_production_dotenvs_in_dotenv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/merge_production_dotenvs_in_dotenv.py b/{{cookiecutter.project_slug}}/merge_production_dotenvs_in_dotenv.py index 936e2406..d1170eff 100644 --- a/{{cookiecutter.project_slug}}/merge_production_dotenvs_in_dotenv.py +++ b/{{cookiecutter.project_slug}}/merge_production_dotenvs_in_dotenv.py @@ -5,7 +5,7 @@ from typing import Sequence import pytest ROOT_DIR_PATH = Path(__file__).parent.resolve() -PRODUCTION_DOTENVS_DIR_PATH = ROOT_DIR_PATH.joinpath(".envs", ".production") +PRODUCTION_DOTENVS_DIR_PATH = ROOT_DIR_PATH / ".envs" / ".production" PRODUCTION_DOTENV_FILE_PATHS = [ PRODUCTION_DOTENVS_DIR_PATH / ".django", PRODUCTION_DOTENVS_DIR_PATH / ".postgres", From ab99cc768ff9d5253ae44b50d3e2762fbdc96ec0 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Tue, 17 Mar 2020 18:26:38 +0000 Subject: [PATCH 094/182] Adding @highpost to the list of contributors Helped in writing code to rule out an issue with the template --- CONTRIBUTORS.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index af13839b..075b3f32 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -99,6 +99,7 @@ Listed in alphabetical order. Dani Hodovic `@danihodovic`_ Daniel Hepper `@dhepper`_ @danielhepper Daniel Hillier `@danifus`_ + Daniel Sears `@highpost`_ @highpost Daniele Tricoli `@eriol`_ David Díaz `@ddiazpinto`_ @DavidDiazPinto Davit Tovmasyan `@davitovmasyan`_ @@ -301,6 +302,7 @@ Listed in alphabetical order. .. _@hairychris: https://github.com/hairychris .. _@hanaquadara: https://github.com/hanaquadara .. _@hendrikschneider: https://github.com/hendrikschneider +.. _@highpost: https://github.com/highpost .. _@hjwp: https://github.com/hjwp .. _@howiezhao: https://github.com/howiezhao .. _@IanLee1521: https://github.com/IanLee1521 From 92bbddc2901c5720042fcadbbceaa68642e7cf3d Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Tue, 17 Mar 2020 18:41:27 +0000 Subject: [PATCH 095/182] Change style for pytest marker Update pytest.mark.django_db to be more consistent with rest of the project --- .../{{cookiecutter.project_slug}}/users/tests/test_tasks.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_tasks.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_tasks.py index 61586b5c..41d5af29 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_tasks.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_tasks.py @@ -4,8 +4,9 @@ from celery.result import EagerResult from {{ cookiecutter.project_slug }}.users.tasks import get_users_count from {{ cookiecutter.project_slug }}.users.tests.factories import UserFactory +pytestmark = pytest.mark.django_db + -@pytest.mark.django_db def test_user_count(settings): """A basic test to execute the get_users_count Celery task.""" UserFactory.create_batch(3) From 5b9161e16e7789a423aeb788c8c0296c8a2a6906 Mon Sep 17 00:00:00 2001 From: Demetris Stavrou <1180929+demestav@users.noreply.github.com> Date: Tue, 17 Mar 2020 22:11:16 +0200 Subject: [PATCH 096/182] Fixed pre-commit files selector regex --- {{cookiecutter.project_slug}}/.pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml index 4b72ee80..c50fefe9 100644 --- a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml +++ b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml @@ -7,7 +7,7 @@ repos: rev: master hooks: - id: trailing-whitespace - files: (^|/)a/.+\.(py|html|sh|css|js)$ + files: (^|/).+\.(py|html|sh|css|js)$ - repo: local hooks: From 67aeb8c5c6889d7e36732a455cd8b93402e34afa Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Wed, 18 Mar 2020 23:05:19 -0700 Subject: [PATCH 097/182] Update pyyaml from 5.3 to 5.3.1 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 6894fa8f..81fbf524 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,4 +14,4 @@ tox==3.14.5 pytest==5.4.1 pytest-cookies==0.5.1 pytest-instafail==0.4.1.post0 -pyyaml==5.3 +pyyaml==5.3.1 From 12a4bd27e8a3e5754c8ec78271f34ce7024a0f07 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Sat, 21 Mar 2020 11:00:31 +0000 Subject: [PATCH 098/182] Update sentry-sdk from 0.14.2 to 0.14.3 --- {{cookiecutter.project_slug}}/requirements/production.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/production.txt b/{{cookiecutter.project_slug}}/requirements/production.txt index da9cbc97..a8bc31dc 100644 --- a/{{cookiecutter.project_slug}}/requirements/production.txt +++ b/{{cookiecutter.project_slug}}/requirements/production.txt @@ -8,7 +8,7 @@ psycopg2==2.8.4 --no-binary psycopg2 # https://github.com/psycopg/psycopg2 Collectfast==2.1.0 # https://github.com/antonagestam/collectfast {%- endif %} {%- if cookiecutter.use_sentry == "y" %} -sentry-sdk==0.14.2 # https://github.com/getsentry/sentry-python +sentry-sdk==0.14.3 # https://github.com/getsentry/sentry-python {%- endif %} # Django From 484fa4ae77b2115db6fe50f494329a3c34a8f481 Mon Sep 17 00:00:00 2001 From: Andrew-Chen-Wang Date: Sun, 22 Mar 2020 13:31:52 -0400 Subject: [PATCH 099/182] Added unsupported mail_service combinations * Added default yaml Loader for pre_gen_projects.py --- docs/project-generation-options.rst | 14 ++++----- hooks/pre_gen_project.py | 12 ++++++++ tests/test_cookiecutter_generation.py | 42 +++++++++++++++++++-------- 3 files changed, 49 insertions(+), 19 deletions(-) diff --git a/docs/project-generation-options.rst b/docs/project-generation-options.rst index 87ae90b1..8abeda9b 100644 --- a/docs/project-generation-options.rst +++ b/docs/project-generation-options.rst @@ -73,15 +73,15 @@ cloud_provider: mail_service: Select an email service that Django-Anymail provides - 1. Amazon SES_ - 2. Mailgun_ + 1. Mailgun_ + 2. `Amazon SES`_ 3. Mailjet_ 4. Mandrill_ 5. Postmark_ 6. SendGrid_ 7. SendinBlue_ 8. SparkPost_ - 9. Plain/Vanilla Django-Anymail_ + 9. `Other SMTP`_ use_drf: Indicates whether the project should be configured to use `Django Rest Framework`_. @@ -114,8 +114,8 @@ ci_tool: Select a CI tool for running tests. The choices are: 1. None - 2. Travis_ - 3. Gitlab_ + 2. `Travis CI`_ + 3. `Gitlab CI`_ keep_local_envs_in_vcs: Indicates whether the project's ``.envs/.local/`` should be kept in VCS @@ -145,7 +145,7 @@ debug: .. _AWS: https://aws.amazon.com/s3/ .. _GCP: https://cloud.google.com/storage/ -.. _SES: https://aws.amazon.com/ses/ +.. _Amazon SES: https://aws.amazon.com/ses/ .. _Mailgun: https://www.mailgun.com .. _Mailjet: https://www.mailjet.com .. _Mandrill: http://mandrill.com @@ -153,7 +153,7 @@ debug: .. _SendGrid: https://sendgrid.com .. _SendinBlue: https://www.sendinblue.com .. _SparkPost: https://www.sparkpost.com -.. _Django-Anymail: https://anymail.readthedocs.io/en/stable/ +.. _Other SMTP: https://anymail.readthedocs.io/en/stable/ .. _Django Rest Framework: https://github.com/encode/django-rest-framework/ diff --git a/hooks/pre_gen_project.py b/hooks/pre_gen_project.py index 668a6e27..54334ded 100644 --- a/hooks/pre_gen_project.py +++ b/hooks/pre_gen_project.py @@ -68,3 +68,15 @@ if ( "You should either use Whitenoise or select a Cloud Provider to serve static files" ) sys.exit(1) + +if ( + "{{ cookiecutter.cloud_provider }}" == "GCP" + and "{{ cookiecutter.mail_service }}" == "Amazon SES" +) or ( + "{{ cookiecutter.cloud_provider }}" == "None" + and "{{ cookiecutter.mail_service }}" == "Amazon SES" +): + print( + "You should either use AWS or select a different Mail Service for sending emails." + ) + sys.exit(1) diff --git a/tests/test_cookiecutter_generation.py b/tests/test_cookiecutter_generation.py index 91f44ae5..2c7e6dc4 100755 --- a/tests/test_cookiecutter_generation.py +++ b/tests/test_cookiecutter_generation.py @@ -46,17 +46,33 @@ SUPPORTED_COMBINATIONS = [ {"cloud_provider": "AWS", "use_whitenoise": "n"}, {"cloud_provider": "GCP", "use_whitenoise": "y"}, {"cloud_provider": "GCP", "use_whitenoise": "n"}, - {"cloud_provider": "None", "use_whitenoise": "y"}, + {"cloud_provider": "None", "use_whitenoise": "y", "mail_service": "Mailgun"}, + {"cloud_provider": "None", "use_whitenoise": "y", "mail_service": "Mailjet"}, + {"cloud_provider": "None", "use_whitenoise": "y", "mail_service": "Mandrill"}, + {"cloud_provider": "None", "use_whitenoise": "y", "mail_service": "Postmark"}, + {"cloud_provider": "None", "use_whitenoise": "y", "mail_service": "Sendgrid"}, + {"cloud_provider": "None", "use_whitenoise": "y", "mail_service": "SendinBlue"}, + {"cloud_provider": "None", "use_whitenoise": "y", "mail_service": "SparkPost"}, + {"cloud_provider": "None", "use_whitenoise": "y", "mail_service": "Other SMTP"}, # Note: cloud_provider=None AND use_whitenoise=n is not supported - {"mail_service": "Mailgun"}, - {"mail_service": "Amazon SES"}, - {"mail_service": "Mailjet"}, - {"mail_service": "Mandrill"}, - {"mail_service": "Postmark"}, - {"mail_service": "Sendgrid"}, - {"mail_service": "SendinBlue"}, - {"mail_service": "SparkPost"}, - {"mail_service": "Other SMTP"}, + {"cloud_provider": "AWS", "mail_service": "Mailgun"}, + {"cloud_provider": "AWS", "mail_service": "Amazon SES"}, + {"cloud_provider": "AWS", "mail_service": "Mailjet"}, + {"cloud_provider": "AWS", "mail_service": "Mandrill"}, + {"cloud_provider": "AWS", "mail_service": "Postmark"}, + {"cloud_provider": "AWS", "mail_service": "Sendgrid"}, + {"cloud_provider": "AWS", "mail_service": "SendinBlue"}, + {"cloud_provider": "AWS", "mail_service": "SparkPost"}, + {"cloud_provider": "AWS", "mail_service": "Other SMTP"}, + {"cloud_provider": "GCP", "mail_service": "Mailgun"}, + {"cloud_provider": "GCP", "mail_service": "Mailjet"}, + {"cloud_provider": "GCP", "mail_service": "Mandrill"}, + {"cloud_provider": "GCP", "mail_service": "Postmark"}, + {"cloud_provider": "GCP", "mail_service": "Sendgrid"}, + {"cloud_provider": "GCP", "mail_service": "SendinBlue"}, + {"cloud_provider": "GCP", "mail_service": "SparkPost"}, + {"cloud_provider": "GCP", "mail_service": "Other SMTP"}, + # Note: cloud_providers GCP and None with mail_service Amazon SES is not supported {"use_drf": "y"}, {"use_drf": "n"}, {"js_task_runner": "None"}, @@ -86,6 +102,8 @@ SUPPORTED_COMBINATIONS = [ UNSUPPORTED_COMBINATIONS = [ {"cloud_provider": "None", "use_whitenoise": "n"}, + {"cloud_provider": "GCP", "mail_service": "Amazon SES"}, + {"cloud_provider": "None", "mail_service": "Amazon SES"}, ] @@ -163,7 +181,7 @@ def test_travis_invokes_pytest(cookies, context): with open(f"{result.project}/.travis.yml", "r") as travis_yml: try: - assert yaml.load(travis_yml)["script"] == ["pytest"] + assert yaml.load(travis_yml, Loader=yaml.FullLoader)["script"] == ["pytest"] except yaml.YAMLError as e: pytest.fail(e) @@ -179,7 +197,7 @@ def test_gitlab_invokes_flake8_and_pytest(cookies, context): with open(f"{result.project}/.gitlab-ci.yml", "r") as gitlab_yml: try: - gitlab_config = yaml.load(gitlab_yml) + gitlab_config = yaml.load(gitlab_yml, Loader=yaml.FullLoader) assert gitlab_config["flake8"]["script"] == ["flake8"] assert gitlab_config["pytest"]["script"] == ["pytest"] except yaml.YAMLError as e: From ea5db6c4f4d0d013be1acc8fa141922a5f84bcb4 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Mon, 23 Mar 2020 21:41:51 +0000 Subject: [PATCH 100/182] Django 3.0 support (#2469) * Bump Django version to 3.0.x to see what breaks * Update places where Django 2.2 is mentioned to 3.0 * Update to latest Django 3.0 version * Bump version in setup.py --- README.rst | 2 +- setup.py | 4 ++-- {{cookiecutter.project_slug}}/config/settings/base.py | 2 +- {{cookiecutter.project_slug}}/requirements/base.txt | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index 56db4c78..64919923 100644 --- a/README.rst +++ b/README.rst @@ -36,7 +36,7 @@ production-ready Django projects quickly. Features --------- -* For Django 2.2 +* For Django 3.0 * Works with Python 3.7 * Renders Django projects with 100% starting test coverage * Twitter Bootstrap_ v4 (`maintained Foundation fork`_ also available) diff --git a/setup.py b/setup.py index 33032009..e311e82a 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ except ImportError: # Our version ALWAYS matches the version of Django we support # If Django has a new release, we branch, tag, then update this setting after the tag. -version = "2.2.1" +version = "3.0.4" if sys.argv[-1] == "tag": os.system(f'git tag -a {version} -m "version {version}"') @@ -34,7 +34,7 @@ setup( classifiers=[ "Development Status :: 4 - Beta", "Environment :: Console", - "Framework :: Django :: 2.2", + "Framework :: Django :: 3.0", "Intended Audience :: Developers", "Natural Language :: English", "License :: OSI Approved :: BSD License", diff --git a/{{cookiecutter.project_slug}}/config/settings/base.py b/{{cookiecutter.project_slug}}/config/settings/base.py index a0bf8f0a..6a2a9c3f 100644 --- a/{{cookiecutter.project_slug}}/config/settings/base.py +++ b/{{cookiecutter.project_slug}}/config/settings/base.py @@ -228,7 +228,7 @@ X_FRAME_OPTIONS = "DENY" EMAIL_BACKEND = env( "DJANGO_EMAIL_BACKEND", default="django.core.mail.backends.smtp.EmailBackend" ) -# https://docs.djangoproject.com/en/2.2/ref/settings/#email-timeout +# https://docs.djangoproject.com/en/dev/ref/settings/#email-timeout EMAIL_TIMEOUT = 5 # ADMIN diff --git a/{{cookiecutter.project_slug}}/requirements/base.txt b/{{cookiecutter.project_slug}}/requirements/base.txt index 7ef43601..b41be3b0 100644 --- a/{{cookiecutter.project_slug}}/requirements/base.txt +++ b/{{cookiecutter.project_slug}}/requirements/base.txt @@ -19,7 +19,7 @@ flower==0.9.3 # https://github.com/mher/flower # Django # ------------------------------------------------------------------------------ -django==2.2.11 # pyup: < 3.0 # https://www.djangoproject.com/ +django==3.0.4 # pyup: < 3.1 # https://www.djangoproject.com/ django-environ==0.4.5 # https://github.com/joke2k/django-environ django-model-utils==4.0.0 # https://github.com/jazzband/django-model-utils django-allauth==0.41.0 # https://github.com/pennersr/django-allauth From 2e1a922577ec888589c7e6ee368dd3f1aedf1a89 Mon Sep 17 00:00:00 2001 From: Gabriel Mejia Date: Mon, 23 Mar 2020 16:43:59 -0500 Subject: [PATCH 101/182] Add CELERY_BROKER_URL for gitlab #2504 (#2505) * Solved issue #2504 * Added new contributor Co-authored-by: Gabriel Mejia --- CONTRIBUTORS.rst | 1 + {{cookiecutter.project_slug}}/.gitlab-ci.yml | 3 +++ 2 files changed, 4 insertions(+) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index 075b3f32..c244f64b 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -222,6 +222,7 @@ Listed in alphabetical order. Xaver Y.R. Chen `@yrchen`_ @yrchen Yaroslav Halchenko Yuchen Xie `@mapx`_ + Gabriel Mejia `@elgartoinf` @elgartoinf ========================== ============================ ============== .. _@a7p: https://github.com/a7p diff --git a/{{cookiecutter.project_slug}}/.gitlab-ci.yml b/{{cookiecutter.project_slug}}/.gitlab-ci.yml index 91ad7238..611ff202 100644 --- a/{{cookiecutter.project_slug}}/.gitlab-ci.yml +++ b/{{cookiecutter.project_slug}}/.gitlab-ci.yml @@ -7,6 +7,9 @@ variables: POSTGRES_PASSWORD: '' POSTGRES_DB: 'test_{{ cookiecutter.project_slug }}' POSTGRES_HOST_AUTH_METHOD: trust + {% if cookiecutter.use_celery == 'y' -%} + CELERY_BROKER_URL: 'redis://redis:6379/0' + {%- endif %} flake8: stage: lint From 0c36c57f2d45be9bdf5c4bdd0c8754765a75a0ea Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Mon, 23 Mar 2020 21:45:38 +0000 Subject: [PATCH 102/182] Fix broken link in list of contributors --- CONTRIBUTORS.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index c244f64b..2e7b11e6 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -118,6 +118,7 @@ Listed in alphabetical order. Eyad Al Sibai `@eyadsibai`_ Felipe Arruda `@arruda`_ Florian Idelberger `@step21`_ @windrush + Gabriel Mejia `@elgartoinf`_ @elgartoinf Garry Cairns `@garry-cairns`_ Garry Polley `@garrypolley`_ Gilbishkosma `@Gilbishkosma`_ @@ -222,7 +223,6 @@ Listed in alphabetical order. Xaver Y.R. Chen `@yrchen`_ @yrchen Yaroslav Halchenko Yuchen Xie `@mapx`_ - Gabriel Mejia `@elgartoinf` @elgartoinf ========================== ============================ ============== .. _@a7p: https://github.com/a7p @@ -286,6 +286,7 @@ Listed in alphabetical order. .. _@guilherme1guy: https://github.com/guilherme1guy .. _@durkode: https://github.com/durkode .. _@Egregors: https://github.com/Egregors +.. _@elgartoinf: https://gihub.com/elgartoinf .. _@epileptic-fish: https://gihub.com/epileptic-fish .. _@eraldo: https://github.com/eraldo .. _@erfaan: https://github.com/erfaan From c4b1666707551cd2ce3f82ffd8a676d34e33130a Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Tue, 3 Mar 2020 20:28:02 +0000 Subject: [PATCH 103/182] Move storages classes into their own module --- hooks/post_gen_project.py | 5 +++ .../config/settings/production.py | 37 ++----------------- .../utils/storages.py | 25 +++++++++++++ 3 files changed, 34 insertions(+), 33 deletions(-) create mode 100644 {{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/utils/storages.py diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 5cc8c32f..9bde5377 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -292,6 +292,10 @@ def remove_drf_starter_files(): shutil.rmtree(os.path.join("{{cookiecutter.project_slug}}", "users", "api")) +def remove_storages_module(): + os.remove(os.path.join("{{cookiecutter.project_slug}}", "utils", "storages.py")) + + def main(): debug = "{{ cookiecutter.debug }}".lower() == "y" @@ -352,6 +356,7 @@ def main(): WARNING + "You chose not to use a cloud provider, " "media files won't be served in production." + TERMINATOR ) + remove_storages_module() if "{{ cookiecutter.use_celery }}".lower() == "n": remove_celery_files() diff --git a/{{cookiecutter.project_slug}}/config/settings/production.py b/{{cookiecutter.project_slug}}/config/settings/production.py index 22832d34..2043e89e 100644 --- a/{{cookiecutter.project_slug}}/config/settings/production.py +++ b/{{cookiecutter.project_slug}}/config/settings/production.py @@ -104,11 +104,11 @@ GS_DEFAULT_ACL = "publicRead" {% if cookiecutter.use_whitenoise == 'y' -%} STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage" {% elif cookiecutter.cloud_provider == 'AWS' -%} -STATICFILES_STORAGE = "config.settings.production.StaticRootS3Boto3Storage" +STATICFILES_STORAGE = "{{cookiecutter.project_slug}}.utils.storages.StaticRootS3Boto3Storage" COLLECTFAST_STRATEGY = "collectfast.strategies.boto3.Boto3Strategy" STATIC_URL = f"https://{AWS_STORAGE_BUCKET_NAME}.s3.amazonaws.com/static/" {% elif cookiecutter.cloud_provider == 'GCP' -%} -STATICFILES_STORAGE = "config.settings.production.StaticRootGoogleCloudStorage" +STATICFILES_STORAGE = "{{cookiecutter.project_slug}}.utils.storages.StaticRootGoogleCloudStorage" COLLECTFAST_STRATEGY = "collectfast.strategies.gcloud.GoogleCloudStrategy" STATIC_URL = f"https://storage.googleapis.com/{GS_BUCKET_NAME}/static/" {% endif -%} @@ -116,39 +116,10 @@ STATIC_URL = f"https://storage.googleapis.com/{GS_BUCKET_NAME}/static/" # MEDIA # ------------------------------------------------------------------------------ {%- if cookiecutter.cloud_provider == 'AWS' %} -# region http://stackoverflow.com/questions/10390244/ -# Full-fledge class: https://stackoverflow.com/a/18046120/104731 -from storages.backends.s3boto3 import S3Boto3Storage # noqa E402 - - -class StaticRootS3Boto3Storage(S3Boto3Storage): - location = "static" - default_acl = "public-read" - - -class MediaRootS3Boto3Storage(S3Boto3Storage): - location = "media" - file_overwrite = False - - -# endregion -DEFAULT_FILE_STORAGE = "config.settings.production.MediaRootS3Boto3Storage" +DEFAULT_FILE_STORAGE = "{{cookiecutter.project_slug}}.utils.storages.MediaRootS3Boto3Storage" MEDIA_URL = f"https://{AWS_STORAGE_BUCKET_NAME}.s3.amazonaws.com/media/" {%- elif cookiecutter.cloud_provider == 'GCP' %} -from storages.backends.gcloud import GoogleCloudStorage # noqa E402 - - -class StaticRootGoogleCloudStorage(GoogleCloudStorage): - location = "static" - default_acl = "publicRead" - - -class MediaRootGoogleCloudStorage(GoogleCloudStorage): - location = "media" - file_overwrite = False - - -DEFAULT_FILE_STORAGE = "config.settings.production.MediaRootGoogleCloudStorage" +DEFAULT_FILE_STORAGE = "{{cookiecutter.project_slug}}.utils.storages.MediaRootGoogleCloudStorage" MEDIA_URL = f"https://storage.googleapis.com/{GS_BUCKET_NAME}/media/" {%- endif %} diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/utils/storages.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/utils/storages.py new file mode 100644 index 00000000..72b8ea3b --- /dev/null +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/utils/storages.py @@ -0,0 +1,25 @@ +{% if cookiecutter.cloud_provider == 'AWS' -%} +from storages.backends.s3boto3 import S3Boto3Storage # noqa E402 + + +class StaticRootS3Boto3Storage(S3Boto3Storage): + location = "static" + default_acl = "public-read" + + +class MediaRootS3Boto3Storage(S3Boto3Storage): + location = "media" + file_overwrite = False +{%- elif cookiecutter.cloud_provider == 'GCP' -%} +from storages.backends.gcloud import GoogleCloudStorage # noqa E402 + + +class StaticRootGoogleCloudStorage(GoogleCloudStorage): + location = "static" + default_acl = "publicRead" + + +class MediaRootGoogleCloudStorage(GoogleCloudStorage): + location = "media" + file_overwrite = False +{%- endif %} From 56d5e271aabffbbf9b8dbb00922507f1cc1e3f13 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Tue, 3 Mar 2020 20:32:03 +0000 Subject: [PATCH 104/182] Remove isort exception in production config & fix issue --- {{cookiecutter.project_slug}}/config/settings/production.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/{{cookiecutter.project_slug}}/config/settings/production.py b/{{cookiecutter.project_slug}}/config/settings/production.py index 2043e89e..cea29b8e 100644 --- a/{{cookiecutter.project_slug}}/config/settings/production.py +++ b/{{cookiecutter.project_slug}}/config/settings/production.py @@ -1,9 +1,7 @@ -"""isort:skip_file""" {% if cookiecutter.use_sentry == 'y' -%} import logging import sentry_sdk - from sentry_sdk.integrations.django import DjangoIntegration from sentry_sdk.integrations.logging import LoggingIntegration {%- if cookiecutter.use_celery == 'y' %} From 7e1cb599af980075459d47cbcabbde0fe1db1e81 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Tue, 3 Mar 2020 21:10:50 +0000 Subject: [PATCH 105/182] Remove flake noqa exception --- .../{{cookiecutter.project_slug}}/utils/storages.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/utils/storages.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/utils/storages.py index 72b8ea3b..b712d323 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/utils/storages.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/utils/storages.py @@ -1,5 +1,5 @@ {% if cookiecutter.cloud_provider == 'AWS' -%} -from storages.backends.s3boto3 import S3Boto3Storage # noqa E402 +from storages.backends.s3boto3 import S3Boto3Storage class StaticRootS3Boto3Storage(S3Boto3Storage): @@ -11,7 +11,7 @@ class MediaRootS3Boto3Storage(S3Boto3Storage): location = "media" file_overwrite = False {%- elif cookiecutter.cloud_provider == 'GCP' -%} -from storages.backends.gcloud import GoogleCloudStorage # noqa E402 +from storages.backends.gcloud import GoogleCloudStorage class StaticRootGoogleCloudStorage(GoogleCloudStorage): From aee2de347bbefbf57edd1790acef2a0c8cef4501 Mon Sep 17 00:00:00 2001 From: Andrew-Chen-Wang Date: Tue, 24 Mar 2020 15:40:14 -0400 Subject: [PATCH 106/182] Add uvicorn and web sockets for Django 3 * Add use_async option to cookiecutter.json * Add websocket configuration --- cookiecutter.json | 1 + docs/project-generation-options.rst | 3 ++ hooks/post_gen_project.py | 12 ++++++ tests/test_cookiecutter_generation.py | 2 + .../compose/local/django/start | 4 ++ .../compose/production/django/start | 4 ++ {{cookiecutter.project_slug}}/config/asgi.py | 41 +++++++++++++++++++ .../config/websocket.py | 18 ++++++++ .../requirements/base.txt | 3 ++ 9 files changed, 88 insertions(+) create mode 100644 {{cookiecutter.project_slug}}/config/asgi.py create mode 100644 {{cookiecutter.project_slug}}/config/websocket.py diff --git a/cookiecutter.json b/cookiecutter.json index cfa1b346..62155ad0 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -44,6 +44,7 @@ "SparkPost", "Other SMTP" ], + "use_async": "n", "use_drf": "n", "custom_bootstrap_compilation": "n", "use_compressor": "n", diff --git a/docs/project-generation-options.rst b/docs/project-generation-options.rst index 8abeda9b..1c2fc314 100644 --- a/docs/project-generation-options.rst +++ b/docs/project-generation-options.rst @@ -83,6 +83,9 @@ mail_service: 8. SparkPost_ 9. `Other SMTP`_ +use_async: + Indicates whether the project should use web sockets with Uvicorn + Gunicorn. + use_drf: Indicates whether the project should be configured to use `Django Rest Framework`_. diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 5cc8c32f..2e2c19e1 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -101,6 +101,15 @@ def remove_celery_files(): os.remove(file_name) +def remove_async_files(): + file_names = [ + os.path.join("config", "asgi.py"), + os.path.join("config", "websocket.py"), + ] + for file_name in file_names: + os.remove(file_name) + + def remove_dottravisyml_file(): os.remove(".travis.yml") @@ -367,6 +376,9 @@ def main(): if "{{ cookiecutter.use_drf }}".lower() == "n": remove_drf_starter_files() + if "{{ cookiecutter.use_async }}".lower() == "n": + remove_async_files() + print(SUCCESS + "Project initialized, keep up the good work!" + TERMINATOR) diff --git a/tests/test_cookiecutter_generation.py b/tests/test_cookiecutter_generation.py index 2c7e6dc4..eee56115 100755 --- a/tests/test_cookiecutter_generation.py +++ b/tests/test_cookiecutter_generation.py @@ -73,6 +73,8 @@ SUPPORTED_COMBINATIONS = [ {"cloud_provider": "GCP", "mail_service": "SparkPost"}, {"cloud_provider": "GCP", "mail_service": "Other SMTP"}, # Note: cloud_providers GCP and None with mail_service Amazon SES is not supported + {"use_async", "y"}, + {"use_async", "n"}, {"use_drf": "y"}, {"use_drf": "n"}, {"js_task_runner": "None"}, diff --git a/{{cookiecutter.project_slug}}/compose/local/django/start b/{{cookiecutter.project_slug}}/compose/local/django/start index f076ee51..bc1293de 100644 --- a/{{cookiecutter.project_slug}}/compose/local/django/start +++ b/{{cookiecutter.project_slug}}/compose/local/django/start @@ -6,4 +6,8 @@ set -o nounset python manage.py migrate +{%- if cookiecutter.use_async %} +/usr/local/bin/uvicorn config.asgi --bind 0.0.0.0:5000 --chdir=/app +{%- else %} python manage.py runserver_plus 0.0.0.0:8000 +{% endif %} diff --git a/{{cookiecutter.project_slug}}/compose/production/django/start b/{{cookiecutter.project_slug}}/compose/production/django/start index 4985aeed..dd06949a 100644 --- a/{{cookiecutter.project_slug}}/compose/production/django/start +++ b/{{cookiecutter.project_slug}}/compose/production/django/start @@ -27,4 +27,8 @@ if compress_enabled; then python /app/manage.py compress fi {%- endif %} +{% if cookiecutter.use_async %} +/usr/local/bin/uvicorn config.asgi --bind 0.0.0.0:5000 --chdir=/app +{% else %} /usr/local/bin/gunicorn config.wsgi --bind 0.0.0.0:5000 --chdir=/app +{%- endif %} diff --git a/{{cookiecutter.project_slug}}/config/asgi.py b/{{cookiecutter.project_slug}}/config/asgi.py new file mode 100644 index 00000000..81f1c76a --- /dev/null +++ b/{{cookiecutter.project_slug}}/config/asgi.py @@ -0,0 +1,41 @@ +""" +ASGI config for {{ cookiecutter.project_name }} project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/dev/howto/deployment/asgi/ +""" +import os +import sys +from pathlib import Path + +from django.core.asgi import get_asgi_application +from .websocket import websocket_application + +# This allows easy placement of apps within the interior +# {{ cookiecutter.project_slug }} directory. +app_path = Path(__file__).parents[1].resolve() +sys.path.append(str(app_path / "{{ cookiecutter.project_slug }}")) +# We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks +# if running multiple sites in the same mod_wsgi process. To fix this, use +# mod_wsgi daemon mode with each site in its own daemon process, or use +# os.environ["DJANGO_SETTINGS_MODULE"] = "config.settings.production" +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.production") + +# This application object is used by any ASGI server configured to use this +# file. This includes Django's development server, if the ASGI_APPLICATION +# setting points here. +django_application = get_asgi_application() +# Apply ASGI middleware here. +# from helloworld.asgi import HelloWorldApplication +# application = HelloWorldApplication(application) + + +async def application(scope, receive, send): + if scope['type'] == 'http': + await django_application(scope, receive, send) + elif scope['type'] == 'websocket': + await websocket_application(scope, receive, send) + else: + raise NotImplementedError(f"Unknown scope type {scope['type']}") diff --git a/{{cookiecutter.project_slug}}/config/websocket.py b/{{cookiecutter.project_slug}}/config/websocket.py new file mode 100644 index 00000000..9c84a528 --- /dev/null +++ b/{{cookiecutter.project_slug}}/config/websocket.py @@ -0,0 +1,18 @@ +async def websocket_application(scope, receive, send): + while True: + event = await receive() + + if event['type'] == 'websocket.connect': + await send({ + 'type': 'websocket.accept' + }) + + if event['type'] == 'websocket.disconnect': + break + + if event['type'] == 'websocket.receive': + if event['text'] == 'ping': + await send({ + 'type': 'websocket.send', + 'text': 'pong!' + }) diff --git a/{{cookiecutter.project_slug}}/requirements/base.txt b/{{cookiecutter.project_slug}}/requirements/base.txt index b41be3b0..ec861f35 100644 --- a/{{cookiecutter.project_slug}}/requirements/base.txt +++ b/{{cookiecutter.project_slug}}/requirements/base.txt @@ -16,6 +16,9 @@ django-celery-beat==2.0.0 # https://github.com/celery/django-celery-beat flower==0.9.3 # https://github.com/mher/flower {%- endif %} {%- endif %} +{%- if cookiecutter.use_async %} +uvicorn==0.11.3 # https://github.com/encode/uvicorn +{%- endif %} # Django # ------------------------------------------------------------------------------ From c4eaf68982eefa368390ff7bbc1296633d86fc63 Mon Sep 17 00:00:00 2001 From: Andrew-Chen-Wang Date: Tue, 24 Mar 2020 15:53:45 -0400 Subject: [PATCH 107/182] Fixed test_cookiecutter_generation.py for use_async from set to dict --- tests/test_cookiecutter_generation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_cookiecutter_generation.py b/tests/test_cookiecutter_generation.py index eee56115..853f4ebd 100755 --- a/tests/test_cookiecutter_generation.py +++ b/tests/test_cookiecutter_generation.py @@ -73,8 +73,8 @@ SUPPORTED_COMBINATIONS = [ {"cloud_provider": "GCP", "mail_service": "SparkPost"}, {"cloud_provider": "GCP", "mail_service": "Other SMTP"}, # Note: cloud_providers GCP and None with mail_service Amazon SES is not supported - {"use_async", "y"}, - {"use_async", "n"}, + {"use_async": "y"}, + {"use_async": "n"}, {"use_drf": "y"}, {"use_drf": "n"}, {"js_task_runner": "None"}, From 910ed86d1132b084f3fc4b56aa5657ce1444d98f Mon Sep 17 00:00:00 2001 From: Andrew-Chen-Wang Date: Tue, 24 Mar 2020 16:12:47 -0400 Subject: [PATCH 108/182] Fixed linter check for #2506 --- {{cookiecutter.project_slug}}/config/asgi.py | 5 +++-- .../config/websocket.py | 17 ++++++----------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/{{cookiecutter.project_slug}}/config/asgi.py b/{{cookiecutter.project_slug}}/config/asgi.py index 81f1c76a..4cc878ca 100644 --- a/{{cookiecutter.project_slug}}/config/asgi.py +++ b/{{cookiecutter.project_slug}}/config/asgi.py @@ -11,6 +11,7 @@ import sys from pathlib import Path from django.core.asgi import get_asgi_application + from .websocket import websocket_application # This allows easy placement of apps within the interior @@ -33,9 +34,9 @@ django_application = get_asgi_application() async def application(scope, receive, send): - if scope['type'] == 'http': + if scope["type"] == "http": await django_application(scope, receive, send) - elif scope['type'] == 'websocket': + elif scope["type"] == "websocket": await websocket_application(scope, receive, send) else: raise NotImplementedError(f"Unknown scope type {scope['type']}") diff --git a/{{cookiecutter.project_slug}}/config/websocket.py b/{{cookiecutter.project_slug}}/config/websocket.py index 9c84a528..81adfbc6 100644 --- a/{{cookiecutter.project_slug}}/config/websocket.py +++ b/{{cookiecutter.project_slug}}/config/websocket.py @@ -2,17 +2,12 @@ async def websocket_application(scope, receive, send): while True: event = await receive() - if event['type'] == 'websocket.connect': - await send({ - 'type': 'websocket.accept' - }) + if event["type"] == "websocket.connect": + await send({"type": "websocket.accept"}) - if event['type'] == 'websocket.disconnect': + if event["type"] == "websocket.disconnect": break - if event['type'] == 'websocket.receive': - if event['text'] == 'ping': - await send({ - 'type': 'websocket.send', - 'text': 'pong!' - }) + if event["type"] == "websocket.receive": + if event["text"] == "ping": + await send({"type": "websocket.send", "text": "pong!"}) From 125ffec2431337fcd95bf74ea391e2097cd5a1e1 Mon Sep 17 00:00:00 2001 From: Andrew-Chen-Wang Date: Tue, 24 Mar 2020 20:51:43 -0400 Subject: [PATCH 109/182] Changed starting commands for running server * Performance is very low --- {{cookiecutter.project_slug}}/compose/local/django/start | 2 +- {{cookiecutter.project_slug}}/compose/production/django/start | 2 +- {{cookiecutter.project_slug}}/config/asgi.py | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/{{cookiecutter.project_slug}}/compose/local/django/start b/{{cookiecutter.project_slug}}/compose/local/django/start index bc1293de..259e7cd1 100644 --- a/{{cookiecutter.project_slug}}/compose/local/django/start +++ b/{{cookiecutter.project_slug}}/compose/local/django/start @@ -7,7 +7,7 @@ set -o nounset python manage.py migrate {%- if cookiecutter.use_async %} -/usr/local/bin/uvicorn config.asgi --bind 0.0.0.0:5000 --chdir=/app +/usr/local/bin/gunicorn config.asgi --bind 0.0.0.0:8000 --chdir=/app -k uvicorn.workers.UvicornWorker -e DJANGO_SETTINGS_MODULE=config.settings.local --reload {%- else %} python manage.py runserver_plus 0.0.0.0:8000 {% endif %} diff --git a/{{cookiecutter.project_slug}}/compose/production/django/start b/{{cookiecutter.project_slug}}/compose/production/django/start index dd06949a..96c8987c 100644 --- a/{{cookiecutter.project_slug}}/compose/production/django/start +++ b/{{cookiecutter.project_slug}}/compose/production/django/start @@ -28,7 +28,7 @@ if compress_enabled; then fi {%- endif %} {% if cookiecutter.use_async %} -/usr/local/bin/uvicorn config.asgi --bind 0.0.0.0:5000 --chdir=/app +/usr/local/bin/gunicorn config.asgi --workers 4 --bind 0.0.0.0:5000 --chdir=/app -k uvicorn.workers.UvicornWorker {% else %} /usr/local/bin/gunicorn config.wsgi --bind 0.0.0.0:5000 --chdir=/app {%- endif %} diff --git a/{{cookiecutter.project_slug}}/config/asgi.py b/{{cookiecutter.project_slug}}/config/asgi.py index 4cc878ca..3dd31f70 100644 --- a/{{cookiecutter.project_slug}}/config/asgi.py +++ b/{{cookiecutter.project_slug}}/config/asgi.py @@ -11,7 +11,6 @@ import sys from pathlib import Path from django.core.asgi import get_asgi_application - from .websocket import websocket_application # This allows easy placement of apps within the interior From e6b800d9854bb0956afd1df175501466faa5be2b Mon Sep 17 00:00:00 2001 From: Andrew-Chen-Wang Date: Tue, 24 Mar 2020 20:59:28 -0400 Subject: [PATCH 110/182] Added static files URL for runserver-level/best performance * The reason there was a degraded performance was because we're using Gunicorn itself as a local tester. So we needed to add the staticfiles urls --- {{cookiecutter.project_slug}}/config/urls.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/{{cookiecutter.project_slug}}/config/urls.py b/{{cookiecutter.project_slug}}/config/urls.py index 81860906..2cf7be95 100644 --- a/{{cookiecutter.project_slug}}/config/urls.py +++ b/{{cookiecutter.project_slug}}/config/urls.py @@ -7,6 +7,9 @@ from django.views.generic import TemplateView {%- if cookiecutter.use_drf == 'y' %} from rest_framework.authtoken.views import obtain_auth_token {%- endif %} +{%- if cookiecutter.use_async %} +from django.contrib.staticfiles.urls import staticfiles_urlpatterns +{%- endif %} urlpatterns = [ path("", TemplateView.as_view(template_name="pages/home.html"), name="home"), @@ -20,6 +23,11 @@ urlpatterns = [ path("accounts/", include("allauth.urls")), # Your stuff: custom urls includes go here ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) +{% if cookiecutter.use_async %} +# Static file serving when using Gunicorn + Uvicorn for local development +if settings.DEBUG: + urlpatterns += staticfiles_urlpatterns() +{% endif %} {% if cookiecutter.use_drf == 'y' -%} # API URLS urlpatterns += [ From 7cd390854b72abd2c93f46c7a2476890f29cabd8 Mon Sep 17 00:00:00 2001 From: Andrew-Chen-Wang Date: Tue, 24 Mar 2020 21:42:28 -0400 Subject: [PATCH 111/182] Fixed linter checks --- {{cookiecutter.project_slug}}/config/asgi.py | 1 + {{cookiecutter.project_slug}}/config/urls.py | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/{{cookiecutter.project_slug}}/config/asgi.py b/{{cookiecutter.project_slug}}/config/asgi.py index 3dd31f70..4cc878ca 100644 --- a/{{cookiecutter.project_slug}}/config/asgi.py +++ b/{{cookiecutter.project_slug}}/config/asgi.py @@ -11,6 +11,7 @@ import sys from pathlib import Path from django.core.asgi import get_asgi_application + from .websocket import websocket_application # This allows easy placement of apps within the interior diff --git a/{{cookiecutter.project_slug}}/config/urls.py b/{{cookiecutter.project_slug}}/config/urls.py index 2cf7be95..168d77a8 100644 --- a/{{cookiecutter.project_slug}}/config/urls.py +++ b/{{cookiecutter.project_slug}}/config/urls.py @@ -1,15 +1,15 @@ from django.conf import settings from django.conf.urls.static import static from django.contrib import admin +{%- if cookiecutter.use_async == 'y' %} +from django.contrib.staticfiles.urls import staticfiles_urlpatterns +{%- endif %} from django.urls import include, path from django.views import defaults as default_views from django.views.generic import TemplateView {%- if cookiecutter.use_drf == 'y' %} from rest_framework.authtoken.views import obtain_auth_token {%- endif %} -{%- if cookiecutter.use_async %} -from django.contrib.staticfiles.urls import staticfiles_urlpatterns -{%- endif %} urlpatterns = [ path("", TemplateView.as_view(template_name="pages/home.html"), name="home"), @@ -23,12 +23,12 @@ urlpatterns = [ path("accounts/", include("allauth.urls")), # Your stuff: custom urls includes go here ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) -{% if cookiecutter.use_async %} -# Static file serving when using Gunicorn + Uvicorn for local development +{%- if cookiecutter.use_async == 'y' %} if settings.DEBUG: + # Static file serving when using Gunicorn + Uvicorn for local web socket development urlpatterns += staticfiles_urlpatterns() -{% endif %} -{% if cookiecutter.use_drf == 'y' -%} +{%- endif %} +{% if cookiecutter.use_drf == 'y' %} # API URLS urlpatterns += [ # API base url From 367225e4e84998e664bed8fabc4c7f159a1c49e1 Mon Sep 17 00:00:00 2001 From: Andrew-Chen-Wang Date: Tue, 24 Mar 2020 21:46:40 -0400 Subject: [PATCH 112/182] Removed the 4 workers from the production start of uvicorn --- {{cookiecutter.project_slug}}/compose/local/django/start | 2 +- {{cookiecutter.project_slug}}/compose/production/django/start | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/{{cookiecutter.project_slug}}/compose/local/django/start b/{{cookiecutter.project_slug}}/compose/local/django/start index 259e7cd1..129266c8 100644 --- a/{{cookiecutter.project_slug}}/compose/local/django/start +++ b/{{cookiecutter.project_slug}}/compose/local/django/start @@ -6,7 +6,7 @@ set -o nounset python manage.py migrate -{%- if cookiecutter.use_async %} +{%- if cookiecutter.use_async == 'y' %} /usr/local/bin/gunicorn config.asgi --bind 0.0.0.0:8000 --chdir=/app -k uvicorn.workers.UvicornWorker -e DJANGO_SETTINGS_MODULE=config.settings.local --reload {%- else %} python manage.py runserver_plus 0.0.0.0:8000 diff --git a/{{cookiecutter.project_slug}}/compose/production/django/start b/{{cookiecutter.project_slug}}/compose/production/django/start index 96c8987c..1a41ed48 100644 --- a/{{cookiecutter.project_slug}}/compose/production/django/start +++ b/{{cookiecutter.project_slug}}/compose/production/django/start @@ -27,8 +27,8 @@ if compress_enabled; then python /app/manage.py compress fi {%- endif %} -{% if cookiecutter.use_async %} -/usr/local/bin/gunicorn config.asgi --workers 4 --bind 0.0.0.0:5000 --chdir=/app -k uvicorn.workers.UvicornWorker +{% if cookiecutter.use_async == 'y' %} +/usr/local/bin/gunicorn config.asgi --bind 0.0.0.0:5000 --chdir=/app -k uvicorn.workers.UvicornWorker {% else %} /usr/local/bin/gunicorn config.wsgi --bind 0.0.0.0:5000 --chdir=/app {%- endif %} From c9744497c90db88ea85246607215e21008b42ca1 Mon Sep 17 00:00:00 2001 From: Andrew-Chen-Wang Date: Tue, 24 Mar 2020 21:53:53 -0400 Subject: [PATCH 113/182] Added gunicorn to base.txt requirements for async work --- {{cookiecutter.project_slug}}/requirements/base.txt | 3 ++- {{cookiecutter.project_slug}}/requirements/production.txt | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/{{cookiecutter.project_slug}}/requirements/base.txt b/{{cookiecutter.project_slug}}/requirements/base.txt index ec861f35..2d47c6e1 100644 --- a/{{cookiecutter.project_slug}}/requirements/base.txt +++ b/{{cookiecutter.project_slug}}/requirements/base.txt @@ -16,8 +16,9 @@ django-celery-beat==2.0.0 # https://github.com/celery/django-celery-beat flower==0.9.3 # https://github.com/mher/flower {%- endif %} {%- endif %} -{%- if cookiecutter.use_async %} +{%- if cookiecutter.use_async == 'y' %} uvicorn==0.11.3 # https://github.com/encode/uvicorn +gunicorn==20.0.4 # https://github.com/benoitc/gunicorn {%- endif %} # Django diff --git a/{{cookiecutter.project_slug}}/requirements/production.txt b/{{cookiecutter.project_slug}}/requirements/production.txt index a8bc31dc..75ae8c30 100644 --- a/{{cookiecutter.project_slug}}/requirements/production.txt +++ b/{{cookiecutter.project_slug}}/requirements/production.txt @@ -2,8 +2,10 @@ -r ./base.txt -gunicorn==20.0.4 # https://github.com/benoitc/gunicorn psycopg2==2.8.4 --no-binary psycopg2 # https://github.com/psycopg/psycopg2 +{%- if cookiecutter.use_async == 'n' %} +gunicorn==20.0.4 # https://github.com/benoitc/gunicorn +{%- endif %} {%- if cookiecutter.use_whitenoise == 'n' %} Collectfast==2.1.0 # https://github.com/antonagestam/collectfast {%- endif %} From 6c9ba12ddf2531c6b9d7737b20a02b2b8700ff19 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Wed, 25 Mar 2020 12:13:30 +0000 Subject: [PATCH 114/182] Update tox from 3.14.5 to 3.14.6 (#2507) --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 81fbf524..7967d95c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,7 +10,7 @@ flake8-isort==2.9.0 # Testing # ------------------------------------------------------------------------------ -tox==3.14.5 +tox==3.14.6 pytest==5.4.1 pytest-cookies==0.5.1 pytest-instafail==0.4.1.post0 From 83f28a592c2a1270dc5413a243719a8485e31c9b Mon Sep 17 00:00:00 2001 From: "Fabio C. Barrioneuvo da Luz" Date: Wed, 25 Mar 2020 11:57:33 -0300 Subject: [PATCH 115/182] Migrate book domain to Feldroy and other small fixes --- LICENSE | 2 +- README.rst | 2 +- docs/faq.rst | 2 +- docs/index.rst | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/LICENSE b/LICENSE index 28466d40..a67e4da2 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2013-2018, Daniel Roy Greenfeld +Copyright (c) 2013-2020, Daniel Roy Greenfeld All rights reserved. Redistribution and use in source and binary forms, with or without modification, diff --git a/README.rst b/README.rst index 64919923..1855f59f 100644 --- a/README.rst +++ b/README.rst @@ -272,7 +272,7 @@ If you do rename your fork, I encourage you to submit it to the following places * cookiecutter_ so it gets listed in the README as a template. * The cookiecutter grid_ on Django Packages. -.. _cookiecutter: https://github.com/audreyr/cookiecutter +.. _cookiecutter: https://github.com/cookiecutter/cookiecutter .. _grid: https://www.djangopackages.com/grids/g/cookiecutters/ Submit a Pull Request diff --git a/docs/faq.rst b/docs/faq.rst index 1481a8ba..59e82465 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -24,4 +24,4 @@ Why doesn't this follow the layout from Two Scoops of Django? You may notice that some elements of this project do not exactly match what we describe in chapter 3 of `Two Scoops of Django 1.11`_. The reason for that is this project, amongst other things, serves as a test bed for trying out new ideas and concepts. Sometimes they work, sometimes they don't, but the end result is that it won't necessarily match precisely what is described in the book I co-authored. -.. _Two Scoops of Django 1.11: https://www.twoscoopspress.com/collections/django/products/two-scoops-of-django-1-11 +.. _Two Scoops of Django 1.11: https://www.feldroy.com/collections/django/products/two-scoops-of-django-1-11 diff --git a/docs/index.rst b/docs/index.rst index 8e0d04aa..b29e728e 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -5,7 +5,7 @@ Welcome to Cookiecutter Django's documentation! A Cookiecutter_ template for Django. -.. _cookiecutter: https://github.com/audreyr/cookiecutter +.. _cookiecutter: https://github.com/cookiecutter/cookiecutter Contents: From 1e612c4cfb30b3b030a9f8582dbad7fca3906974 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Tue, 17 Mar 2020 19:00:55 +0000 Subject: [PATCH 116/182] Remove request_factory fixture, use the rf one from pytest-django --- .../{{cookiecutter.project_slug}}/conftest.py | 6 ------ .../users/tests/test_views.py | 12 ++++++------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/conftest.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/conftest.py index 8cd51d7f..335648e0 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/conftest.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/conftest.py @@ -1,5 +1,4 @@ import pytest -from django.test import RequestFactory from {{ cookiecutter.project_slug }}.users.models import User from {{ cookiecutter.project_slug }}.users.tests.factories import UserFactory @@ -13,8 +12,3 @@ def media_storage(settings, tmpdir): @pytest.fixture def user() -> User: return UserFactory() - - -@pytest.fixture -def request_factory() -> RequestFactory: - return RequestFactory() diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_views.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_views.py index 9e868899..ca006059 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_views.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_views.py @@ -16,18 +16,18 @@ class TestUserUpdateView: https://github.com/pytest-dev/pytest-django/pull/258 """ - def test_get_success_url(self, user: User, request_factory: RequestFactory): + def test_get_success_url(self, user: User, rf: RequestFactory): view = UserUpdateView() - request = request_factory.get("/fake-url/") + request = rf.get("/fake-url/") request.user = user view.request = request assert view.get_success_url() == f"/users/{user.username}/" - def test_get_object(self, user: User, request_factory: RequestFactory): + def test_get_object(self, user: User, rf: RequestFactory): view = UserUpdateView() - request = request_factory.get("/fake-url/") + request = rf.get("/fake-url/") request.user = user view.request = request @@ -36,9 +36,9 @@ class TestUserUpdateView: class TestUserRedirectView: - def test_get_redirect_url(self, user: User, request_factory: RequestFactory): + def test_get_redirect_url(self, user: User, rf: RequestFactory): view = UserRedirectView() - request = request_factory.get("/fake-url") + request = rf.get("/fake-url") request.user = user view.request = request From 820f574bf534b7c6126f9d7e8c6484116bf094ac Mon Sep 17 00:00:00 2001 From: browniebroke Date: Fri, 27 Mar 2020 11:00:30 +0000 Subject: [PATCH 117/182] Update django-extensions from 2.2.8 to 2.2.9 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index 81ef97c7..2c7ee602 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -33,6 +33,6 @@ pre-commit==2.2.0 # https://github.com/pre-commit/pre-commit factory-boy==2.12.0 # https://github.com/FactoryBoy/factory_boy django-debug-toolbar==2.2 # https://github.com/jazzband/django-debug-toolbar -django-extensions==2.2.8 # https://github.com/django-extensions/django-extensions +django-extensions==2.2.9 # https://github.com/django-extensions/django-extensions django-coverage-plugin==1.8.0 # https://github.com/nedbat/django_coverage_plugin pytest-django==3.8.0 # https://github.com/pytest-dev/pytest-django From 62236dd908dcd35fbd2baabec1e9fadde40406d5 Mon Sep 17 00:00:00 2001 From: Tim Gates Date: Fri, 27 Mar 2020 22:15:56 +1100 Subject: [PATCH 118/182] docs: Fix simple typo, interpteter -> interpreter There is a small typo in {{cookiecutter.project_slug}}/docs/pycharm/configuration.rst. Should read `interpreter` rather than `interpteter`. --- {{cookiecutter.project_slug}}/docs/pycharm/configuration.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/docs/pycharm/configuration.rst b/{{cookiecutter.project_slug}}/docs/pycharm/configuration.rst index 1c20d023..d8e76916 100644 --- a/{{cookiecutter.project_slug}}/docs/pycharm/configuration.rst +++ b/{{cookiecutter.project_slug}}/docs/pycharm/configuration.rst @@ -14,7 +14,7 @@ This repository comes with already prepared "Run/Debug Configurations" for docke .. image:: images/2.png -But as you can see, at the beginning there is something wrong with them. They have red X on django icon, and they cannot be used, without configuring remote python interpteter. To do that, you have to go to *Settings > Build, Execution, Deployment* first. +But as you can see, at the beginning there is something wrong with them. They have red X on django icon, and they cannot be used, without configuring remote python interpreter. To do that, you have to go to *Settings > Build, Execution, Deployment* first. Next, you have to add new remote python interpreter, based on already tested deployment settings. Go to *Settings > Project > Project Interpreter*. Click on the cog icon, and click *Add Remote*. From efbb04da9155d1e45885d5c925c2b26ad3a9cf7f Mon Sep 17 00:00:00 2001 From: Andrew Chen Wang <60190294+Andrew-Chen-Wang@users.noreply.github.com> Date: Fri, 27 Mar 2020 21:32:17 -0400 Subject: [PATCH 119/182] Update so apps load first when using asgi.py --- {{cookiecutter.project_slug}}/config/asgi.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/{{cookiecutter.project_slug}}/config/asgi.py b/{{cookiecutter.project_slug}}/config/asgi.py index 4cc878ca..a325839b 100644 --- a/{{cookiecutter.project_slug}}/config/asgi.py +++ b/{{cookiecutter.project_slug}}/config/asgi.py @@ -12,8 +12,6 @@ from pathlib import Path from django.core.asgi import get_asgi_application -from .websocket import websocket_application - # This allows easy placement of apps within the interior # {{ cookiecutter.project_slug }} directory. app_path = Path(__file__).parents[1].resolve() @@ -32,6 +30,9 @@ django_application = get_asgi_application() # from helloworld.asgi import HelloWorldApplication # application = HelloWorldApplication(application) +# Importing websocket application so that apps are loaded first +from .websocket import websocket_application # noqa + async def application(scope, receive, send): if scope["type"] == "http": From 558380ebe98017fe220b99eda58bc533efd4347f Mon Sep 17 00:00:00 2001 From: "pyup.io bot" Date: Sun, 29 Mar 2020 05:11:07 +0200 Subject: [PATCH 120/182] Update flake8-isort to 2.9.1 (#2511) --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 7967d95c..f4d5a931 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,7 +6,7 @@ binaryornot==0.4.4 # ------------------------------------------------------------------------------ black==19.10b0 flake8==3.7.9 -flake8-isort==2.9.0 +flake8-isort==2.9.1 # Testing # ------------------------------------------------------------------------------ From e49afda665a445899916f448bf6afa0a77a69f13 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Sun, 29 Mar 2020 12:00:30 +0100 Subject: [PATCH 121/182] Update flower from 0.9.3 to 0.9.4 --- {{cookiecutter.project_slug}}/requirements/base.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/base.txt b/{{cookiecutter.project_slug}}/requirements/base.txt index b41be3b0..0b18afc5 100644 --- a/{{cookiecutter.project_slug}}/requirements/base.txt +++ b/{{cookiecutter.project_slug}}/requirements/base.txt @@ -13,7 +13,7 @@ redis==3.4.1 # https://github.com/andymccurdy/redis-py celery==4.4.2 # pyup: < 5.0 # https://github.com/celery/celery django-celery-beat==2.0.0 # https://github.com/celery/django-celery-beat {%- if cookiecutter.use_docker == 'y' %} -flower==0.9.3 # https://github.com/mher/flower +flower==0.9.4 # https://github.com/mher/flower {%- endif %} {%- endif %} From 53b240af9a9be8439ea9e36ab9f7acd33786687f Mon Sep 17 00:00:00 2001 From: browniebroke Date: Sun, 29 Mar 2020 12:00:34 +0100 Subject: [PATCH 122/182] Update flake8-isort from 2.9.0 to 2.9.1 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index 2c7ee602..70c498f2 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -19,7 +19,7 @@ pytest-sugar==0.9.2 # https://github.com/Frozenball/pytest-sugar # Code quality # ------------------------------------------------------------------------------ flake8==3.7.9 # https://github.com/PyCQA/flake8 -flake8-isort==2.9.0 # https://github.com/gforcada/flake8-isort +flake8-isort==2.9.1 # https://github.com/gforcada/flake8-isort coverage==5.0.4 # https://github.com/nedbat/coveragepy black==19.10b0 # https://github.com/ambv/black pylint-django==2.0.14 # https://github.com/PyCQA/pylint-django From ec374425348c1241a918905a4a8409930e73599e Mon Sep 17 00:00:00 2001 From: Ernesto Cedeno Date: Sun, 29 Mar 2020 19:54:30 +0200 Subject: [PATCH 123/182] Add Ernesto Cedeno to Contributors --- CONTRIBUTORS.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index 2e7b11e6..e1416cf7 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -115,6 +115,7 @@ Listed in alphabetical order. Emanuel Calso `@bloodpet`_ @bloodpet Eraldo Energy `@eraldo`_ Eric Groom `@ericgroom`_ + Ernesto Cedeno `@codnee` Eyad Al Sibai `@eyadsibai`_ Felipe Arruda `@arruda`_ Florian Idelberger `@step21`_ @windrush From 0cdf60ceac4398aa74bbf8a45a4a92756c0e3d3b Mon Sep 17 00:00:00 2001 From: Ernesto Cedeno Date: Sun, 29 Mar 2020 19:55:27 +0200 Subject: [PATCH 124/182] Change Python version to 3.8 --- .travis.yml | 4 ++-- CONTRIBUTING.rst | 4 ++-- README.rst | 2 +- docs/deployment-on-pythonanywhere.rst | 2 +- docs/developing-locally.rst | 4 ++-- hooks/pre_gen_project.py | 2 +- setup.py | 2 +- tox.ini | 2 +- {{cookiecutter.project_slug}}/.travis.yml | 2 +- {{cookiecutter.project_slug}}/compose/local/django/Dockerfile | 2 +- .../compose/production/django/Dockerfile | 2 +- {{cookiecutter.project_slug}}/runtime.txt | 2 +- {{cookiecutter.project_slug}}/setup.cfg | 2 +- 13 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 52786a17..b250148e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ services: language: python -python: 3.7 +python: 3.8 before_install: - docker-compose -v @@ -14,7 +14,7 @@ before_install: matrix: include: - name: Test results - script: tox -e py37 + script: tox -e py38 - name: Black template script: tox -e black-template - name: Basic Docker diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index cb59ae5f..0a64e628 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -39,9 +39,9 @@ To run all tests using various versions of python in virtualenvs defined in tox. It is possible to test with a specific version of python. To do this, the command is:: - $ tox -e py37 + $ tox -e py38 -This will run py.test with the python3.7 interpreter, for example. +This will run py.test with the python3.8 interpreter, for example. To run a particular test with tox for against your current Python version:: diff --git a/README.rst b/README.rst index 1855f59f..475d41cf 100644 --- a/README.rst +++ b/README.rst @@ -37,7 +37,7 @@ Features --------- * For Django 3.0 -* Works with Python 3.7 +* Works with Python 3.8 * Renders Django projects with 100% starting test coverage * Twitter Bootstrap_ v4 (`maintained Foundation fork`_ also available) * 12-Factor_ based settings via django-environ_ diff --git a/docs/deployment-on-pythonanywhere.rst b/docs/deployment-on-pythonanywhere.rst index 4738d5a5..75109675 100644 --- a/docs/deployment-on-pythonanywhere.rst +++ b/docs/deployment-on-pythonanywhere.rst @@ -35,7 +35,7 @@ Make sure your project is fully committed and pushed up to Bitbucket or Github o git clone # you can also use hg cd my-project-name - mkvirtualenv --python=/usr/bin/python3.7 my-project-name + mkvirtualenv --python=/usr/bin/python3.8 my-project-name pip install -r requirements/production.txt # may take a few minutes diff --git a/docs/developing-locally.rst b/docs/developing-locally.rst index 7a58d099..f02e5c56 100644 --- a/docs/developing-locally.rst +++ b/docs/developing-locally.rst @@ -9,7 +9,7 @@ Setting Up Development Environment Make sure to have the following on your host: -* Python 3.7 +* Python 3.8 * PostgreSQL_. * Redis_, if using Celery @@ -17,7 +17,7 @@ First things first. #. Create a virtualenv: :: - $ python3.7 -m venv + $ python3.8 -m venv #. Activate the virtualenv you have just created: :: diff --git a/hooks/pre_gen_project.py b/hooks/pre_gen_project.py index 54334ded..8eaf4983 100644 --- a/hooks/pre_gen_project.py +++ b/hooks/pre_gen_project.py @@ -35,7 +35,7 @@ if "{{ cookiecutter.use_docker }}".lower() == "n": if python_major_version == 2: print( WARNING + "You're running cookiecutter under Python 2, but the generated " - "project requires Python 3.7+. Do you want to proceed (y/n)? " + TERMINATOR + "project requires Python 3.8+. Do you want to proceed (y/n)? " + TERMINATOR ) yes_options, no_options = frozenset(["y"]), frozenset(["n"]) while True: diff --git a/setup.py b/setup.py index e311e82a..ee325e8a 100644 --- a/setup.py +++ b/setup.py @@ -40,7 +40,7 @@ setup( "License :: OSI Approved :: BSD License", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", "Programming Language :: Python :: Implementation :: CPython", "Topic :: Software Development", ], diff --git a/tox.ini b/tox.ini index 737b26e7..242183c3 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] skipsdist = true -envlist = py37,black-template +envlist = py38,black-template [testenv] deps = -rrequirements.txt diff --git a/{{cookiecutter.project_slug}}/.travis.yml b/{{cookiecutter.project_slug}}/.travis.yml index 31695e41..6f759697 100644 --- a/{{cookiecutter.project_slug}}/.travis.yml +++ b/{{cookiecutter.project_slug}}/.travis.yml @@ -10,7 +10,7 @@ before_install: - sudo apt-get install -qq libsqlite3-dev libxml2 libxml2-dev libssl-dev libbz2-dev wget curl llvm language: python python: - - "3.7" + - "3.8" install: - pip install -r requirements/local.txt script: diff --git a/{{cookiecutter.project_slug}}/compose/local/django/Dockerfile b/{{cookiecutter.project_slug}}/compose/local/django/Dockerfile index 6a356ac6..5473f114 100644 --- a/{{cookiecutter.project_slug}}/compose/local/django/Dockerfile +++ b/{{cookiecutter.project_slug}}/compose/local/django/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.7-slim-buster +FROM python:3.8-slim-buster ENV PYTHONUNBUFFERED 1 ENV PYTHONDONTWRITEBYTECODE 1 diff --git a/{{cookiecutter.project_slug}}/compose/production/django/Dockerfile b/{{cookiecutter.project_slug}}/compose/production/django/Dockerfile index 42ecbeaf..72f71d6e 100644 --- a/{{cookiecutter.project_slug}}/compose/production/django/Dockerfile +++ b/{{cookiecutter.project_slug}}/compose/production/django/Dockerfile @@ -9,7 +9,7 @@ RUN npm run build # Python build stage {%- endif %} -FROM python:3.7-slim-buster +FROM python:3.8-slim-buster ENV PYTHONUNBUFFERED 1 diff --git a/{{cookiecutter.project_slug}}/runtime.txt b/{{cookiecutter.project_slug}}/runtime.txt index 6919bf9e..724c203e 100644 --- a/{{cookiecutter.project_slug}}/runtime.txt +++ b/{{cookiecutter.project_slug}}/runtime.txt @@ -1 +1 @@ -python-3.7.6 +python-3.8.2 diff --git a/{{cookiecutter.project_slug}}/setup.cfg b/{{cookiecutter.project_slug}}/setup.cfg index 5f7d9b65..f1f66519 100644 --- a/{{cookiecutter.project_slug}}/setup.cfg +++ b/{{cookiecutter.project_slug}}/setup.cfg @@ -7,7 +7,7 @@ max-line-length = 120 exclude = .tox,.git,*/migrations/*,*/static/CACHE/*,docs,node_modules [mypy] -python_version = 3.7 +python_version = 3.8 check_untyped_defs = True ignore_missing_imports = True warn_unused_ignores = True From a2966da438aafcc2cdeb9c987e20f5866fd146d9 Mon Sep 17 00:00:00 2001 From: codnee Date: Sun, 29 Mar 2020 23:30:42 +0200 Subject: [PATCH 125/182] Update CONTRIBUTORS.rst Fix link to @codnee Co-Authored-By: Bruno Alla --- CONTRIBUTORS.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index e1416cf7..3d2a8463 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -115,7 +115,7 @@ Listed in alphabetical order. Emanuel Calso `@bloodpet`_ @bloodpet Eraldo Energy `@eraldo`_ Eric Groom `@ericgroom`_ - Ernesto Cedeno `@codnee` + Ernesto Cedeno `@codnee`_ Eyad Al Sibai `@eyadsibai`_ Felipe Arruda `@arruda`_ Florian Idelberger `@step21`_ @windrush From 94a1fef0af2450b89e6b4861b5155a02c2ee5e05 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Tue, 31 Mar 2020 12:00:31 +0100 Subject: [PATCH 126/182] Update pytest-django from 3.8.0 to 3.9.0 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index 70c498f2..e2e3fdd6 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -35,4 +35,4 @@ factory-boy==2.12.0 # https://github.com/FactoryBoy/factory_boy django-debug-toolbar==2.2 # https://github.com/jazzband/django-debug-toolbar django-extensions==2.2.9 # https://github.com/django-extensions/django-extensions django-coverage-plugin==1.8.0 # https://github.com/nedbat/django_coverage_plugin -pytest-django==3.8.0 # https://github.com/pytest-dev/pytest-django +pytest-django==3.9.0 # https://github.com/pytest-dev/pytest-django From bbd940363f29ba41f6e0527d6b2e8b908738bf96 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Wed, 1 Apr 2020 12:00:31 +0100 Subject: [PATCH 127/182] Update django from 3.0.4 to 3.0.5 --- {{cookiecutter.project_slug}}/requirements/base.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/base.txt b/{{cookiecutter.project_slug}}/requirements/base.txt index 0b18afc5..8f473c50 100644 --- a/{{cookiecutter.project_slug}}/requirements/base.txt +++ b/{{cookiecutter.project_slug}}/requirements/base.txt @@ -19,7 +19,7 @@ flower==0.9.4 # https://github.com/mher/flower # Django # ------------------------------------------------------------------------------ -django==3.0.4 # pyup: < 3.1 # https://www.djangoproject.com/ +django==3.0.5 # pyup: < 3.1 # https://www.djangoproject.com/ django-environ==0.4.5 # https://github.com/joke2k/django-environ django-model-utils==4.0.0 # https://github.com/jazzband/django-model-utils django-allauth==0.41.0 # https://github.com/pennersr/django-allauth From 80fdb5c7cc3c65dcc78552585d76d5e36102b37b Mon Sep 17 00:00:00 2001 From: browniebroke Date: Wed, 1 Apr 2020 12:00:35 +0100 Subject: [PATCH 128/182] Update werkzeug from 1.0.0 to 1.0.1 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index e2e3fdd6..8f7cbd73 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -1,6 +1,6 @@ -r ./base.txt -Werkzeug==1.0.0 # https://github.com/pallets/werkzeug +Werkzeug==1.0.1 # https://github.com/pallets/werkzeug ipdb==0.13.2 # https://github.com/gotcha/ipdb Sphinx==2.4.4 # https://github.com/sphinx-doc/sphinx {%- if cookiecutter.use_docker == 'y' %} From a9977e78e058b83907854938cebea15586dec22f Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Wed, 1 Apr 2020 16:02:21 +0100 Subject: [PATCH 129/182] Bump version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index e311e82a..d1051d8b 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ except ImportError: # Our version ALWAYS matches the version of Django we support # If Django has a new release, we branch, tag, then update this setting after the tag. -version = "3.0.4" +version = "3.0.5" if sys.argv[-1] == "tag": os.system(f'git tag -a {version} -m "version {version}"') From 8eb14e6c84f1b964c24645de93eeb1c6c96fa7bc Mon Sep 17 00:00:00 2001 From: browniebroke Date: Thu, 2 Apr 2020 12:00:31 +0100 Subject: [PATCH 130/182] Update pillow from 7.0.0 to 7.1.0 --- {{cookiecutter.project_slug}}/requirements/base.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/base.txt b/{{cookiecutter.project_slug}}/requirements/base.txt index 8f473c50..8752ec37 100644 --- a/{{cookiecutter.project_slug}}/requirements/base.txt +++ b/{{cookiecutter.project_slug}}/requirements/base.txt @@ -1,6 +1,6 @@ pytz==2019.3 # https://github.com/stub42/pytz python-slugify==4.0.0 # https://github.com/un33k/python-slugify -Pillow==7.0.0 # https://github.com/python-pillow/Pillow +Pillow==7.1.0 # https://github.com/python-pillow/Pillow {%- if cookiecutter.use_compressor == "y" %} rcssmin==1.0.6{% if cookiecutter.windows == 'y' and cookiecutter.use_docker == 'n' %} --install-option="--without-c-extensions"{% endif %} # https://github.com/ndparker/rcssmin {%- endif %} From d16760bf8b3dff00fc63d35993395be0e017fbb4 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Fri, 3 Apr 2020 12:00:30 +0100 Subject: [PATCH 131/182] Update pillow from 7.1.0 to 7.1.1 --- {{cookiecutter.project_slug}}/requirements/base.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/base.txt b/{{cookiecutter.project_slug}}/requirements/base.txt index 8752ec37..b7a370d4 100644 --- a/{{cookiecutter.project_slug}}/requirements/base.txt +++ b/{{cookiecutter.project_slug}}/requirements/base.txt @@ -1,6 +1,6 @@ pytz==2019.3 # https://github.com/stub42/pytz python-slugify==4.0.0 # https://github.com/un33k/python-slugify -Pillow==7.1.0 # https://github.com/python-pillow/Pillow +Pillow==7.1.1 # https://github.com/python-pillow/Pillow {%- if cookiecutter.use_compressor == "y" %} rcssmin==1.0.6{% if cookiecutter.windows == 'y' and cookiecutter.use_docker == 'n' %} --install-option="--without-c-extensions"{% endif %} # https://github.com/ndparker/rcssmin {%- endif %} From 68d751f2d4dde5297771a6e665c395585e95a7e1 Mon Sep 17 00:00:00 2001 From: gwiskur Date: Sat, 4 Apr 2020 08:59:00 -0500 Subject: [PATCH 132/182] Add compress command when using Django Compressor If the django-compressor option is selected, then the ``compress`` command is required where COMPRESS_OFFLINE = True is default in the production settings. See here: https://django-compressor.readthedocs.io/en/latest/usage/#offline-compression --- CONTRIBUTORS.rst | 2 ++ docs/deployment-on-pythonanywhere.rst | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index 2e7b11e6..3ab939c2 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -122,6 +122,7 @@ Listed in alphabetical order. Garry Cairns `@garry-cairns`_ Garry Polley `@garrypolley`_ Gilbishkosma `@Gilbishkosma`_ + Glenn Wiskur `@gwiskur`_ Guilherme Guy `@guilherme1guy`_ Hamish Durkin `@durkode`_ Hana Quadara `@hanaquadara`_ @@ -298,6 +299,7 @@ Listed in alphabetical order. .. _@garry-cairns: https://github.com/garry-cairns .. _@garrypolley: https://github.com/garrypolley .. _@Gilbishkosma: https://github.com/Gilbishkosma +.. _@gwiskur: https://github.com/gwiskur .. _@glasslion: https://github.com/glasslion .. _@goldhand: https://github.com/goldhand .. _@hackebrot: https://github.com/hackebrot diff --git a/docs/deployment-on-pythonanywhere.rst b/docs/deployment-on-pythonanywhere.rst index 4738d5a5..a924d69a 100644 --- a/docs/deployment-on-pythonanywhere.rst +++ b/docs/deployment-on-pythonanywhere.rst @@ -15,7 +15,7 @@ Full instructions follow, but here's a high-level view. 2. Set your config variables in the *postactivate* script -3. Run the *manage.py* ``migrate`` and ``collectstatic`` commands +3. Run the *manage.py* ``migrate`` and ``collectstatic`` {%- if cookiecutter.use_compressor == "y" %}and ``compress`` {%- endif %}commands 4. Add an entry to the PythonAnywhere *Web tab* @@ -109,6 +109,7 @@ Now run the migration, and collectstatic: source $VIRTUAL_ENV/bin/postactivate python manage.py migrate python manage.py collectstatic + {%- if cookiecutter.use_compressor == "y" %}python manage.py compress {%- endif %} # and, optionally python manage.py createsuperuser @@ -175,6 +176,7 @@ For subsequent deployments, the procedure is much simpler. In a Bash console: git pull python manage.py migrate python manage.py collectstatic + {%- if cookiecutter.use_compressor == "y" %}python manage.py compress {%- endif %} And then go to the Web tab and hit **Reload** From 0df3087d3d93a26daeceac8ed31518ce7be40541 Mon Sep 17 00:00:00 2001 From: Tevak Date: Sat, 4 Apr 2020 17:26:24 +0200 Subject: [PATCH 133/182] Traefik - Also redirect wwww. to service. --- CONTRIBUTORS.rst | 2 ++ .../compose/production/traefik/traefik.yml | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index 3ab939c2..b39845c2 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -200,6 +200,7 @@ Listed in alphabetical order. Sascha `@saschalalala`_ @saschalalala Shupeyko Nikita `@webyneter`_ Sławek Ehlert `@slafs`_ + Sorasful `@sorasful`_ Srinivas Nyayapati `@shireenrao`_ stepmr `@stepmr`_ Steve Steiner `@ssteinerX`_ @@ -372,6 +373,7 @@ Listed in alphabetical order. .. _@siauPatrick: https://github.com/siauPatrick .. _@sladinji: https://github.com/sladinji .. _@slafs: https://github.com/slafs +.. _@sorasful:: https://github.com/sorasful .. _@ssteinerX: https://github.com/ssteinerx .. _@step21: https://github.com/step21 .. _@stepmr: https://github.com/stepmr diff --git a/{{cookiecutter.project_slug}}/compose/production/traefik/traefik.yml b/{{cookiecutter.project_slug}}/compose/production/traefik/traefik.yml index 923774f4..960d1ac2 100644 --- a/{{cookiecutter.project_slug}}/compose/production/traefik/traefik.yml +++ b/{{cookiecutter.project_slug}}/compose/production/traefik/traefik.yml @@ -28,7 +28,7 @@ certificatesResolvers: http: routers: web-router: - rule: "Host(`{{ cookiecutter.domain_name }}`)" + rule: "Host(`{{ cookiecutter.domain_name }}`) || Host(`www.{{ cookiecutter.domain_name }}`)" entryPoints: - web middlewares: @@ -37,7 +37,7 @@ http: service: django web-secure-router: - rule: "Host(`{{ cookiecutter.domain_name }}`)" + rule: "Host(`{{ cookiecutter.domain_name }}`) || Host(`www.{{ cookiecutter.domain_name }}`)" entryPoints: - web-secure middlewares: From bd104afb3dfdc0c4a6e0bc817c0deb5ff73df66a Mon Sep 17 00:00:00 2001 From: browniebroke Date: Mon, 6 Apr 2020 12:00:30 +0100 Subject: [PATCH 134/182] Update sphinx from 2.4.4 to 3.0.0 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index 8f7cbd73..370ea21e 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -2,7 +2,7 @@ Werkzeug==1.0.1 # https://github.com/pallets/werkzeug ipdb==0.13.2 # https://github.com/gotcha/ipdb -Sphinx==2.4.4 # https://github.com/sphinx-doc/sphinx +Sphinx==3.0.0 # https://github.com/sphinx-doc/sphinx {%- if cookiecutter.use_docker == 'y' %} psycopg2==2.8.4 --no-binary psycopg2 # https://github.com/psycopg/psycopg2 {%- else %} From 75f4d304f4898114b699e9e1cc4ef9e3a64a60ae Mon Sep 17 00:00:00 2001 From: browniebroke Date: Mon, 6 Apr 2020 12:00:33 +0100 Subject: [PATCH 135/182] Update psycopg2-binary from 2.8.4 to 2.8.5 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index 370ea21e..49ed908d 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -6,7 +6,7 @@ Sphinx==3.0.0 # https://github.com/sphinx-doc/sphinx {%- if cookiecutter.use_docker == 'y' %} psycopg2==2.8.4 --no-binary psycopg2 # https://github.com/psycopg/psycopg2 {%- else %} -psycopg2-binary==2.8.4 # https://github.com/psycopg/psycopg2 +psycopg2-binary==2.8.5 # https://github.com/psycopg/psycopg2 {%- endif %} # Testing From 94d7bd11ad27511d9f5beab72282a7d978a2f06f Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Mon, 6 Apr 2020 13:36:25 +0100 Subject: [PATCH 136/182] Update psycopg2 from 2.8.4 to 2.8.5 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- {{cookiecutter.project_slug}}/requirements/production.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index 49ed908d..6dbf448e 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -4,7 +4,7 @@ Werkzeug==1.0.1 # https://github.com/pallets/werkzeug ipdb==0.13.2 # https://github.com/gotcha/ipdb Sphinx==3.0.0 # https://github.com/sphinx-doc/sphinx {%- if cookiecutter.use_docker == 'y' %} -psycopg2==2.8.4 --no-binary psycopg2 # https://github.com/psycopg/psycopg2 +psycopg2==2.8.5 --no-binary psycopg2 # https://github.com/psycopg/psycopg2 {%- else %} psycopg2-binary==2.8.5 # https://github.com/psycopg/psycopg2 {%- endif %} diff --git a/{{cookiecutter.project_slug}}/requirements/production.txt b/{{cookiecutter.project_slug}}/requirements/production.txt index a8bc31dc..b13c4533 100644 --- a/{{cookiecutter.project_slug}}/requirements/production.txt +++ b/{{cookiecutter.project_slug}}/requirements/production.txt @@ -3,7 +3,7 @@ -r ./base.txt gunicorn==20.0.4 # https://github.com/benoitc/gunicorn -psycopg2==2.8.4 --no-binary psycopg2 # https://github.com/psycopg/psycopg2 +psycopg2==2.8.5 --no-binary psycopg2 # https://github.com/psycopg/psycopg2 {%- if cookiecutter.use_whitenoise == 'n' %} Collectfast==2.1.0 # https://github.com/antonagestam/collectfast {%- endif %} From 041751a359fd774857f723c4344e5b8dd9680c66 Mon Sep 17 00:00:00 2001 From: Andrew Chen Wang <60190294+Andrew-Chen-Wang@users.noreply.github.com> Date: Tue, 7 Apr 2020 00:23:31 -0400 Subject: [PATCH 137/182] Fixed linter for asgi.py --- {{cookiecutter.project_slug}}/config/asgi.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/{{cookiecutter.project_slug}}/config/asgi.py b/{{cookiecutter.project_slug}}/config/asgi.py index a325839b..ef3ff58e 100644 --- a/{{cookiecutter.project_slug}}/config/asgi.py +++ b/{{cookiecutter.project_slug}}/config/asgi.py @@ -5,6 +5,7 @@ It exposes the ASGI callable as a module-level variable named ``application``. For more information on this file, see https://docs.djangoproject.com/en/dev/howto/deployment/asgi/ + """ import os import sys @@ -30,8 +31,8 @@ django_application = get_asgi_application() # from helloworld.asgi import HelloWorldApplication # application = HelloWorldApplication(application) -# Importing websocket application so that apps are loaded first -from .websocket import websocket_application # noqa +# Import websocket application here, so apps from django_application are loaded first +from .websocket import websocket_application # noqa isort:skip async def application(scope, receive, send): From 1d2d881aba9b72653bbd206af4afd6ba297d0649 Mon Sep 17 00:00:00 2001 From: Duda Nogueira Date: Tue, 7 Apr 2020 18:53:09 -0300 Subject: [PATCH 138/182] Fix INTERNAL_IPS for DOCKER when ip higher than 9 previously, for IP ex: 172.19.0.13 becomes: 172.19.0.11 now, it becomes 172.19.0.1 --- {{cookiecutter.project_slug}}/config/settings/local.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/config/settings/local.py b/{{cookiecutter.project_slug}}/config/settings/local.py index 015d8aff..9bbfa60d 100644 --- a/{{cookiecutter.project_slug}}/config/settings/local.py +++ b/{{cookiecutter.project_slug}}/config/settings/local.py @@ -68,7 +68,7 @@ if env("USE_DOCKER") == "yes": import socket hostname, _, ips = socket.gethostbyname_ex(socket.gethostname()) - INTERNAL_IPS += [ip[:-1] + "1" for ip in ips] + INTERNAL_IPS += [".".join(ip.split(".")[:-1]+["1"]) for ip in ips] {%- endif %} # django-extensions From 8d9796d9f8db16df6e222daa4c09bf12f1d3db9d Mon Sep 17 00:00:00 2001 From: Duda Nogueira Date: Tue, 7 Apr 2020 19:03:34 -0300 Subject: [PATCH 139/182] Update CONTRIBUTORS.rst --- CONTRIBUTORS.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index 3ab939c2..01248ecc 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -112,6 +112,7 @@ Listed in alphabetical order. Diane Chen `@purplediane`_ @purplediane88 Dónal Adams `@epileptic-fish`_ Dong Huynh `@trungdong`_ + Duda Nogueira `@dudanogueira`_ @dudanogueira Emanuel Calso `@bloodpet`_ @bloodpet Eraldo Energy `@eraldo`_ Eric Groom `@ericgroom`_ From 5602d4f73b04a1a0b9dc3a124303f74932dd4f17 Mon Sep 17 00:00:00 2001 From: Duda Nogueira Date: Tue, 7 Apr 2020 19:11:43 -0300 Subject: [PATCH 140/182] Link to my github --- CONTRIBUTORS.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index 01248ecc..64a901d1 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -112,7 +112,7 @@ Listed in alphabetical order. Diane Chen `@purplediane`_ @purplediane88 Dónal Adams `@epileptic-fish`_ Dong Huynh `@trungdong`_ - Duda Nogueira `@dudanogueira`_ @dudanogueira + Duda Nogueira `@dudanogueira`_ @dudanogueira Emanuel Calso `@bloodpet`_ @bloodpet Eraldo Energy `@eraldo`_ Eric Groom `@ericgroom`_ @@ -284,6 +284,7 @@ Listed in alphabetical order. .. _@dezoito: https://github.com/dezoito .. _@dhepper: https://github.com/dhepper .. _@dot2dotseurat: https://github.com/dot2dotseurat +.. _@dudanogueira: https://github.com/dudanogueira .. _@dsclementsen: https://github.com/dsclementsen .. _@guilherme1guy: https://github.com/guilherme1guy .. _@durkode: https://github.com/durkode From 819e9ff27351001055dc10382b70a919e3634573 Mon Sep 17 00:00:00 2001 From: Duda Nogueira Date: Tue, 7 Apr 2020 19:29:46 -0300 Subject: [PATCH 141/182] Adding some spaces to pass build :P --- {{cookiecutter.project_slug}}/config/settings/local.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/config/settings/local.py b/{{cookiecutter.project_slug}}/config/settings/local.py index 9bbfa60d..21e6a8df 100644 --- a/{{cookiecutter.project_slug}}/config/settings/local.py +++ b/{{cookiecutter.project_slug}}/config/settings/local.py @@ -68,7 +68,7 @@ if env("USE_DOCKER") == "yes": import socket hostname, _, ips = socket.gethostbyname_ex(socket.gethostname()) - INTERNAL_IPS += [".".join(ip.split(".")[:-1]+["1"]) for ip in ips] + INTERNAL_IPS += [".".join(ip.split(".")[:-1] + ["1"]) for ip in ips] {%- endif %} # django-extensions From e474ed3f1aa70cf8790089200c99ae71037c1e1b Mon Sep 17 00:00:00 2001 From: browniebroke Date: Sat, 11 Apr 2020 12:00:29 +0100 Subject: [PATCH 142/182] Update sphinx from 3.0.0 to 3.0.1 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index 6dbf448e..ddecd541 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -2,7 +2,7 @@ Werkzeug==1.0.1 # https://github.com/pallets/werkzeug ipdb==0.13.2 # https://github.com/gotcha/ipdb -Sphinx==3.0.0 # https://github.com/sphinx-doc/sphinx +Sphinx==3.0.1 # https://github.com/sphinx-doc/sphinx {%- if cookiecutter.use_docker == 'y' %} psycopg2==2.8.5 --no-binary psycopg2 # https://github.com/psycopg/psycopg2 {%- else %} From 0f388a6d96655e732b5f066844bcfddba7529196 Mon Sep 17 00:00:00 2001 From: Tano Abeleyra Date: Sat, 11 Apr 2020 14:49:04 -0300 Subject: [PATCH 143/182] Fix minor typo --- {{cookiecutter.project_slug}}/config/settings/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/config/settings/base.py b/{{cookiecutter.project_slug}}/config/settings/base.py index 6a2a9c3f..390f2252 100644 --- a/{{cookiecutter.project_slug}}/config/settings/base.py +++ b/{{cookiecutter.project_slug}}/config/settings/base.py @@ -311,7 +311,7 @@ INSTALLED_APPS += ["compressor"] STATICFILES_FINDERS += ["compressor.finders.CompressorFinder"] {%- endif %} {% if cookiecutter.use_drf == "y" -%} -# django-reset-framework +# django-rest-framework # ------------------------------------------------------------------------------- # django-rest-framework - https://www.django-rest-framework.org/api-guide/settings/ REST_FRAMEWORK = { From 83934f3d86e77ee98f62e3b36a6e2c6f653b27a1 Mon Sep 17 00:00:00 2001 From: Dani Hodovic Date: Sun, 12 Apr 2020 21:40:02 +0300 Subject: [PATCH 144/182] Store coverage config in setup.cfg Less is more. Unify tooling configuration in one file. --- {{cookiecutter.project_slug}}/.coveragerc | 5 ----- {{cookiecutter.project_slug}}/setup.cfg | 6 ++++++ 2 files changed, 6 insertions(+), 5 deletions(-) delete mode 100644 {{cookiecutter.project_slug}}/.coveragerc diff --git a/{{cookiecutter.project_slug}}/.coveragerc b/{{cookiecutter.project_slug}}/.coveragerc deleted file mode 100644 index 283a4b89..00000000 --- a/{{cookiecutter.project_slug}}/.coveragerc +++ /dev/null @@ -1,5 +0,0 @@ -[run] -include = {{cookiecutter.project_slug}}/* -omit = *migrations*, *tests* -plugins = - django_coverage_plugin diff --git a/{{cookiecutter.project_slug}}/setup.cfg b/{{cookiecutter.project_slug}}/setup.cfg index 5f7d9b65..5bcbc8c4 100644 --- a/{{cookiecutter.project_slug}}/setup.cfg +++ b/{{cookiecutter.project_slug}}/setup.cfg @@ -21,3 +21,9 @@ django_settings_module = config.settings.test [mypy-*.migrations.*] # Django migrations should not produce any errors: ignore_errors = True + +[coverage:run] +include = {{cookiecutter.project_slug}}/* +omit = *migrations*, *tests* +plugins = + django_coverage_plugin From 6510ab1555dfea7281847ca832bb7e55e3b4b555 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Mon, 13 Apr 2020 12:00:29 +0100 Subject: [PATCH 145/182] Update coverage from 5.0.4 to 5.1 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index ddecd541..975ed252 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -20,7 +20,7 @@ pytest-sugar==0.9.2 # https://github.com/Frozenball/pytest-sugar # ------------------------------------------------------------------------------ flake8==3.7.9 # https://github.com/PyCQA/flake8 flake8-isort==2.9.1 # https://github.com/gforcada/flake8-isort -coverage==5.0.4 # https://github.com/nedbat/coveragepy +coverage==5.1 # https://github.com/nedbat/coveragepy black==19.10b0 # https://github.com/ambv/black pylint-django==2.0.14 # https://github.com/PyCQA/pylint-django {%- if cookiecutter.use_celery == 'y' %} From 7bf1a81dcc7365cc44d7b8fcf4cc34b2f8224ec1 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Mon, 13 Apr 2020 15:16:08 +0100 Subject: [PATCH 146/182] Fix broken link in contributors list --- CONTRIBUTORS.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index 209d22a3..40119fd3 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -272,6 +272,7 @@ Listed in alphabetical order. .. _@chuckus: https://github.com/chuckus .. _@cmackenzie1: https://github.com/cmackenzie1 .. _@cmargieson: https://github.com/cmargieson +.. _@codnee: https://github.com/codnee .. _@cole: https://github.com/cole .. _@Collederas: https://github.com/Collederas .. _@curtisstpierre: https://github.com/curtisstpierre From 02aaba1ee5c38586408c3ff31fe64af64a1815c5 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Mon, 13 Apr 2020 15:24:45 +0100 Subject: [PATCH 147/182] Added a few things to the changelog --- CHANGELOG.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae8f7efe..27a8578a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,36 @@ # Change Log All enhancements and patches to Cookiecutter Django will be documented in this file. +## [2020-04-13] +### Changed +- Updated to Python 3.8 (@codnee) +- Moved converage config in setup.cfg (@danihodovic) + +## [2020-04-08] +### Fixed +- Internal IPs for debug toolbar (@dudanogueira) + +## [2020-04-04] +### Fixed +- Added compress command command with Django compressor (@gwiskur) + +## [2020-03-23] +### Changed +- Updated project to Django 3.0 + +## [2020-03-17] +### Changed +- Handle paths using Pathlib (@jules-ch) + +### Fixed +- Pre-commit hook regex (@demestav) + +## [2020-03-16] +### Added +- Support for all Anymail providers (@Andrew-Chen-Wang) +### Fixed +- Django compressor setup (@jameswilliams1) + ## [2020-01-23] ### Changed - Fix UserFactory to set the password if provided (@BoPeng) From f0813a24b2e5648b8f6d2f2d5ce7da36dd4fead5 Mon Sep 17 00:00:00 2001 From: Andrew-Chen-Wang Date: Mon, 13 Apr 2020 10:57:42 -0400 Subject: [PATCH 148/182] Added Heroku and Gulp support * Deleted some unnecessary info inside asgi.py --- {{cookiecutter.project_slug}}/Procfile | 4 ++++ {{cookiecutter.project_slug}}/config/asgi.py | 12 ++---------- {{cookiecutter.project_slug}}/gulpfile.js | 17 +++++++++++++++++ 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/{{cookiecutter.project_slug}}/Procfile b/{{cookiecutter.project_slug}}/Procfile index 3838eafd..0becb2cb 100644 --- a/{{cookiecutter.project_slug}}/Procfile +++ b/{{cookiecutter.project_slug}}/Procfile @@ -1,5 +1,9 @@ release: python manage.py migrate +{% if cookiecutter.use_async == "y" -%} +web: gunicorn config.asgi:application -k uvicorn.workers.UvicornWorker +{%- else %} web: gunicorn config.wsgi:application +{%- endif %} {% if cookiecutter.use_celery == "y" -%} worker: celery worker --app=config.celery_app --loglevel=info beat: celery beat --app=config.celery_app --loglevel=info diff --git a/{{cookiecutter.project_slug}}/config/asgi.py b/{{cookiecutter.project_slug}}/config/asgi.py index ef3ff58e..485c8eca 100644 --- a/{{cookiecutter.project_slug}}/config/asgi.py +++ b/{{cookiecutter.project_slug}}/config/asgi.py @@ -7,7 +7,6 @@ For more information on this file, see https://docs.djangoproject.com/en/dev/howto/deployment/asgi/ """ -import os import sys from pathlib import Path @@ -17,22 +16,15 @@ from django.core.asgi import get_asgi_application # {{ cookiecutter.project_slug }} directory. app_path = Path(__file__).parents[1].resolve() sys.path.append(str(app_path / "{{ cookiecutter.project_slug }}")) -# We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks -# if running multiple sites in the same mod_wsgi process. To fix this, use -# mod_wsgi daemon mode with each site in its own daemon process, or use -# os.environ["DJANGO_SETTINGS_MODULE"] = "config.settings.production" -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.production") -# This application object is used by any ASGI server configured to use this -# file. This includes Django's development server, if the ASGI_APPLICATION -# setting points here. +# This application object is used by any ASGI server configured to use this file. django_application = get_asgi_application() # Apply ASGI middleware here. # from helloworld.asgi import HelloWorldApplication # application = HelloWorldApplication(application) # Import websocket application here, so apps from django_application are loaded first -from .websocket import websocket_application # noqa isort:skip +from config.websocket import websocket_application # noqa isort:skip async def application(scope, receive, send): diff --git a/{{cookiecutter.project_slug}}/gulpfile.js b/{{cookiecutter.project_slug}}/gulpfile.js index 3c28a735..89894d38 100644 --- a/{{cookiecutter.project_slug}}/gulpfile.js +++ b/{{cookiecutter.project_slug}}/gulpfile.js @@ -110,6 +110,18 @@ function imgCompression() { .pipe(dest(paths.images)) } +{% if cookiecutter.use_async == 'y' -%} +// Run django server +function asyncRunServer(cb) { + var cmd = spawn('gunicorn', [ + 'config.asgi', '-k', 'uvicorn.workers.UvicornWorker', '--reload' + ], {stdio: 'inherit'} + ) + cmd.on('close', function(code) { + console.log('gunicorn exited with code ' + code) + }) +} +{%- else %} // Run django server function runServer(cb) { var cmd = spawn('python', ['manage.py', 'runserver'], {stdio: 'inherit'}) @@ -118,6 +130,7 @@ function runServer(cb) { cb(code) }) } +{%- endif %} // Browser sync server for live reload function initBrowserSync() { @@ -166,8 +179,12 @@ const generateAssets = parallel( // Set up dev environment const dev = parallel( {%- if cookiecutter.use_docker == 'n' %} + {%- if cookiecutter.use_async == 'y' %} + asyncRunServer, + {%- else %} runServer, {%- endif %} + {%- endif %} initBrowserSync, watchPaths ) From cc099ae941a6136da9dfd5dd24ce41766fd720cb Mon Sep 17 00:00:00 2001 From: Andrew-Chen-Wang Date: Mon, 13 Apr 2020 11:26:09 -0400 Subject: [PATCH 149/182] Edited docs for local running async --- docs/developing-locally.rst | 6 +++++- {{cookiecutter.project_slug}}/compose/local/django/start | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/developing-locally.rst b/docs/developing-locally.rst index 7a58d099..dae14f6a 100644 --- a/docs/developing-locally.rst +++ b/docs/developing-locally.rst @@ -68,10 +68,14 @@ First things first. $ python manage.py migrate -#. See the application being served through Django development server: :: +#. If you're running synchronously, see the application being served through Django development server: :: $ python manage.py runserver 0.0.0.0:8000 +or if you're running asynchronously: :: + + $ gunicorn config.asgi --bind 0.0.0.0:8000 -k uvicorn.workers.UvicornWorker --reload + .. _PostgreSQL: https://www.postgresql.org/download/ .. _Redis: https://redis.io/download .. _createdb: https://www.postgresql.org/docs/current/static/app-createdb.html diff --git a/{{cookiecutter.project_slug}}/compose/local/django/start b/{{cookiecutter.project_slug}}/compose/local/django/start index 129266c8..9c0b43d1 100644 --- a/{{cookiecutter.project_slug}}/compose/local/django/start +++ b/{{cookiecutter.project_slug}}/compose/local/django/start @@ -7,7 +7,7 @@ set -o nounset python manage.py migrate {%- if cookiecutter.use_async == 'y' %} -/usr/local/bin/gunicorn config.asgi --bind 0.0.0.0:8000 --chdir=/app -k uvicorn.workers.UvicornWorker -e DJANGO_SETTINGS_MODULE=config.settings.local --reload +/usr/local/bin/gunicorn config.asgi --bind 0.0.0.0:8000 --chdir=/app -k uvicorn.workers.UvicornWorker --reload {%- else %} python manage.py runserver_plus 0.0.0.0:8000 {% endif %} From efd53908af9579c4a7b5b230bebec1bf18d3628e Mon Sep 17 00:00:00 2001 From: browniebroke Date: Tue, 14 Apr 2020 12:00:30 +0100 Subject: [PATCH 150/182] Update django-anymail from 7.0.0 to 7.1.0 --- {{cookiecutter.project_slug}}/requirements/production.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/production.txt b/{{cookiecutter.project_slug}}/requirements/production.txt index b13c4533..e0f4b332 100644 --- a/{{cookiecutter.project_slug}}/requirements/production.txt +++ b/{{cookiecutter.project_slug}}/requirements/production.txt @@ -19,7 +19,7 @@ django-storages[boto3]==1.9.1 # https://github.com/jschneier/django-storages django-storages[google]==1.9.1 # https://github.com/jschneier/django-storages {%- endif %} {%- if cookiecutter.mail_service == 'Mailgun' %} -django-anymail[mailgun]==7.0.0 # https://github.com/anymail/django-anymail +django-anymail[mailgun]==7.1.0 # https://github.com/anymail/django-anymail {%- elif cookiecutter.mail_service == 'Amazon SES' %} django-anymail[amazon_ses]==7.0.0 # https://github.com/anymail/django-anymail {%- elif cookiecutter.mail_service == 'Mailjet' %} From cbaf953ed29c37d11c7d251ca2c7c33e683860f7 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Tue, 14 Apr 2020 12:00:31 +0100 Subject: [PATCH 151/182] Update django-anymail from 7.0.0 to 7.1.0 --- {{cookiecutter.project_slug}}/requirements/production.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/production.txt b/{{cookiecutter.project_slug}}/requirements/production.txt index e0f4b332..f53110b7 100644 --- a/{{cookiecutter.project_slug}}/requirements/production.txt +++ b/{{cookiecutter.project_slug}}/requirements/production.txt @@ -21,7 +21,7 @@ django-storages[google]==1.9.1 # https://github.com/jschneier/django-storages {%- if cookiecutter.mail_service == 'Mailgun' %} django-anymail[mailgun]==7.1.0 # https://github.com/anymail/django-anymail {%- elif cookiecutter.mail_service == 'Amazon SES' %} -django-anymail[amazon_ses]==7.0.0 # https://github.com/anymail/django-anymail +django-anymail[amazon_ses]==7.1.0 # https://github.com/anymail/django-anymail {%- elif cookiecutter.mail_service == 'Mailjet' %} django-anymail[mailjet]==7.0.0 # https://github.com/anymail/django-anymail {%- elif cookiecutter.mail_service == 'Mandrill' %} From 7cc6fc0b3052102758b2fb6c28c8edc093de6cfe Mon Sep 17 00:00:00 2001 From: browniebroke Date: Tue, 14 Apr 2020 12:00:32 +0100 Subject: [PATCH 152/182] Update django-anymail from 7.0.0 to 7.1.0 --- {{cookiecutter.project_slug}}/requirements/production.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/production.txt b/{{cookiecutter.project_slug}}/requirements/production.txt index f53110b7..617c4978 100644 --- a/{{cookiecutter.project_slug}}/requirements/production.txt +++ b/{{cookiecutter.project_slug}}/requirements/production.txt @@ -23,7 +23,7 @@ django-anymail[mailgun]==7.1.0 # https://github.com/anymail/django-anymail {%- elif cookiecutter.mail_service == 'Amazon SES' %} django-anymail[amazon_ses]==7.1.0 # https://github.com/anymail/django-anymail {%- elif cookiecutter.mail_service == 'Mailjet' %} -django-anymail[mailjet]==7.0.0 # https://github.com/anymail/django-anymail +django-anymail[mailjet]==7.1.0 # https://github.com/anymail/django-anymail {%- elif cookiecutter.mail_service == 'Mandrill' %} django-anymail[mandrill]==7.0.0 # https://github.com/anymail/django-anymail {%- elif cookiecutter.mail_service == 'Postmark' %} From d816a62e43d39d45cb5cd2d8b5855d8bec081c7a Mon Sep 17 00:00:00 2001 From: browniebroke Date: Tue, 14 Apr 2020 12:00:33 +0100 Subject: [PATCH 153/182] Update django-anymail from 7.0.0 to 7.1.0 --- {{cookiecutter.project_slug}}/requirements/production.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/production.txt b/{{cookiecutter.project_slug}}/requirements/production.txt index 617c4978..9b9926aa 100644 --- a/{{cookiecutter.project_slug}}/requirements/production.txt +++ b/{{cookiecutter.project_slug}}/requirements/production.txt @@ -25,7 +25,7 @@ django-anymail[amazon_ses]==7.1.0 # https://github.com/anymail/django-anymail {%- elif cookiecutter.mail_service == 'Mailjet' %} django-anymail[mailjet]==7.1.0 # https://github.com/anymail/django-anymail {%- elif cookiecutter.mail_service == 'Mandrill' %} -django-anymail[mandrill]==7.0.0 # https://github.com/anymail/django-anymail +django-anymail[mandrill]==7.1.0 # https://github.com/anymail/django-anymail {%- elif cookiecutter.mail_service == 'Postmark' %} django-anymail[postmark]==7.0.0 # https://github.com/anymail/django-anymail {%- elif cookiecutter.mail_service == 'Sendgrid' %} From 81363cc0f8faeea9e85ef0df3e15583b25c21eb7 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Tue, 14 Apr 2020 12:00:35 +0100 Subject: [PATCH 154/182] Update django-anymail from 7.0.0 to 7.1.0 --- {{cookiecutter.project_slug}}/requirements/production.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/production.txt b/{{cookiecutter.project_slug}}/requirements/production.txt index 9b9926aa..48da0fa2 100644 --- a/{{cookiecutter.project_slug}}/requirements/production.txt +++ b/{{cookiecutter.project_slug}}/requirements/production.txt @@ -27,7 +27,7 @@ django-anymail[mailjet]==7.1.0 # https://github.com/anymail/django-anymail {%- elif cookiecutter.mail_service == 'Mandrill' %} django-anymail[mandrill]==7.1.0 # https://github.com/anymail/django-anymail {%- elif cookiecutter.mail_service == 'Postmark' %} -django-anymail[postmark]==7.0.0 # https://github.com/anymail/django-anymail +django-anymail[postmark]==7.1.0 # https://github.com/anymail/django-anymail {%- elif cookiecutter.mail_service == 'Sendgrid' %} django-anymail[sendgrid]==7.0.0 # https://github.com/anymail/django-anymail {%- elif cookiecutter.mail_service == 'SendinBlue' %} From 8bbcc6aa01637349719852ac37dc2b49885ab40c Mon Sep 17 00:00:00 2001 From: browniebroke Date: Tue, 14 Apr 2020 12:00:36 +0100 Subject: [PATCH 155/182] Update django-anymail from 7.0.0 to 7.1.0 --- {{cookiecutter.project_slug}}/requirements/production.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/production.txt b/{{cookiecutter.project_slug}}/requirements/production.txt index 48da0fa2..59f8dc96 100644 --- a/{{cookiecutter.project_slug}}/requirements/production.txt +++ b/{{cookiecutter.project_slug}}/requirements/production.txt @@ -29,7 +29,7 @@ django-anymail[mandrill]==7.1.0 # https://github.com/anymail/django-anymail {%- elif cookiecutter.mail_service == 'Postmark' %} django-anymail[postmark]==7.1.0 # https://github.com/anymail/django-anymail {%- elif cookiecutter.mail_service == 'Sendgrid' %} -django-anymail[sendgrid]==7.0.0 # https://github.com/anymail/django-anymail +django-anymail[sendgrid]==7.1.0 # https://github.com/anymail/django-anymail {%- elif cookiecutter.mail_service == 'SendinBlue' %} django-anymail[sendinblue]==7.0.0 # https://github.com/anymail/django-anymail {%- elif cookiecutter.mail_service == 'SparkPost' %} From 5040eb9ba49fdb711f97df2c64ebaa2dd8604d60 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Tue, 14 Apr 2020 12:00:37 +0100 Subject: [PATCH 156/182] Update django-anymail from 7.0.0 to 7.1.0 --- {{cookiecutter.project_slug}}/requirements/production.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/production.txt b/{{cookiecutter.project_slug}}/requirements/production.txt index 59f8dc96..74a5c00c 100644 --- a/{{cookiecutter.project_slug}}/requirements/production.txt +++ b/{{cookiecutter.project_slug}}/requirements/production.txt @@ -31,7 +31,7 @@ django-anymail[postmark]==7.1.0 # https://github.com/anymail/django-anymail {%- elif cookiecutter.mail_service == 'Sendgrid' %} django-anymail[sendgrid]==7.1.0 # https://github.com/anymail/django-anymail {%- elif cookiecutter.mail_service == 'SendinBlue' %} -django-anymail[sendinblue]==7.0.0 # https://github.com/anymail/django-anymail +django-anymail[sendinblue]==7.1.0 # https://github.com/anymail/django-anymail {%- elif cookiecutter.mail_service == 'SparkPost' %} django-anymail[sparkpost]==7.0.0 # https://github.com/anymail/django-anymail {%- elif cookiecutter.mail_service == 'Other SMTP' %} From 508ca6f4e853a9e8f56a12787113b5dbc4271b92 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Tue, 14 Apr 2020 12:00:37 +0100 Subject: [PATCH 157/182] Update django-anymail from 7.0.0 to 7.1.0 --- {{cookiecutter.project_slug}}/requirements/production.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/production.txt b/{{cookiecutter.project_slug}}/requirements/production.txt index 74a5c00c..bf34ee70 100644 --- a/{{cookiecutter.project_slug}}/requirements/production.txt +++ b/{{cookiecutter.project_slug}}/requirements/production.txt @@ -33,7 +33,7 @@ django-anymail[sendgrid]==7.1.0 # https://github.com/anymail/django-anymail {%- elif cookiecutter.mail_service == 'SendinBlue' %} django-anymail[sendinblue]==7.1.0 # https://github.com/anymail/django-anymail {%- elif cookiecutter.mail_service == 'SparkPost' %} -django-anymail[sparkpost]==7.0.0 # https://github.com/anymail/django-anymail +django-anymail[sparkpost]==7.1.0 # https://github.com/anymail/django-anymail {%- elif cookiecutter.mail_service == 'Other SMTP' %} django-anymail==7.0.0 # https://github.com/anymail/django-anymail {%- endif %} From 82cde2eacc598c119e717a4d32918ed2869953f3 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Tue, 14 Apr 2020 12:00:39 +0100 Subject: [PATCH 158/182] Update django-anymail from 7.0.0 to 7.1.0 --- {{cookiecutter.project_slug}}/requirements/production.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/production.txt b/{{cookiecutter.project_slug}}/requirements/production.txt index bf34ee70..83ed366f 100644 --- a/{{cookiecutter.project_slug}}/requirements/production.txt +++ b/{{cookiecutter.project_slug}}/requirements/production.txt @@ -35,5 +35,5 @@ django-anymail[sendinblue]==7.1.0 # https://github.com/anymail/django-anymail {%- elif cookiecutter.mail_service == 'SparkPost' %} django-anymail[sparkpost]==7.1.0 # https://github.com/anymail/django-anymail {%- elif cookiecutter.mail_service == 'Other SMTP' %} -django-anymail==7.0.0 # https://github.com/anymail/django-anymail +django-anymail==7.1.0 # https://github.com/anymail/django-anymail {%- endif %} From 0c32fac51eac0b121a57aede6fb5bc78dea65b38 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Tue, 14 Apr 2020 12:00:42 +0100 Subject: [PATCH 159/182] Update pylint-django from 2.0.14 to 2.0.15 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index 975ed252..0d052969 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -22,7 +22,7 @@ flake8==3.7.9 # https://github.com/PyCQA/flake8 flake8-isort==2.9.1 # https://github.com/gforcada/flake8-isort coverage==5.1 # https://github.com/nedbat/coveragepy black==19.10b0 # https://github.com/ambv/black -pylint-django==2.0.14 # https://github.com/PyCQA/pylint-django +pylint-django==2.0.15 # https://github.com/PyCQA/pylint-django {%- if cookiecutter.use_celery == 'y' %} pylint-celery==0.3 # https://github.com/PyCQA/pylint-celery {%- endif %} From 264466904e6621eac99036e40bbe34eccf5d2d1b Mon Sep 17 00:00:00 2001 From: Andrew Chen Wang <60190294+Andrew-Chen-Wang@users.noreply.github.com> Date: Tue, 14 Apr 2020 11:36:11 -0400 Subject: [PATCH 160/182] Add Apache Software License 2.0 to LICENSE --- {{cookiecutter.project_slug}}/LICENSE | 203 ++++++++++++++++++++++++++ 1 file changed, 203 insertions(+) diff --git a/{{cookiecutter.project_slug}}/LICENSE b/{{cookiecutter.project_slug}}/LICENSE index 3a6c7e13..0bf0b7c7 100644 --- a/{{cookiecutter.project_slug}}/LICENSE +++ b/{{cookiecutter.project_slug}}/LICENSE @@ -50,4 +50,207 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . +{% elif cookiecutter.open_source_license == 'Apache Software License 2.0' %} + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {% now 'utc', '%Y' %} {{ cookiecutter.author_name }} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. {% endif %} From e2b5dba3f7acda9c898241ebb7a19efe192a4a35 Mon Sep 17 00:00:00 2001 From: Andrew Chen Wang <60190294+Andrew-Chen-Wang@users.noreply.github.com> Date: Tue, 14 Apr 2020 11:50:44 -0400 Subject: [PATCH 161/182] Remove Apache LICENSE Appendix --- {{cookiecutter.project_slug}}/LICENSE | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/{{cookiecutter.project_slug}}/LICENSE b/{{cookiecutter.project_slug}}/LICENSE index 0bf0b7c7..c831e030 100644 --- a/{{cookiecutter.project_slug}}/LICENSE +++ b/{{cookiecutter.project_slug}}/LICENSE @@ -229,17 +229,6 @@ along with this program. If not, see . END OF TERMS AND CONDITIONS - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - Copyright {% now 'utc', '%Y' %} {{ cookiecutter.author_name }} Licensed under the Apache License, Version 2.0 (the "License"); From 3c63b3e46ef2c4c99c1cab341eb5e09c5f4e8884 Mon Sep 17 00:00:00 2001 From: Andrew-Chen-Wang Date: Tue, 14 Apr 2020 11:52:14 -0400 Subject: [PATCH 162/182] Add Docker support to Travis and GitLab CI * Celerybeat start files wait for table migration so that errors don't occur if a migration does not happen post-build --- tests/test_cookiecutter_generation.py | 10 +++- {{cookiecutter.project_slug}}/.gitlab-ci.yml | 12 +++++ {{cookiecutter.project_slug}}/.travis.yml | 52 ++++++++++++++----- .../compose/local/django/celery/beat/start | 37 +++++++++++++ .../production/django/celery/beat/start | 35 +++++++++++++ 5 files changed, 132 insertions(+), 14 deletions(-) diff --git a/tests/test_cookiecutter_generation.py b/tests/test_cookiecutter_generation.py index 2c7e6dc4..8785d7ce 100755 --- a/tests/test_cookiecutter_generation.py +++ b/tests/test_cookiecutter_generation.py @@ -181,7 +181,15 @@ def test_travis_invokes_pytest(cookies, context): with open(f"{result.project}/.travis.yml", "r") as travis_yml: try: - assert yaml.load(travis_yml, Loader=yaml.FullLoader)["script"] == ["pytest"] + yml = yaml.load(travis_yml, Loader=yaml.FullLoader)["jobs"]["include"] + assert yml[0]["script"] == ["flake8"] + + if context.get("use_docker") == "y": + assert yml[1]["script"] == [ + "docker-compose -f local.yml run django pytest" + ] + else: + assert yml[1]["script"] == ["pytest"] except yaml.YAMLError as e: pytest.fail(e) diff --git a/{{cookiecutter.project_slug}}/.gitlab-ci.yml b/{{cookiecutter.project_slug}}/.gitlab-ci.yml index 91ad7238..8c032bf7 100644 --- a/{{cookiecutter.project_slug}}/.gitlab-ci.yml +++ b/{{cookiecutter.project_slug}}/.gitlab-ci.yml @@ -19,8 +19,19 @@ flake8: pytest: stage: test image: python:3.7 + {% if cookiecutter.use_docker == 'y' -%} tags: - docker + services: + - docker + before_script: + - docker-compose -f local.yml build + - docker-compose -f local.yml up -d + script: + - docker-compose -f local.yml run django pytest + {%- else %} + tags: + - python services: - postgres:11 variables: @@ -31,4 +42,5 @@ pytest: script: - pytest + {%- endif %} diff --git a/{{cookiecutter.project_slug}}/.travis.yml b/{{cookiecutter.project_slug}}/.travis.yml index 31695e41..7b618e37 100644 --- a/{{cookiecutter.project_slug}}/.travis.yml +++ b/{{cookiecutter.project_slug}}/.travis.yml @@ -1,17 +1,43 @@ dist: xenial -services: - - postgresql -before_install: - - sudo apt-get update -qq - - sudo apt-get install -qq build-essential gettext python-dev zlib1g-dev libpq-dev xvfb - - sudo apt-get install -qq libjpeg8-dev libfreetype6-dev libwebp-dev - - sudo apt-get install -qq graphviz-dev python-setuptools python3-dev python-virtualenv python-pip - - sudo apt-get install -qq firefox automake libtool libreadline6 libreadline6-dev libreadline-dev - - sudo apt-get install -qq libsqlite3-dev libxml2 libxml2-dev libssl-dev libbz2-dev wget curl llvm + language: python python: - "3.7" -install: - - pip install -r requirements/local.txt -script: - - "pytest" + +services: + - {% if cookiecutter.use_docker == 'y' %}docker{% else %}postgresql{% endif %} +jobs: + include: + - name: "Linter" + before_script: + - pip install -q flake8 + script: + - "flake8" + + - name: "Django Test" + {% if cookiecutter.use_docker == 'y' -%} + before_script: + - docker-compose -v + - docker -v + - docker-compose -f local.yml build + - docker-compose -f local.yml up -d + script: + - "docker-compose -f local.yml run django pytest" + after_failure: + - docker-compose -f local.yml logs + {%- else %} + before_install: + - sudo apt-get update -qq + - sudo apt-get install -qq build-essential gettext python-dev zlib1g-dev libpq-dev xvfb + - sudo apt-get install -qq libjpeg8-dev libfreetype6-dev libwebp-dev + - sudo apt-get install -qq graphviz-dev python-setuptools python3-dev python-virtualenv python-pip + - sudo apt-get install -qq firefox automake libtool libreadline6 libreadline6-dev libreadline-dev + - sudo apt-get install -qq libsqlite3-dev libxml2 libxml2-dev libssl-dev libbz2-dev wget curl llvm + language: python + python: + - "3.8" + install: + - pip install -r requirements/local.txt + script: + - "pytest" + {%- endif %} diff --git a/{{cookiecutter.project_slug}}/compose/local/django/celery/beat/start b/{{cookiecutter.project_slug}}/compose/local/django/celery/beat/start index c04a7365..779750ca 100644 --- a/{{cookiecutter.project_slug}}/compose/local/django/celery/beat/start +++ b/{{cookiecutter.project_slug}}/compose/local/django/celery/beat/start @@ -5,4 +5,41 @@ set -o nounset rm -f './celerybeat.pid' + +postgres_ready() { +python << END +import sys +from time import sleep +import psycopg2 +try: + conn = psycopg2.connect( + dbname="${POSTGRES_DB}", + user="${POSTGRES_USER}", + password="${POSTGRES_PASSWORD}", + host="${POSTGRES_HOST}", + port="${POSTGRES_PORT}", + ) + # Check if table exists yet. + # If not, wait for docker-compose up to migrate all tables. + cur = conn.cursor() + cur.execute( + "select exists(select * from ${POSTGRES_DB}.tables where table_name=%s)", + ('django_celery_beat_periodictask',) + ) + conn.close() +except psycopg2.OperationalError: + sys.exit(-1) +except psycopg2.errors.UndefinedTable: + conn.close() + sys.exit(-1) + +sys.exit(0) +END +} +until postgres_ready; do + >&2 echo 'Waiting for celerybeat models to be migrated...' + sleep 1 +done +>&2 echo 'PostgreSQL is ready' + celery -A config.celery_app beat -l INFO diff --git a/{{cookiecutter.project_slug}}/compose/production/django/celery/beat/start b/{{cookiecutter.project_slug}}/compose/production/django/celery/beat/start index 20b93123..0bc76667 100644 --- a/{{cookiecutter.project_slug}}/compose/production/django/celery/beat/start +++ b/{{cookiecutter.project_slug}}/compose/production/django/celery/beat/start @@ -4,5 +4,40 @@ set -o errexit set -o pipefail set -o nounset +postgres_ready() { +python << END +import sys +from time import sleep +import psycopg2 +try: + conn = psycopg2.connect( + dbname="${POSTGRES_DB}", + user="${POSTGRES_USER}", + password="${POSTGRES_PASSWORD}", + host="${POSTGRES_HOST}", + port="${POSTGRES_PORT}", + ) + # Check if table exists yet. + # If not, wait for docker-compose up to migrate all tables. + cur = conn.cursor() + cur.execute( + "select exists(select * from ${POSTGRES_DB}.tables where table_name=%s)", + ('django_celery_beat_periodictask',) + ) + conn.close() +except psycopg2.OperationalError: + sys.exit(-1) +except psycopg2.errors.UndefinedTable: + conn.close() + sys.exit(-1) + +sys.exit(0) +END +} +until postgres_ready; do + >&2 echo 'Waiting for celerybeat models to be migrated...' + sleep 1 +done +>&2 echo 'PostgreSQL is ready' celery -A config.celery_app beat -l INFO From dd0e7c0c801a55f13c6235dc5937ef81664752e8 Mon Sep 17 00:00:00 2001 From: Andrew-Chen-Wang Date: Tue, 14 Apr 2020 12:04:41 -0400 Subject: [PATCH 163/182] Remove unnecssary import in celerybeat start files --- .../compose/local/django/celery/beat/start | 1 - .../compose/production/django/celery/beat/start | 1 - 2 files changed, 2 deletions(-) diff --git a/{{cookiecutter.project_slug}}/compose/local/django/celery/beat/start b/{{cookiecutter.project_slug}}/compose/local/django/celery/beat/start index 779750ca..2499f866 100644 --- a/{{cookiecutter.project_slug}}/compose/local/django/celery/beat/start +++ b/{{cookiecutter.project_slug}}/compose/local/django/celery/beat/start @@ -9,7 +9,6 @@ rm -f './celerybeat.pid' postgres_ready() { python << END import sys -from time import sleep import psycopg2 try: conn = psycopg2.connect( diff --git a/{{cookiecutter.project_slug}}/compose/production/django/celery/beat/start b/{{cookiecutter.project_slug}}/compose/production/django/celery/beat/start index 0bc76667..3882e194 100644 --- a/{{cookiecutter.project_slug}}/compose/production/django/celery/beat/start +++ b/{{cookiecutter.project_slug}}/compose/production/django/celery/beat/start @@ -7,7 +7,6 @@ set -o nounset postgres_ready() { python << END import sys -from time import sleep import psycopg2 try: conn = psycopg2.connect( From 25cd8ea72b8dd3e017ddac738373ab64ce934524 Mon Sep 17 00:00:00 2001 From: Andrew-Chen-Wang Date: Tue, 14 Apr 2020 15:05:53 -0400 Subject: [PATCH 164/182] Update beat start files with better? SQL statement --- .../compose/local/django/celery/beat/start | 13 +++++++------ .../compose/production/django/celery/beat/start | 12 +++++++----- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/{{cookiecutter.project_slug}}/compose/local/django/celery/beat/start b/{{cookiecutter.project_slug}}/compose/local/django/celery/beat/start index 2499f866..477dfca3 100644 --- a/{{cookiecutter.project_slug}}/compose/local/django/celery/beat/start +++ b/{{cookiecutter.project_slug}}/compose/local/django/celery/beat/start @@ -22,17 +22,18 @@ try: # If not, wait for docker-compose up to migrate all tables. cur = conn.cursor() cur.execute( - "select exists(select * from ${POSTGRES_DB}.tables where table_name=%s)", + "select exists(select * from information_schema.tables where table_name=%s)", ('django_celery_beat_periodictask',) ) - conn.close() + if cur.fetchone()[0] == 1: + cur.close() + sys.exit(0) + else: + cur.close() + sys.exit(-1) except psycopg2.OperationalError: sys.exit(-1) -except psycopg2.errors.UndefinedTable: - conn.close() - sys.exit(-1) -sys.exit(0) END } until postgres_ready; do diff --git a/{{cookiecutter.project_slug}}/compose/production/django/celery/beat/start b/{{cookiecutter.project_slug}}/compose/production/django/celery/beat/start index 3882e194..0cc8ae8a 100644 --- a/{{cookiecutter.project_slug}}/compose/production/django/celery/beat/start +++ b/{{cookiecutter.project_slug}}/compose/production/django/celery/beat/start @@ -20,15 +20,17 @@ try: # If not, wait for docker-compose up to migrate all tables. cur = conn.cursor() cur.execute( - "select exists(select * from ${POSTGRES_DB}.tables where table_name=%s)", + "select exists(select * from information_schema.tables where table_name=%s)", ('django_celery_beat_periodictask',) ) - conn.close() + if cur.fetchone()[0] == 1: + cur.close() + sys.exit(0) + else: + cur.close() + sys.exit(-1) except psycopg2.OperationalError: sys.exit(-1) -except psycopg2.errors.UndefinedTable: - conn.close() - sys.exit(-1) sys.exit(0) END From 7e3f61a2f8a6dbe57f98f684b6dcebf010007980 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Wed, 15 Apr 2020 10:37:57 +0100 Subject: [PATCH 165/182] Update .pyup.yml --- .pyup.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.pyup.yml b/.pyup.yml index 4978524e..c503dabf 100644 --- a/.pyup.yml +++ b/.pyup.yml @@ -8,6 +8,11 @@ update: all # allowed: True, False pin: True +# add a label to pull requests, default is not set +# requires private repo permissions, even on public repos +# default: empty +label_prs: update + # Specify requirement files by hand, pyup seems to struggle to # find the ones in the project_slug folder requirements: From f2f881179c3e35fddb5c937e8aebff92240a3f05 Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Wed, 15 Apr 2020 09:43:34 -0700 Subject: [PATCH 166/182] Update flake8-isort from 2.9.1 to 3.0.0 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index f4d5a931..3beb162b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,7 +6,7 @@ binaryornot==0.4.4 # ------------------------------------------------------------------------------ black==19.10b0 flake8==3.7.9 -flake8-isort==2.9.1 +flake8-isort==3.0.0 # Testing # ------------------------------------------------------------------------------ From c639541d506c20405e43a903058b75f5fee63192 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Thu, 16 Apr 2020 09:11:15 +0100 Subject: [PATCH 167/182] Default DJANGO_SETTINGS_MODULE to local settings in asgi.py This is to be consistent with `manage.py` behaviour and required to run locally. --- {{cookiecutter.project_slug}}/config/asgi.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/{{cookiecutter.project_slug}}/config/asgi.py b/{{cookiecutter.project_slug}}/config/asgi.py index 485c8eca..562ecf40 100644 --- a/{{cookiecutter.project_slug}}/config/asgi.py +++ b/{{cookiecutter.project_slug}}/config/asgi.py @@ -7,6 +7,7 @@ For more information on this file, see https://docs.djangoproject.com/en/dev/howto/deployment/asgi/ """ +import os import sys from pathlib import Path @@ -17,6 +18,9 @@ from django.core.asgi import get_asgi_application app_path = Path(__file__).parents[1].resolve() sys.path.append(str(app_path / "{{ cookiecutter.project_slug }}")) +# If DJANGO_SETTINGS_MODULE is unset, default to the local settings +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.local") + # This application object is used by any ASGI server configured to use this file. django_application = get_asgi_application() # Apply ASGI middleware here. From 835cd8c9b5c5811fdcd7e04b6f09739c82b9eddc Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Thu, 16 Apr 2020 09:18:58 +0100 Subject: [PATCH 168/182] Remove unused parameter in Gulp task --- {{cookiecutter.project_slug}}/gulpfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/gulpfile.js b/{{cookiecutter.project_slug}}/gulpfile.js index 89894d38..1f9884ec 100644 --- a/{{cookiecutter.project_slug}}/gulpfile.js +++ b/{{cookiecutter.project_slug}}/gulpfile.js @@ -112,7 +112,7 @@ function imgCompression() { {% if cookiecutter.use_async == 'y' -%} // Run django server -function asyncRunServer(cb) { +function asyncRunServer() { var cmd = spawn('gunicorn', [ 'config.asgi', '-k', 'uvicorn.workers.UvicornWorker', '--reload' ], {stdio: 'inherit'} From 3d6dce66aad8ded5a4ba490336f4fee7f5374eb1 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Thu, 16 Apr 2020 09:35:50 +0100 Subject: [PATCH 169/182] Mention ASGI in the README --- README.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/README.rst b/README.rst index 1855f59f..604cff91 100644 --- a/README.rst +++ b/README.rst @@ -45,6 +45,7 @@ Features * Optimized development and production settings * Registration via django-allauth_ * Comes with custom user model ready to go +* Optional basic ASGI setup for Websockets * Optional custom static build using Gulp and livereload * Send emails via Anymail_ (using Mailgun_ by default or Amazon SES if AWS is selected cloud provider, but switchable) * Media storage using Amazon S3 or Google Cloud Storage From 3d9f7b91d0b813fab5b8c5bbed5fb87b3ab9afde Mon Sep 17 00:00:00 2001 From: browniebroke Date: Thu, 16 Apr 2020 12:00:30 +0100 Subject: [PATCH 170/182] Update flake8-isort from 2.9.1 to 3.0.0 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index 0d052969..4b113507 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -19,7 +19,7 @@ pytest-sugar==0.9.2 # https://github.com/Frozenball/pytest-sugar # Code quality # ------------------------------------------------------------------------------ flake8==3.7.9 # https://github.com/PyCQA/flake8 -flake8-isort==2.9.1 # https://github.com/gforcada/flake8-isort +flake8-isort==3.0.0 # https://github.com/gforcada/flake8-isort coverage==5.1 # https://github.com/nedbat/coveragepy black==19.10b0 # https://github.com/ambv/black pylint-django==2.0.15 # https://github.com/PyCQA/pylint-django From d2285d9e2d1798e863d355e0efee76fe7e73fdd1 Mon Sep 17 00:00:00 2001 From: Andrew-Chen-Wang Date: Thu, 16 Apr 2020 13:34:12 -0400 Subject: [PATCH 171/182] pytest.parametrized test for generating CI * Removed celerybeat start's postgres_ready() for new PR for closer inspection and further review. Travis and GitLab CI reflect changes --- tests/test_cookiecutter_generation.py | 30 ++++++++------- {{cookiecutter.project_slug}}/.gitlab-ci.yml | 2 + {{cookiecutter.project_slug}}/.travis.yml | 2 + .../compose/local/django/celery/beat/start | 37 ------------------- .../production/django/celery/beat/start | 36 ------------------ 5 files changed, 21 insertions(+), 86 deletions(-) diff --git a/tests/test_cookiecutter_generation.py b/tests/test_cookiecutter_generation.py index 8785d7ce..ecd08ea0 100755 --- a/tests/test_cookiecutter_generation.py +++ b/tests/test_cookiecutter_generation.py @@ -170,8 +170,12 @@ def test_black_passes(cookies, context_override): pytest.fail(e.stdout.decode()) -def test_travis_invokes_pytest(cookies, context): - context.update({"ci_tool": "Travis"}) +@pytest.mark.parametrize( + ["use_docker", "expected_test_script"], + [("n", "pytest"), ("y", "docker-compose -f local.yml run django pytest"),], +) +def test_travis_invokes_pytest(cookies, context, use_docker, expected_test_script): + context.update({"ci_tool": "Travis", "use_docker": use_docker}) result = cookies.bake(extra_context=context) assert result.exit_code == 0 @@ -183,19 +187,19 @@ def test_travis_invokes_pytest(cookies, context): try: yml = yaml.load(travis_yml, Loader=yaml.FullLoader)["jobs"]["include"] assert yml[0]["script"] == ["flake8"] - - if context.get("use_docker") == "y": - assert yml[1]["script"] == [ - "docker-compose -f local.yml run django pytest" - ] - else: - assert yml[1]["script"] == ["pytest"] + assert yml[1]["script"] == [expected_test_script] except yaml.YAMLError as e: - pytest.fail(e) + pytest.fail(str(e)) -def test_gitlab_invokes_flake8_and_pytest(cookies, context): - context.update({"ci_tool": "Gitlab"}) +@pytest.mark.parametrize( + ["use_docker", "expected_test_script"], + [("n", "pytest"), ("y", "docker-compose -f local.yml run django pytest"),], +) +def test_gitlab_invokes_flake8_and_pytest( + cookies, context, use_docker, expected_test_script +): + context.update({"ci_tool": "Gitlab", "use_docker": use_docker}) result = cookies.bake(extra_context=context) assert result.exit_code == 0 @@ -207,7 +211,7 @@ def test_gitlab_invokes_flake8_and_pytest(cookies, context): try: gitlab_config = yaml.load(gitlab_yml, Loader=yaml.FullLoader) assert gitlab_config["flake8"]["script"] == ["flake8"] - assert gitlab_config["pytest"]["script"] == ["pytest"] + assert gitlab_config["pytest"]["script"] == [expected_test_script] except yaml.YAMLError as e: pytest.fail(e) diff --git a/{{cookiecutter.project_slug}}/.gitlab-ci.yml b/{{cookiecutter.project_slug}}/.gitlab-ci.yml index 4d67f8a1..a74d5de8 100644 --- a/{{cookiecutter.project_slug}}/.gitlab-ci.yml +++ b/{{cookiecutter.project_slug}}/.gitlab-ci.yml @@ -29,6 +29,8 @@ pytest: - docker before_script: - docker-compose -f local.yml build + # Ensure celerybeat does not crash due to non-existent tables + - docker-compose -f local.yml run --rm django python manage.py migrate - docker-compose -f local.yml up -d script: - docker-compose -f local.yml run django pytest diff --git a/{{cookiecutter.project_slug}}/.travis.yml b/{{cookiecutter.project_slug}}/.travis.yml index 7f90b5f5..fac60650 100644 --- a/{{cookiecutter.project_slug}}/.travis.yml +++ b/{{cookiecutter.project_slug}}/.travis.yml @@ -20,6 +20,8 @@ jobs: - docker-compose -v - docker -v - docker-compose -f local.yml build + # Ensure celerybeat does not crash due to non-existent tables + - docker-compose -f local.yml run --rm django python manage.py migrate - docker-compose -f local.yml up -d script: - "docker-compose -f local.yml run django pytest" diff --git a/{{cookiecutter.project_slug}}/compose/local/django/celery/beat/start b/{{cookiecutter.project_slug}}/compose/local/django/celery/beat/start index 477dfca3..c04a7365 100644 --- a/{{cookiecutter.project_slug}}/compose/local/django/celery/beat/start +++ b/{{cookiecutter.project_slug}}/compose/local/django/celery/beat/start @@ -5,41 +5,4 @@ set -o nounset rm -f './celerybeat.pid' - -postgres_ready() { -python << END -import sys -import psycopg2 -try: - conn = psycopg2.connect( - dbname="${POSTGRES_DB}", - user="${POSTGRES_USER}", - password="${POSTGRES_PASSWORD}", - host="${POSTGRES_HOST}", - port="${POSTGRES_PORT}", - ) - # Check if table exists yet. - # If not, wait for docker-compose up to migrate all tables. - cur = conn.cursor() - cur.execute( - "select exists(select * from information_schema.tables where table_name=%s)", - ('django_celery_beat_periodictask',) - ) - if cur.fetchone()[0] == 1: - cur.close() - sys.exit(0) - else: - cur.close() - sys.exit(-1) -except psycopg2.OperationalError: - sys.exit(-1) - -END -} -until postgres_ready; do - >&2 echo 'Waiting for celerybeat models to be migrated...' - sleep 1 -done ->&2 echo 'PostgreSQL is ready' - celery -A config.celery_app beat -l INFO diff --git a/{{cookiecutter.project_slug}}/compose/production/django/celery/beat/start b/{{cookiecutter.project_slug}}/compose/production/django/celery/beat/start index 0cc8ae8a..20b93123 100644 --- a/{{cookiecutter.project_slug}}/compose/production/django/celery/beat/start +++ b/{{cookiecutter.project_slug}}/compose/production/django/celery/beat/start @@ -4,41 +4,5 @@ set -o errexit set -o pipefail set -o nounset -postgres_ready() { -python << END -import sys -import psycopg2 -try: - conn = psycopg2.connect( - dbname="${POSTGRES_DB}", - user="${POSTGRES_USER}", - password="${POSTGRES_PASSWORD}", - host="${POSTGRES_HOST}", - port="${POSTGRES_PORT}", - ) - # Check if table exists yet. - # If not, wait for docker-compose up to migrate all tables. - cur = conn.cursor() - cur.execute( - "select exists(select * from information_schema.tables where table_name=%s)", - ('django_celery_beat_periodictask',) - ) - if cur.fetchone()[0] == 1: - cur.close() - sys.exit(0) - else: - cur.close() - sys.exit(-1) -except psycopg2.OperationalError: - sys.exit(-1) - -sys.exit(0) -END -} -until postgres_ready; do - >&2 echo 'Waiting for celerybeat models to be migrated...' - sleep 1 -done ->&2 echo 'PostgreSQL is ready' celery -A config.celery_app beat -l INFO From d249158444d1cb0f32cbc9cdd6dc868dcc2210d7 Mon Sep 17 00:00:00 2001 From: Andrew-Chen-Wang Date: Thu, 16 Apr 2020 14:15:35 -0400 Subject: [PATCH 172/182] Fix .travis.yml indent alignment --- {{cookiecutter.project_slug}}/.travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/.travis.yml b/{{cookiecutter.project_slug}}/.travis.yml index fac60650..24f9f24a 100644 --- a/{{cookiecutter.project_slug}}/.travis.yml +++ b/{{cookiecutter.project_slug}}/.travis.yml @@ -15,7 +15,7 @@ jobs: - "flake8" - name: "Django Test" - {% if cookiecutter.use_docker == 'y' -%} + {%- if cookiecutter.use_docker == 'y' %} before_script: - docker-compose -v - docker -v From d02b88f681b5d467219b56e14b1e2ecc78e49177 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Fri, 17 Apr 2020 19:08:38 +0100 Subject: [PATCH 173/182] Bump to version 3.0.5-01 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 98e98fb7..6dfd9e50 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ except ImportError: # Our version ALWAYS matches the version of Django we support # If Django has a new release, we branch, tag, then update this setting after the tag. -version = "3.0.5" +version = "3.0.5-01" if sys.argv[-1] == "tag": os.system(f'git tag -a {version} -m "version {version}"') From 7a435b3d4a14296f239bd9c4df4ffbedbcc7edc3 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Fri, 17 Apr 2020 19:18:56 +0100 Subject: [PATCH 174/182] Add GitHub action to label pull requests --- .github/labeler.yml | 11 +++++++++++ .github/workflows/label.yml | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 .github/labeler.yml create mode 100644 .github/workflows/label.yml diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 00000000..bad7cac0 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,11 @@ +# Add 'docs' to any changes within 'docs' folder or any subfolders +docs: + - README.rst + - docs/**/* + - {{cookiecutter.project_slug}}/docs/**/* + +# Flag PR related to docker +docker: + - {{cookiecutter.project_slug}}/compose/**/* + - {{cookiecutter.project_slug}}/local.yml + - {{cookiecutter.project_slug}}/production.yml diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml new file mode 100644 index 00000000..3df0ec0c --- /dev/null +++ b/.github/workflows/label.yml @@ -0,0 +1,20 @@ +# This workflow will triage pull requests and apply a label based on the +# paths that are modified in the pull request. +# +# To use this workflow, you will need to set up a .github/labeler.yml +# file with configuration. For more information, see: +# https://github.com/actions/labeler/blob/master/README.md + + +name: Labeler +on: [pull_request] + +jobs: + label: + + runs-on: ubuntu-latest + + steps: + - uses: actions/labeler@v2 + with: + repo-token: "${{ secrets.GITHUB_TOKEN }}" From 4ab97dd5a4da02305a795841a4c4d3f90ae44a2f Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Sat, 18 Apr 2020 12:33:13 +0100 Subject: [PATCH 175/182] Add GitHub action to draft releases notes --- .github/release-drafter.yml | 30 +++++++++++++++++++++++++++++ .github/workflows/draft-release.yml | 14 ++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 .github/release-drafter.yml create mode 100644 .github/workflows/draft-release.yml diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 00000000..7d3a1b4f --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,30 @@ +categories: + - title: 'Breaking Changes' + labels: + - 'breaking' + - title: 'Major Changes' + labels: + - 'major' + - title: 'Minor Changes' + labels: + - 'enhancement' + - title: 'Bugfixes' + labels: + - 'bug' + - title: 'Removals' + labels: + - 'removed' + - title: 'Documentation updates' + labels: + - 'docs' + - title: 'Dependencies updates' + labels: + - 'update' + +exclude-labels: + - 'skip-changelog' + +template: | + ## Changes + + $CHANGES diff --git a/.github/workflows/draft-release.yml b/.github/workflows/draft-release.yml new file mode 100644 index 00000000..6c2d6620 --- /dev/null +++ b/.github/workflows/draft-release.yml @@ -0,0 +1,14 @@ +name: Release Drafter + +on: + push: + branches: + - master + +jobs: + release_notes: + runs-on: ubuntu-latest + steps: + - uses: release-drafter/release-drafter@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From d0481624e77e5ff498415a3e1e73cef51e1596cb Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Sat, 18 Apr 2020 14:46:37 +0100 Subject: [PATCH 176/182] Remove updates from release drafter --- .github/release-drafter.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index 7d3a1b4f..af10ea70 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -17,9 +17,6 @@ categories: - title: 'Documentation updates' labels: - 'docs' - - title: 'Dependencies updates' - labels: - - 'update' exclude-labels: - 'skip-changelog' From 935c83fa309b5d08fa0b3a2f381be72fac4efd88 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Sat, 18 Apr 2020 14:49:20 +0100 Subject: [PATCH 177/182] Don't mention updates in release drafter at all --- .github/release-drafter.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index af10ea70..34030861 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -20,6 +20,7 @@ categories: exclude-labels: - 'skip-changelog' + - 'update' template: | ## Changes From d3439b859298776749d152c6e5a76c4447866a07 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Sat, 18 Apr 2020 14:53:57 +0100 Subject: [PATCH 178/182] Exclude changes for project infrastructure --- .github/release-drafter.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index 34030861..734a541a 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -21,6 +21,7 @@ categories: exclude-labels: - 'skip-changelog' - 'update' + - 'project infrastructure' template: | ## Changes From 8eeef9a86c1612d2a934053beb1c10d9ef902119 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Mon, 20 Apr 2020 12:00:32 +0100 Subject: [PATCH 179/182] Update sphinx from 3.0.1 to 3.0.2 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index 4b113507..03f8467a 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -2,7 +2,7 @@ Werkzeug==1.0.1 # https://github.com/pallets/werkzeug ipdb==0.13.2 # https://github.com/gotcha/ipdb -Sphinx==3.0.1 # https://github.com/sphinx-doc/sphinx +Sphinx==3.0.2 # https://github.com/sphinx-doc/sphinx {%- if cookiecutter.use_docker == 'y' %} psycopg2==2.8.5 --no-binary psycopg2 # https://github.com/psycopg/psycopg2 {%- else %} From bda0541a2b536e305ec1ec2de10a4b1fde9711a2 Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Mon, 20 Apr 2020 21:32:43 -0700 Subject: [PATCH 180/182] Update cookiecutter from 1.7.0 to 1.7.2 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 3beb162b..c5601892 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -cookiecutter==1.7.0 +cookiecutter==1.7.2 sh==1.12.14 binaryornot==0.4.4 From 109784b79d063d2fb529a93c849ab85bc5e478f1 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Tue, 21 Apr 2020 17:21:43 +0100 Subject: [PATCH 181/182] Fix labeler config --- .github/labeler.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/labeler.yml b/.github/labeler.yml index bad7cac0..a29e237d 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -1,11 +1,11 @@ # Add 'docs' to any changes within 'docs' folder or any subfolders docs: - - README.rst - - docs/**/* - - {{cookiecutter.project_slug}}/docs/**/* + - 'README.rst' + - 'docs/**/*' + - '{{cookiecutter.project_slug}}/docs/**/*' # Flag PR related to docker docker: - - {{cookiecutter.project_slug}}/compose/**/* - - {{cookiecutter.project_slug}}/local.yml - - {{cookiecutter.project_slug}}/production.yml + - '{{cookiecutter.project_slug}}/compose/**/*' + - '{{cookiecutter.project_slug}}/local.yml' + - '{{cookiecutter.project_slug}}/production.yml' From 433aa667f552c2c2b2375606da2f022d5a1c5b4c Mon Sep 17 00:00:00 2001 From: browniebroke Date: Thu, 23 Apr 2020 12:00:33 +0100 Subject: [PATCH 182/182] Update pre-commit from 2.2.0 to 2.3.0 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index 03f8467a..f6be44b5 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -26,7 +26,7 @@ pylint-django==2.0.15 # https://github.com/PyCQA/pylint-django {%- if cookiecutter.use_celery == 'y' %} pylint-celery==0.3 # https://github.com/PyCQA/pylint-celery {%- endif %} -pre-commit==2.2.0 # https://github.com/pre-commit/pre-commit +pre-commit==2.3.0 # https://github.com/pre-commit/pre-commit # Django # ------------------------------------------------------------------------------