diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 37a905b9d..b232b6e34 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,32 +1 @@ -**Note: for support questions, please use the `cookiecutter-django` tag on stackoverflow**. This repository's issues are reserved for feature requests and bug reports. - -* **I'm submitting a ... ** - - [ ] bug report - - [ ] feature request - - [ ] support request => Please do not submit support request here, see note at the top of this template. - - -* **Do you want to request a *feature* or report a *bug*?** - - - -* **What is the current behavior?** - - - -* **If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem** - - -* **What is the expected behavior?** - - - -* **What is the motivation / use case for changing the behavior?** - - - -* **Please tell us about your environment:** - - - -* **Other information** (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc) +## [Make sure to follow one of the issue templates we've got](https://github.com/pydanny/cookiecutter-django/issues/new/choose), otherwise the issue might be closed immeditely diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md new file mode 100644 index 000000000..75f6a19c6 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -0,0 +1,23 @@ +--- +name: Bug Report +about: Report a bug +--- + +## What happened? + + + + +## What should've happened instead? + + + + +## Steps to reproduce + +[//]: # (Any or all of the following:) +[//]: # (* Host system configuration: OS, Docker & friends' versions etc.) +[//]: # (* Project generation options) +[//]: # (* Logs) + + diff --git a/.github/ISSUE_TEMPLATE/feature.md b/.github/ISSUE_TEMPLATE/feature.md new file mode 100644 index 000000000..b0d560d81 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature.md @@ -0,0 +1,24 @@ +--- +name: New Feature Proposal +about: Propose a new feature +--- + +## Description + +[//]: # (What's it you're proposing? How should it be implemented?) + + + + +## Rationale + +[//]: # (Why should this feature be implemented?) + + + + +## Use case(s) / visualization(s) + +[//]: # ("Better to see something once than to hear about it a thousand times.") + + diff --git a/.github/ISSUE_TEMPLATE/improvement.md b/.github/ISSUE_TEMPLATE/improvement.md new file mode 100644 index 000000000..572652373 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/improvement.md @@ -0,0 +1,24 @@ +--- +name: Improvement Suggestion +about: Let us know how we could improve +--- + +## Description + +[//]: # (What's it you're proposing? How should it be implemented?) + + + + +## Rationale + +[//]: # (Why should this feature be implemented?) + + + + +## Use case(s) / visualization(s) + +[//]: # ("Better to see something once than to hear about it a thousand times.") + + diff --git a/.github/ISSUE_TEMPLATE/paid-support.md b/.github/ISSUE_TEMPLATE/paid-support.md new file mode 100644 index 000000000..d565e564f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/paid-support.md @@ -0,0 +1,10 @@ +--- +name: Paid Support Request +about: Ask Core Team members to help you out +--- + +Provided your question goes beyound [regular support](https://github.com/pydanny/cookiecutter-django/issues/new?template=question.md), and/or the task at hand is of timely/high priority nature use the below information to reach out for contributors directly. + +* Daniel Roy Greenfeld, Project Lead ([GitHub](https://github.com/pydanny), [Patreon](https://www.patreon.com/danielroygreenfeld)): expertise in Django and AWS ELB. + +* Nikita Shupeyko, Core Developer ([GitHub](https://github.com/webyneter)): expertise in Python/Django, hands-on DevOps and frontend experience. diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md new file mode 100644 index 000000000..0c0f3d891 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question.md @@ -0,0 +1,6 @@ +--- +name: Question +about: Please, ask your question on StackOverflow or Gitter +--- + +First, make sure to examine [the docs](https://cookiecutter-django.readthedocs.io/en/latest/). If that doesn't help post a question on [StackOverflow](https://stackoverflow.com/questions/tagged/cookiecutter-django) tagged with `cookiecutter-django`. Finally, feel free to join [Gitter](https://gitter.im/pydanny/cookiecutter-django) and ask around. diff --git a/.github/ISSUE_TEMPLATE/regression.md b/.github/ISSUE_TEMPLATE/regression.md new file mode 100644 index 000000000..80384004b --- /dev/null +++ b/.github/ISSUE_TEMPLATE/regression.md @@ -0,0 +1,28 @@ +--- +name: Regression Report +about: Let us know if something that'd been working has broke +--- + +## What happened before? + + + + +## What happens now? + + + + +## Last stable commit / Since when? + + + + +## Steps to reproduce + +[//]: # (Any or all of the following:) +[//]: # (* Host system configuration: OS, Docker & friends' versions etc.) +[//]: # (* Project generation options) +[//]: # (* Logs) + + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 000000000..8dbff6c25 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,27 @@ +[//]: # (Thank you for helping us out: your efforts mean great deal to the project and the community as a whole!) + +[//]: # (Before you proceed:) + +[//]: # (1. Make sure to add yourself to `CONTRIBUTORS.rst` through this PR provided you're contributing here for the first time) +[//]: # (2. Don't forget to update the `docs/` presuming others would benefit from a concise description of whatever that you're proposing) + + +## Description + +[//]: # (What's it you're proposing?) + + + + +## Rationale + +[//]: # (Why does the project need that?) + + + + +## Use case(s) / visualization(s) + +[//]: # ("Better to see something once than to hear about it a thousand times.") + + diff --git a/.gitignore b/.gitignore index 9e4496f1c..54fafb8be 100644 --- a/.gitignore +++ b/.gitignore @@ -215,7 +215,6 @@ tags [Ii]nclude [Ll]ib [Ll]ib64 -[Ll]ocal [Ss]cripts pyvenv.cfg pip-selfcheck.json diff --git a/.travis.yml b/.travis.yml index 8be8bc440..a46726d6c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,3 @@ -# Config file for automatic testing at travis-ci.org - sudo: required services: @@ -10,18 +8,18 @@ language: python python: 3.6 env: - - TOX_ENV=py36 + - TOX_ENV=py36 before_install: - docker-compose -v - docker -v script: - - tox -e $TOX_ENV - - sh tests/test_docker.sh + - tox -e $TOX_ENV + - sh tests/test_docker.sh install: - - pip install tox + - pip install tox notifications: email: diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index a5ea2d937..6b3f00660 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -87,6 +87,7 @@ Listed in alphabetical order. David Díaz `@ddiazpinto`_ @DavidDiazPinto Davur Clementsen `@dsclementsen`_ @davur Delio Castillo `@jangeador`_ @jangeador + Denis Orehovsky `@apirobot`_ Dónal Adams `@epileptic-fish`_ Dong Huynh `@trungdong`_ Emanuel Calso `@bloodpet`_ @bloodpet @@ -120,6 +121,7 @@ Listed in alphabetical order. Lyla Fischer Malik Sulaimanov `@flyudvik`_ @flyudvik Martin Blech + Martin Saizar `@msaizar`_ Mathijs Hoogland `@MathijsHoogland`_ Matt Braymer-Hayes `@mattayes`_ @mattayes Matt Linares @@ -160,6 +162,7 @@ Listed in alphabetical order. Will Farley `@goldhand`_ @g01dhand William Archinal `@archinal`_ Yaroslav Halchenko + Denis Bobrov `@delneg`_ ========================== ============================ ============== .. _@a7p: https://github.com/a7p @@ -171,6 +174,7 @@ Listed in alphabetical order. .. _@amjith: https://github.com/amjith .. _@andor-pierdelacabeza: https://github.com/andor-pierdelacabeza .. _@antoniablair: https://github.com/antoniablair +.. _@apirobot: https://github.com/apirobot .. _@archinal: https://github.com/archinal .. _@areski: https://github.com/areski .. _@arruda: https://github.com/arruda @@ -218,6 +222,7 @@ Listed in alphabetical order. .. _@kevgathuku: https://github.com/kevgathuku .. _@knitatoms: https://github.com/knitatoms .. _@krzysztofzuraw: https://github.com/krzysztofzuraw +.. _@msaizar: https://github.com/msaizar .. _@MathijsHoogland: https://github.com/MathijsHoogland .. _@mattayes: https://github.com/mattayes .. _@menzenski: https://github.com/menzenski @@ -261,7 +266,7 @@ Listed in alphabetical order. .. _@brentpayne: https://github.com/brentpayne .. _@afrowave: https://github.com/afrowave .. _@pchiquet: https://github.com/pchiquet - +.. _@delneg: https://github.com/delneg Special Thanks ~~~~~~~~~~~~~~ diff --git a/README.rst b/README.rst index 25f421947..a69712d07 100644 --- a/README.rst +++ b/README.rst @@ -65,7 +65,7 @@ Optional Integrations *These features can be enabled during initial project setup.* * Serve static files from Amazon S3 or Whitenoise_ -* Configuration for Celery_ +* Configuration for Celery_ and Flower_ (the latter in Docker setup only) * Integration with MailHog_ for local email testing * Integration with Sentry_ for error logging @@ -78,6 +78,7 @@ Optional Integrations .. _Mailgun: http://www.mailgun.com/ .. _Whitenoise: https://whitenoise.readthedocs.io/ .. _Celery: http://www.celeryproject.org/ +.. _Flower: https://github.com/mher/flower .. _Anymail: https://github.com/anymail/django-anymail .. _MailHog: https://github.com/mailhog/MailHog .. _Sentry: https://sentry.io/welcome/ @@ -98,7 +99,9 @@ Support this Project! This project is run by volunteers. Please support them in their efforts to maintain and improve Cookiecutter Django: -* https://www.patreon.com/danielroygreenfeld: Project lead. Expertise in AWS ELB and Django. +* Daniel Roy Greenfeld, Project Lead (`GitHub `_, `Patreon `_): expertise in Django and AWS ELB. + +* Nikita Shupeyko, Core Developer (`GitHub `_): expertise in Python/Django, hands-on DevOps and frontend experience. Projects that provide financial support to the maintainers: @@ -158,13 +161,13 @@ Answer the prompts with your own desired options_. For example:: domain_name [example.com]: myreddit.com version [0.1.0]: 0.0.1 timezone [UTC]: America/Los_Angeles - use_whitenoise [y]: n + use_whitenoise [n]: n use_celery [n]: y use_mailhog [n]: n - use_sentry [y]: y + use_sentry [n]: y use_pycharm [n]: y windows [n]: n - use_docker [y]: n + use_docker [n]: n use_heroku [n]: y use_compressor [n]: y Select postgresql_version: @@ -279,6 +282,8 @@ experience better. Articles --------- +* `cookiecutter-django with Nginx, Route 53 and ELB`_ - Feb. 12, 2018 +* `cookiecutter-django and Amazon RDS`_ - Feb. 7, 2018 * `Deploying Cookiecutter-Django with Docker-Compose`_ - Oct. 19, 2017 * `Using Cookiecutter to Jumpstart a Django Project on Windows with PyCharm`_ - May 19, 2017 * `Exploring with Cookiecutter`_ - Dec. 3, 2016 @@ -290,6 +295,8 @@ Articles Have a blog or online publication? Write about your cookiecutter-django tips and tricks, then send us a pull request with the link. +.. _`cookiecutter-django with Nginx, Route 53 and ELB`: https://msaizar.com/blog/cookiecutter-django-nginx-route-53-and-elb/ +.. _`cookiecutter-django and Amazon RDS`: https://msaizar.com/blog/cookiecutter-django-and-amazon-rds/ .. _`Deploying Cookiecutter-Django with Docker-Compose`: http://adamantine.me/2017/10/19/deploying-cookiecutter-django-with-docker-compose/ .. _`Exploring with Cookiecutter`: http://www.snowboardingcoder.com/django/2016/12/03/exploring-with-cookiecutter/ .. _`Using Cookiecutter to Jumpstart a Django Project on Windows with PyCharm`: https://joshuahunter.com/posts/using-cookiecutter-to-jumpstart-a-django-project-on-windows-with-pycharm/ diff --git a/cookiecutter.json b/cookiecutter.json index cb41bbfce..21a639a3a 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -18,6 +18,7 @@ "use_pycharm": "n", "use_docker": "n", "postgresql_version": [ + "10.4", "10.3", "10.2", "10.1", @@ -34,8 +35,8 @@ "use_compressor": "n", "use_celery": "n", "use_mailhog": "n", - "use_sentry": "y", - "use_whitenoise": "y", + "use_sentry": "n", + "use_whitenoise": "n", "use_heroku": "n", "use_travisci": "n", "keep_local_envs_in_vcs": "y", diff --git a/docs/deployment-on-heroku.rst b/docs/deployment-on-heroku.rst index 982168fc7..d7d95184d 100644 --- a/docs/deployment-on-heroku.rst +++ b/docs/deployment-on-heroku.rst @@ -14,26 +14,41 @@ Run these commands to deploy the project to Heroku: heroku pg:promote DATABASE_URL heroku addons:create heroku-redis:hobby-dev - heroku addons:create mailgun - heroku config:set WEB_CONCURRENCY=4 - # Generating a 32 character-long random string without any of the visually similiar characters "IOl01": - heroku config:set DJANGO_ADMIN_URL="$(openssl rand -base64 4096 | tr -dc 'A-HJ-NP-Za-km-z2-9' | head -c 32)/" - heroku config:set DJANGO_SECRET_KEY="$(openssl rand -base64 64)" - heroku config:set DJANGO_SETTINGS_MODULE=config.settings.production - heroku config:set DJANGO_ALLOWED_HOSTS='.herokuapp.com' + # If using mailgun: + heroku addons:create mailgun:starter - heroku config:set DJANGO_AWS_ACCESS_KEY_ID=YOUR_AWS_ID_HERE - heroku config:set DJANGO_AWS_SECRET_ACCESS_KEY=YOUR_AWS_SECRET_ACCESS_KEY_HERE - heroku config:set DJANGO_AWS_STORAGE_BUCKET_NAME=YOUR_AWS_S3_BUCKET_NAME_HERE - - # This is to be set only if you're using Sentry: - heroku config:set DJANGO_SENTRY_DSN=YOUR_SENTRY_DSN + heroku addons:create sentry:f1 heroku config:set PYTHONHASHSEED=random + + heroku config:set WEB_CONCURRENCY=4 + + heroku config:set DJANGO_DEBUG=False + heroku config:set DJANGO_SETTINGS_MODULE=config.settings.production + heroku config:set DJANGO_SECRET_KEY="$(openssl rand -base64 64)" + + # Generating a 32 character-long random string without any of the visually similiar characters "IOl01": + heroku config:set DJANGO_ADMIN_URL="$(openssl rand -base64 4096 | tr -dc 'A-HJ-NP-Za-km-z2-9' | head -c 32)/" + + # Set this to your Heroku app url, e.g. 'bionic-beaver-28392.herokuapp.com' + heroku config:set DJANGO_ALLOWED_HOSTS= + + # Assign with AWS_ACCESS_KEY_ID + heroku config:set DJANGO_AWS_ACCESS_KEY_ID= + + # Assign with AWS_SECRET_ACCESS_KEY + heroku config:set DJANGO_AWS_SECRET_ACCESS_KEY= + + # Assign with AWS_STORAGE_BUCKET_NAME + heroku config:set DJANGO_AWS_STORAGE_BUCKET_NAME= git push heroku master + heroku run python manage.py migrate - heroku run python manage.py check --deploy heroku run python manage.py createsuperuser + heroku run python manage.py collectstatic --no-input + + heroku run python manage.py check --deploy + heroku open diff --git a/docs/deployment-with-docker.rst b/docs/deployment-with-docker.rst index 90f2fa5c0..b21668241 100644 --- a/docs/deployment-with-docker.rst +++ b/docs/deployment-with-docker.rst @@ -21,10 +21,13 @@ Before you begin, check out the ``production.yml`` file in the root of this proj * ``redis``: Redis instance for caching; * ``caddy``: Caddy web server with HTTPS on by default. -Provided you have opted for Celery (via setting ``use_celery`` to ``y``) there are two more services: +Provided you have opted for Celery (via setting ``use_celery`` to ``y``) there are three more services: * ``celeryworker`` running a Celery worker process; -* ``celerybeat`` running a Celery beat process. +* ``celerybeat`` running a Celery beat process; +* ``flower`` running Flower_ (for more info, check out :ref:`CeleryFlower` instructions for local environment). + +.. _`Flower`: https://github.com/mher/flower Configuring the Stack @@ -32,7 +35,7 @@ Configuring the Stack The majority of services above are configured through the use of environment variables. Just check out :ref:`envs` and you will know the drill. -To obtain logs and information about crashes in a production setup, make sure that you have access to an external Sentry instance (e.g. by creating an account with `sentry.io`_), and set the ``DJANGO_SENTRY_DSN`` variable. +To obtain logs and information about crashes in a production setup, make sure that you have access to an external Sentry instance (e.g. by creating an account with `sentry.io`_), and set the ``SENTRY_DSN`` variable. You will probably also need to setup the Mail backend, for example by adding a `Mailgun`_ API key and a `Mailgun`_ sender domain, otherwise, the account creation view will crash and result in a 500 error when the backend attempts to send an email to the account owner. @@ -70,7 +73,7 @@ You can read more about this here at `Automatic HTTPS`_ in the Caddy docs. (Optional) Postgres Data Volume Modifications --------------------------------------------- -Postgres is saving its database files to the ``postgres_data`` volume by default. Change that if you want something else and make sure to make backups since this is not done automatically. +Postgres is saving its database files to the ``production_postgres_data`` volume by default. Change that if you want something else and make sure to make backups since this is not done automatically. Building & Running Production Stack @@ -84,6 +87,10 @@ Once this is ready, you can run it with:: docker-compose -f production.yml up +To run the stack and detach the containers, run:: + + docker-compose -f production.yml up -d + To run a migration, open up a second terminal and run:: docker-compose -f production.yml run --rm django python manage.py migrate diff --git a/docs/developing-locally-docker.rst b/docs/developing-locally-docker.rst index 207f0ea2c..08b25f3bc 100644 --- a/docs/developing-locally-docker.rst +++ b/docs/developing-locally-docker.rst @@ -91,8 +91,8 @@ This is the excerpt from your project's ``local.yml``: :: context: . dockerfile: ./compose/production/postgres/Dockerfile volumes: - - postgres_data_local:/var/lib/postgresql/data - - postgres_backup_local:/backups + - local_postgres_data:/var/lib/postgresql/data + - local_postgres_data_backups:/backups env_file: - ./.envs/.local/.postgres @@ -170,3 +170,20 @@ When developing locally you can go with MailHog_ for email testing provided ``us #. open up ``http://127.0.0.1:8025``. .. _Mailhog: https://github.com/mailhog/MailHog/ + + +.. _`CeleryFlower`: + +Celery Flower +~~~~~~~~~~~~~ + +`Flower`_ is a "real-time monitor and web admin for Celery distributed task queue". + +Prerequisites: + +* ``use_docker`` was set to ``y`` on project initialization; +* ``use_celery`` was set to ``y`` on project initialization. + +By default, it's enabled both in local and production environments (``local.yml`` and ``production.yml`` Docker Compose configs, respectively) through a ``flower`` service. For added security, ``flower`` requires its clients to provide authentication credentials specified as the corresponding environments' ``.envs/.local/.django`` and ``.envs/.production/.django`` ``CELERY_FLOWER_USER`` and ``CELERY_FLOWER_PASSWORD`` environment variables. Check out ``localhost:5555`` and see for yourself. + +.. _`Flower`: https://github.com/mher/flower diff --git a/docs/project-generation-options.rst b/docs/project-generation-options.rst index 476d65af9..60453b870 100644 --- a/docs/project-generation-options.rst +++ b/docs/project-generation-options.rst @@ -1,31 +1,31 @@ Project Generation Options ========================== -project_name [My Awesome Project]: +project_name: Your project's human-readable name, capitals and spaces allowed. -project_slug [my_awesome_project]: +project_slug: Your project's slug without dashes or spaces. Used to name your repo and in other places where a Python-importable version of your project name is needed. -description [Behold My Awesome Project!] +description: Describes your project and gets used in places like ``README.rst`` and such. -author_name [Daniel Roy Greenfeld]: +author_name: This is you! The value goes into places like ``LICENSE`` and such. -email [daniel-roy-greenfeld@example.com]: +email: The email address you want to identify yourself in the project. -domain_name [example.com] +domain_name: The domain name you plan to use for your project once it goes live. Note that it can be safely changed later on whenever you need to. -version [0.1.0] +version: The version of the project at its inception. -open_source_license [1] +open_source_license: A software license for the project. The choices are: 1. MIT_ @@ -34,19 +34,19 @@ open_source_license [1] 4. `Apache Software License 2.0`_ 5. Not open source -timezone [UTC] +timezone: The value to be used for the ``TIME_ZONE`` setting of the project. -windows [n] +windows: Indicates whether the project should be configured for development on Windows. -use_pycharm [n] +use_pycharm: Indicates whether the project should be configured for development with PyCharm_. -use_docker [y] +use_docker: Indicates whether the project should be configured to use Docker_ and `Docker Compose`_. -postgresql_version [1] +postgresql_version: Select a PostgreSQL_ version to use. The choices are: 1. 10.3 @@ -57,45 +57,45 @@ postgresql_version [1] 6. 9.4 7. 9.3 -js_task_runner [1] +js_task_runner: Select a JavaScript task runner. The choices are: 1. None 2. Gulp_ -custom_bootstrap_compilation [n] +custom_bootstrap_compilation: Indicates whether the project should support Bootstrap recompilation via the selected JavaScript task runner's task. This can be useful for real-time Bootstrap variable alteration. -use_compressor [n] +use_compressor: Indicates whether the project should be configured to use `Django Compressor`_. -use_celery [n] +use_celery: Indicates whether the project should be configured to use Celery_. -use_mailhog [n] +use_mailhog: Indicates whether the project should be configured to use MailHog_. -use_sentry [n] +use_sentry: Indicates whether the project should be configured to use Sentry_. -use_whitenoise [y] +use_whitenoise: Indicates whether the project should be configured to use WhiteNoise_. -use_heroku [n] +use_heroku: Indicates whether the project should be configured so as to be deployable to Heroku_. -use_travisci [n] +use_travisci: Indicates whether the project should be configured to use `Travis CI`_. -keep_local_envs_in_vcs [y] +keep_local_envs_in_vcs: Indicates whether the project's ``.envs/.local/`` should be kept in VCS (comes in handy when working in teams where local environment reproducibility is strongly encouraged). -debug [n] +debug: Indicates whether the project should be configured for debugging. This option is relevant for Cookiecutter Django developers only. diff --git a/docs/settings.rst b/docs/settings.rst index 60593a5d1..6e71a5151 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -44,7 +44,7 @@ Environment Variable Django Setting Development DJANGO_AWS_ACCESS_KEY_ID AWS_ACCESS_KEY_ID n/a raises error DJANGO_AWS_SECRET_ACCESS_KEY AWS_SECRET_ACCESS_KEY n/a raises error DJANGO_AWS_STORAGE_BUCKET_NAME AWS_STORAGE_BUCKET_NAME n/a raises error -DJANGO_SENTRY_DSN SENTRY_DSN n/a raises error +SENTRY_DSN SENTRY_DSN n/a raises error DJANGO_SENTRY_CLIENT SENTRY_CLIENT n/a raven.contrib.django.raven_compat.DjangoClient DJANGO_SENTRY_LOG_LEVEL SENTRY_LOG_LEVEL n/a logging.INFO MAILGUN_API_KEY MAILGUN_ACCESS_KEY n/a raises error diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 6b48471e5..669edb0ef 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -32,7 +32,10 @@ DEBUG_VALUE = "debug" def remove_open_source_files(): - file_names = ["CONTRIBUTORS.txt"] + file_names = [ + "CONTRIBUTORS.txt", + "LICENSE", + ] for file_name in file_names: os.remove(file_name) @@ -61,6 +64,10 @@ def remove_docker_files(): os.remove(file_name) +def remove_utility_files(): + shutil.rmtree("utility") + + def remove_heroku_files(): file_names = ["Procfile", "runtime.txt", "requirements.txt"] for file_name in file_names: @@ -162,8 +169,12 @@ def set_django_admin_url(file_path): return django_admin_url +def generate_random_user(): + return generate_random_string(length=32, using_ascii_letters=True) + + def generate_postgres_user(debug=False): - return DEBUG_VALUE if debug else generate_random_string(length=32, using_ascii_letters=True) + return DEBUG_VALUE if debug else generate_random_user() def set_postgres_user(file_path, value): @@ -187,25 +198,56 @@ def set_postgres_password(file_path, value=None): return postgres_password +def set_celery_flower_user(file_path, value): + celery_flower_user = set_flag( + file_path, + "!!!SET CELERY_FLOWER_USER!!!", + value=value, + ) + return celery_flower_user + + +def set_celery_flower_password(file_path, value=None): + celery_flower_password = set_flag( + file_path, + "!!!SET CELERY_FLOWER_PASSWORD!!!", + value=value, + length=64, + using_digits=True, + using_ascii_letters=True, + ) + return celery_flower_password + + def append_to_gitignore_file(s): with open(".gitignore", "a") as gitignore_file: gitignore_file.write(s) gitignore_file.write(os.linesep) -def set_flags_in_envs(postgres_user, debug=False): - local_postgres_envs_path = os.path.join(".envs", ".local", ".postgres") - set_postgres_user(local_postgres_envs_path, value=postgres_user) - set_postgres_password(local_postgres_envs_path, value=DEBUG_VALUE if debug else None) - +def set_flags_in_envs( + postgres_user, + celery_flower_user, + debug=False, +): + local_django_envs_path = os.path.join(".envs", ".local", ".django") production_django_envs_path = os.path.join(".envs", ".production", ".django") + local_postgres_envs_path = os.path.join(".envs", ".local", ".postgres") + production_postgres_envs_path = os.path.join(".envs", ".production", ".postgres") + set_django_secret_key(production_django_envs_path) set_django_admin_url(production_django_envs_path) - production_postgres_envs_path = os.path.join(".envs", ".production", ".postgres") + set_postgres_user(local_postgres_envs_path, value=postgres_user) + set_postgres_password(local_postgres_envs_path, value=DEBUG_VALUE if debug else None) set_postgres_user(production_postgres_envs_path, value=postgres_user) set_postgres_password(production_postgres_envs_path, value=DEBUG_VALUE if debug else None) + set_celery_flower_user(local_django_envs_path, value=celery_flower_user) + set_celery_flower_password(local_django_envs_path, value=DEBUG_VALUE if debug else None) + set_celery_flower_user(production_django_envs_path, value=celery_flower_user) + set_celery_flower_password(production_django_envs_path, value=DEBUG_VALUE if debug else None) + def set_flags_in_settings_files(): set_django_secret_key(os.path.join("config", "settings", "local.py")) @@ -223,8 +265,13 @@ def remove_celery_compose_dirs(): def main(): - postgres_user = generate_postgres_user(debug="{{ cookiecutter.debug }}".lower() == "y") - set_flags_in_envs(postgres_user, debug="{{ cookiecutter.debug }}".lower() == "y") + debug = "{{ cookiecutter.debug }}".lower() == "y" + + set_flags_in_envs( + DEBUG_VALUE if debug else generate_random_user(), + DEBUG_VALUE if debug else generate_random_user(), + debug=debug, + ) set_flags_in_settings_files() if "{{ cookiecutter.open_source_license }}" == "Not open source": @@ -235,7 +282,9 @@ def main(): if "{{ cookiecutter.use_pycharm }}".lower() == "n": remove_pycharm_files() - if "{{ cookiecutter.use_docker }}".lower() == "n": + if "{{ cookiecutter.use_docker }}".lower() == "y": + remove_utility_files() + else: remove_docker_files() if "{{ cookiecutter.use_heroku }}".lower() == "n": diff --git a/requirements.txt b/requirements.txt index eedbfad06..fca457e76 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,6 +8,6 @@ flake8==3.5.0 # Testing # ------------------------------------------------------------------------------ -tox==3.0.0 -pytest==3.5.1 +tox==3.1.1 +pytest==3.6.3 pytest-cookies==0.3.0 diff --git a/tests/test_docker.sh b/tests/test_docker.sh index 384fdff2d..bebac1488 100755 --- a/tests/test_docker.sh +++ b/tests/test_docker.sh @@ -11,7 +11,7 @@ mkdir -p .cache/docker cd .cache/docker # create the project using the default settings in cookiecutter.json -cookiecutter ../../ --no-input --overwrite-if-exists use_docker=y js_task_runner=None +cookiecutter ../../ --no-input --overwrite-if-exists use_docker=y cd my_awesome_project # run the project's tests diff --git a/{{cookiecutter.project_slug}}/.envs/.local/.django b/{{cookiecutter.project_slug}}/.envs/.local/.django index 8aa9a9946..d94a17e59 100644 --- a/{{cookiecutter.project_slug}}/.envs/.local/.django +++ b/{{cookiecutter.project_slug}}/.envs/.local/.django @@ -5,3 +5,11 @@ USE_DOCKER=yes # Redis # ------------------------------------------------------------------------------ REDIS_URL=redis://redis:6379/0 +{% if cookiecutter.use_celery == 'y' %} +# Celery +# ------------------------------------------------------------------------------ + +# Flower +CELERY_FLOWER_USER=!!!SET CELERY_FLOWER_USER!!! +CELERY_FLOWER_PASSWORD=!!!SET CELERY_FLOWER_PASSWORD!!! +{% endif %} diff --git a/{{cookiecutter.project_slug}}/.envs/.production/.django b/{{cookiecutter.project_slug}}/.envs/.production/.django index 2e9eefea7..4175f8944 100644 --- a/{{cookiecutter.project_slug}}/.envs/.production/.django +++ b/{{cookiecutter.project_slug}}/.envs/.production/.django @@ -37,9 +37,17 @@ WEB_CONCURRENCY=4 {% if cookiecutter.use_sentry == 'y' %} # Sentry # ------------------------------------------------------------------------------ -DJANGO_SENTRY_DSN= +SENTRY_DSN= {% endif %} # Redis # ------------------------------------------------------------------------------ REDIS_URL=redis://redis:6379/0 +{% if cookiecutter.use_celery == 'y' %} +# Celery +# ------------------------------------------------------------------------------ + +# Flower +CELERY_FLOWER_USER=!!!SET CELERY_FLOWER_USER!!! +CELERY_FLOWER_PASSWORD=!!!SET CELERY_FLOWER_PASSWORD!!! +{% endif %} diff --git a/{{cookiecutter.project_slug}}/.gitignore b/{{cookiecutter.project_slug}}/.gitignore index 3cabaac22..679fb9026 100644 --- a/{{cookiecutter.project_slug}}/.gitignore +++ b/{{cookiecutter.project_slug}}/.gitignore @@ -330,7 +330,6 @@ tags [Ii]nclude [Ll]ib [Ll]ib64 -[Ll]ocal [Ss]cripts pyvenv.cfg pip-selfcheck.json @@ -341,3 +340,5 @@ pip-selfcheck.json MailHog {%- endif %} {{ cookiecutter.project_slug }}/media/ + +.pytest_cache/ diff --git a/{{cookiecutter.project_slug}}/.idea/misc.xml b/{{cookiecutter.project_slug}}/.idea/misc.xml new file mode 100644 index 000000000..10af178fd --- /dev/null +++ b/{{cookiecutter.project_slug}}/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/{{cookiecutter.project_slug}}/.idea/modules.xml b/{{cookiecutter.project_slug}}/.idea/modules.xml new file mode 100644 index 000000000..1418fcddf --- /dev/null +++ b/{{cookiecutter.project_slug}}/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/{{cookiecutter.project_slug}}/.idea/runConfigurations/Docker__runserver.xml b/{{cookiecutter.project_slug}}/.idea/runConfigurations/Docker__runserver.xml deleted file mode 100644 index 77b9a5875..000000000 --- a/{{cookiecutter.project_slug}}/.idea/runConfigurations/Docker__runserver.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - diff --git a/{{cookiecutter.project_slug}}/.idea/runConfigurations/Docker__tests___all.xml b/{{cookiecutter.project_slug}}/.idea/runConfigurations/Docker__tests___all.xml deleted file mode 100644 index c4fd62aae..000000000 --- a/{{cookiecutter.project_slug}}/.idea/runConfigurations/Docker__tests___all.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - diff --git a/{{cookiecutter.project_slug}}/.idea/runConfigurations/Docker__tests___class__TestUser.xml b/{{cookiecutter.project_slug}}/.idea/runConfigurations/Docker__tests___class__TestUser.xml deleted file mode 100644 index 78da4a677..000000000 --- a/{{cookiecutter.project_slug}}/.idea/runConfigurations/Docker__tests___class__TestUser.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - diff --git a/{{cookiecutter.project_slug}}/.idea/runConfigurations/Docker__tests___file__test_models.xml b/{{cookiecutter.project_slug}}/.idea/runConfigurations/Docker__tests___file__test_models.xml deleted file mode 100644 index 0391bf257..000000000 --- a/{{cookiecutter.project_slug}}/.idea/runConfigurations/Docker__tests___file__test_models.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - diff --git a/{{cookiecutter.project_slug}}/.idea/runConfigurations/Docker__tests___module__users.xml b/{{cookiecutter.project_slug}}/.idea/runConfigurations/Docker__tests___module__users.xml deleted file mode 100644 index 651ea5cb9..000000000 --- a/{{cookiecutter.project_slug}}/.idea/runConfigurations/Docker__tests___module__users.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - diff --git a/{{cookiecutter.project_slug}}/.idea/runConfigurations/Docker__tests___specific__test_get_absolute_url.xml b/{{cookiecutter.project_slug}}/.idea/runConfigurations/Docker__tests___specific__test_get_absolute_url.xml deleted file mode 100644 index 8c7893907..000000000 --- a/{{cookiecutter.project_slug}}/.idea/runConfigurations/Docker__tests___specific__test_get_absolute_url.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - diff --git a/{{cookiecutter.project_slug}}/.idea/runConfigurations/merge_production_dotenvs_in_dotenv.xml b/{{cookiecutter.project_slug}}/.idea/runConfigurations/merge_production_dotenvs_in_dotenv.xml index 18f8365aa..cf2c5dd89 100644 --- a/{{cookiecutter.project_slug}}/.idea/runConfigurations/merge_production_dotenvs_in_dotenv.xml +++ b/{{cookiecutter.project_slug}}/.idea/runConfigurations/merge_production_dotenvs_in_dotenv.xml @@ -1,5 +1,6 @@ +