diff --git a/.gitignore b/.gitignore index 818cccd5a..393a1968c 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,7 @@ sftp-config.json *.pyc .idea _build +*.egg-info/ # Project Specific Stuff local_settings.py diff --git a/.travis.yml b/.travis.yml index b548b9235..f4a2e41c5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,12 +15,17 @@ env: - TOX_ENV=py35 before_install: + - sudo sh -c 'echo "deb https://apt.dockerproject.org/repo ubuntu-precise main" > /etc/apt/sources.list.d/docker.list' + - sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D - sudo apt-get update - - sudo apt-get install -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" docker-engine=1.10.1-0~trusty + - sudo apt-key update + - sudo apt-get --force-yes -qqy -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install docker-engine=1.11.1-0~precise - sudo rm /usr/local/bin/docker-compose - - curl -L https://github.com/docker/compose/releases/download/1.6.0/docker-compose-`uname -s`-`uname -m` > docker-compose + - curl -L https://github.com/docker/compose/releases/download/1.7.0/docker-compose-`uname -s`-`uname -m` > docker-compose - chmod +x docker-compose - sudo mv docker-compose /usr/local/bin + - docker-compose -v + - docker -v script: - tox -e $TOX_ENV diff --git a/CHANGELOG.md b/CHANGELOG.md index 76ba8fba5..e614c84a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,93 @@ All enhancements and patches to Cookiecutter Django will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +##[2016-09-10] +### Changed +- Use app registry instead of INSTALLED_APPS to discover celery tasks (@dhepper) +- PEP8 imports fix (@aleprovencio) + +### Removed +- Removed django-floppyforms (@pydanny) + +##[2016-09-08] +### Removed +- Webpack support, see #774 (@ssteinerx) + +##[2016-08-10] +## Added +- PostgreSQL versions are now selectable, instead of defaulting to 9.5; the minimum version is 9.2, which is supported by [Heroku](https://devcenter.heroku.com/articles/heroku-postgresql#version-support-and-legacy-infrastructure) and Django (@burhan) +- Fixed minor issue in the README.rst (@burhan) + +##[2016-08-03] +## Changed +- Upgrade to Bootstrap 4 Alpha 3 and its dependencies, including jQuery (@audreyr) + +##[2016-06-25] +## Changed +- use `https` instead `ssh` to clone [cookiecutter-webpack](https://github.com/hzdg/cookiecutter-webpack) if `Webpack` is selected as `JS Task Runner` - fix issue #647 (@luzfcb and @resakse) + +##[2016-06-24] +## Added +- Settings file for running tests faster (@audreyr) +- Add GPLv3 licence support (@cgaspoz) + +## Changed +- Makes the database backups compressed. restores compressed backups (@jangeador) +- Review and edit django-allauth templates (@kappataumu) + +##[2016-06-19] +## Added +- Webpack as an option (@goldhand) + +##[2016-06-17] +## Added +- django-compressor support (@andresgz) +- Debian Jessie OS Requirements (@ddiazpinto) + +##[2016-06-14] +### Changed +- Move Docker backups to their own section (@pydanny) + +##[2016-06-13] +### Changed +- Use latest redis image in Docker (@pydanny) +- Documentation cleanup and corrections (@audreyr) + +##[2016-06-12] +### Changed +- Documentation cleanup and corrections (@kappataumu) + +##[2016-06-11] +### Changed +- Enhancements to the developing locally docs (@antoniablair) + +##[2016-06-06] +### Changed +- Pin Bootstrap CSS and JS to v4.0.0-alpha.2, use minified versions + +##[2016-06-05] +### Added +- Configurable admin for users (@pydanny, @jayfk, @dezoito) + +##[2016-06-04] +### Added +- Let's Encrypt automation and instruction (@mjsisley and @chrisdev) + +##[2016-06-03] +### Added +- Documentation for debugging with Docker (@mjsisley) +- Apache 2 License option in `cookiecutter.json` (@dot2dotseurat) +- Removed unnecessary version check from `pre_gen_project.py` (@suledev) +- Add gulp alternative as a js task runner and fix navbar style issue (@viviangb and @xpostudio4) + +### Deleted +- AngularJS (@pydanny) +- django-secure (@xpostudio4) + +##[2016-06-02] +### Added +- Added better instructions for installing postgres on Mac OS X (@dot2dotseurat ) + ##[2016-05-22] ### Added - Added instructions for copying backups from docker to host (@phiberjenz) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index 2fda7c634..652b7bd55 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -2,7 +2,7 @@ Contributors ============ Core Developers ----------------- +--------------- These contributors have commit flags for the repository, and are able to accept and merge pull requests. @@ -28,7 +28,7 @@ Daniel are on the Cookiecutter core team.* .. _@jayfk: https://github.com/jayfk Other Contributors -------------------- +------------------ Listed in alphabetical order. @@ -45,9 +45,12 @@ Listed in alphabetical order. Alex Tsai `@caffodian`_ Alvaro [Andor] `@andor-pierdelacabeza`_ Amjith Ramanujam `@amjith`_ + Andreas Meistad `@ameistad`_ + Andres Gonzalez `@andresgz`_ Andrew Mikhnevich `@zcho`_ Andy Rose Anna Callahan `@jazztpt`_ + Antonia Blair `@antoniablair`_ @antoniablairart Areski Belaid `@areski`_ Ashley Camba Barclay Gauld `@yunti`_ @@ -57,16 +60,21 @@ Listed in alphabetical order. Bouke Haarsma Burhan Khalid `@burhan`_ @burhan Catherine Devlin `@catherinedevlin`_ + Cédric Gaspoz `@cgaspoz`_ Chris Curvey `@ccurvey`_ Chris Franklin Chris Franklin `@hairychris`_ Chris Pappalardo `@ChrisPappalardo`_ + Christopher Clarke `@chrisdev`_ Collederas `@Collederas`_ Cristian Vargas `@cdvv7788`_ Cullen Rhodes `@c-rhodes`_ + Dan Shultz `@shultz`_ + Daniel Hepper `@dhepper`_ @danielhepper Daniele Tricoli `@eriol`_ David Díaz `@ddiazpinto`_ @DavidDiazPinto Davur Clementsen `@dsclementsen`_ @davur + Delio Castillo `@jangeador`_ @jangeador Dónal Adams `@epileptic-fish`_ Dong Huynh `@trungdong`_ Emanuel Calso `@bloodpet`_ @bloodpet @@ -79,14 +87,17 @@ Listed in alphabetical order. Henrique G. G. Pereira `@ikkebr`_ Ian Lee `@IanLee1521`_ Jan Van Bruggen `@jvanbrug`_ - Jens Nilsson `@phiberjenz` + Jens Nilsson `@phiberjenz`_ + Julien Almarcha `@sladinji`_ Julio Castillo `@juliocc`_ Kaido Kert `@kaidokert`_ + kappataumu `@kappataumu`_ @kappataumu Kaveh `@ka7eh`_ Kevin A. Stone Kevin Ndung'u `@kevgathuku`_ Krzysztof Szumny `@noisy`_ Krzysztof Żuraw `@krzysztofzuraw`_ + Leonardo Jimenez `@xpostudio4`_ Lin Xianyi `@iynaix`_ Luis Nell `@originell`_ Lukas Klein @@ -96,8 +107,12 @@ Listed in alphabetical order. Matt Linares Matt Menzenski `@menzenski`_ Matt Warren `@mfwarren`_ + Matthew Sisley `@mjsisley`_ + Meghan Heintz `@dot2dotseurat`_ mozillazg `@mozillazg`_ Pablo `@oubiga`_ + Parbhat Puri `@parbhat`_ + Peter Bittner `@bittner`_ Raphael Pierzina `@hackebrot`_ Raony Guimarães Corrêa `@raonyguimaraes`_ Roman Afanaskin `@siauPatrick`_ @@ -106,25 +121,32 @@ Listed in alphabetical order. stepmr `@stepmr`_ Sławek Ehlert `@slafs`_ Srinivas Nyayapati `@shireenrao`_ + Steve Steiner `@ssteinerX`_ + Sule Marshall `@suledev`_ Taylor Baldwin Théo Segonds `@show0k`_ Tom Atkins `@knitatoms`_ Tom Offermann - Travis McNeill `@Travistock`_ @tavistock_esq + Travis McNeill `@Travistock`_ @tavistock_esq Vitaly Babiy + Vivian Guillen `@viviangb`_ + Will Farley `@goldhand`_ @g01dhand Yaroslav Halchenko ========================== ============================ ============== -.. _@dezoito: https://github.com/dezoito .. _@a7p: https://github.com/a7p .. _@ad-m: https://github.com/ad-m .. _@aeikenberry: https://github.com/aeikenberry .. _@alb3rto: https://github.com/alb3rto +.. _@ameistad: https://github.com/ameistad .. _@amjith: https://github.com/amjith .. _@andor-pierdelacabeza: https://github.com/andor-pierdelacabeza +.. _@antoniablair: https://github.com/antoniablair .. _@areski: https://github.com/areski .. _@arruda: https://github.com/arruda +.. _@bittner: https://github.com/bittner .. _@bloodpet: https://github.com/bloodpet +.. _@blopker: https://github.com/blopker .. _@bogdal: https://github.com/bogdal .. _@burhan: https://github.com/burhan .. _@c-rhodes: https://github.com/c-rhodes @@ -132,9 +154,14 @@ Listed in alphabetical order. .. _@catherinedevlin: https://github.com/catherinedevlin .. _@ccurvey: https://github.com/ccurvey .. _@cdvv7788: https://github.com/cdvv7788 +.. _@cgaspoz: https://github.com/cgaspoz +.. _@chrisdev: https://github.com/chrisdev .. _@ChrisPappalardo: https://github.com/ChrisPappalardo .. _@Collederas: https://github.com/Collederas .. _@ddiazpinto: https://github.com/ddiazpinto +.. _@dezoito: https://github.com/dezoito +.. _@dhepper: https://github.com/dhepper +.. _@dot2dotseurat: https://github.com/dot2dotseurat .. _@dsclementsen: https://github.com/dsclementsen .. _@epileptic-fish: https://gihub.com/epileptic-fish .. _@eraldo: https://github.com/eraldo @@ -142,6 +169,7 @@ Listed in alphabetical order. .. _@eyadsibai: https://github.com/eyadsibai .. _@garry-cairns: https://github.com/garry-cairns .. _@garrypolley: https://github.com/garrypolley +.. _@goldhand: https://github.com/goldhand .. _@hackebrot: https://github.com/hackebrot .. _@hairychris: https://github.com/hairychris .. _@hjwp: https://github.com/hjwp @@ -153,26 +181,40 @@ Listed in alphabetical order. .. _@jvanbrug: https://github.com/jvanbrug .. _@ka7eh: https://github.com/ka7eh .. _@kaidokert: https://github.com/kaidokert +.. _@kappataumu: https://github.com/kappataumu .. _@kevgathuku: https://github.com/kevgathuku .. _@knitatoms: https://github.com/knitatoms +.. _@krzysztofzuraw: https://github.com/krzysztofzuraw .. _@MathijsHoogland: https://github.com/MathijsHoogland .. _@menzenski: https://github.com/menzenski .. _@mfwarren: https://github.com/mfwarren +.. _@mjsisley: https://github.com/mjsisley .. _@mozillazg: https://github.com/mozillazg +.. _@noisy: https://github.com/noisy .. _@originell: https://github.com/originell .. _@oubiga: https://github.com/oubiga -.. _@romanosipenko: https://github.com/romanosipenko +.. _@parbhat: https://github.com/parbhat .. _@raonyguimaraes: https://github.com/raonyguimaraes -.. _@show0k: https://github.com/show0k -.. _@siauPatrick: https://github.com/siauPatrick +.. _@romanosipenko: https://github.com/romanosipenko .. _@shireenrao: https://github.com/shireenrao +.. _@show0k: https://github.com/show0k +.. _@shultz: https://github.com/shultz +.. _@siauPatrick: https://github.com/siauPatrick .. _@slafs: https://github.com/slafs +.. _@ssteinerX: https://github.com/ssteinerx .. _@stepmr: https://github.com/stepmr +.. _@suledev: https://github.com/suledev .. _@Travistock: https://github.com/Tavistock .. _@trungdong: https://github.com/trungdong +.. _@viviangb: httpsL//github.com/viviangb +.. _@xpostudio4: https://github.com/xpostudio4 .. _@yunti: https://github.com/yunti .. _@zcho: https://github.com/zcho -.. _@noisy: https://github.com/noisy +.. _@phiberjenz: https://github.com/phiberjenz +.. _@sladinji: https://github.com/sladinji +.. _@andresgz: https://github.com/andresgz +.. _@jangeador: https://github.com/jangeador + Special Thanks ~~~~~~~~~~~~~~ diff --git a/README.rst b/README.rst index eece63919..a0aa50778 100644 --- a/README.rst +++ b/README.rst @@ -1,9 +1,9 @@ Cookiecutter Django ======================= -.. image:: https://requires.io/github/pydanny/cookiecutter-django/requirements.svg?branch=master - :target: https://requires.io/github/pydanny/cookiecutter-django/requirements/?branch=master - :alt: Requirements Status +.. image:: https://pyup.io/repos/github/pydanny/cookiecutter-django/shield.svg + :target: https://pyup.io/repos/github/pydanny/cookiecutter-django/ + :alt: Updates .. image:: https://travis-ci.org/pydanny/cookiecutter-django.svg?branch=master :target: https://travis-ci.org/pydanny/cookiecutter-django?branch=master @@ -14,9 +14,12 @@ Cookiecutter Django Powered by Cookiecutter_, Cookiecutter Django is a framework for jumpstarting production-ready Django projects quickly. +* Documentation: https://cookiecutter-django.readthedocs.io/en/latest/ +* See Troubleshooting_ for common errors and obstacles + .. _cookiecutter: https://github.com/audreyr/cookiecutter -**Warning**: if you get the error "jinja2.exceptions.TemplateSyntaxError: Encountered unknown tag 'now'." , please upgrade your cookiecutter version to >= 1.4 (see issue # 528_ ) +.. _Troubleshooting: https://cookiecutter-django.readthedocs.io/en/latest/troubleshooting.html .. _528: https://github.com/pydanny/cookiecutter-django/issues/528#issuecomment-212650373 @@ -25,20 +28,20 @@ Features * For Django 1.9 * Renders Django projects with 100% starting test coverage -* Twitter Bootstrap_ v4.0.0 - alpha_ -* AngularJS_ +* Twitter Bootstrap_ v4.0.0 - `alpha 3`_ * 12-Factor_ based settings via django-environ_ * Optimized development and production settings * Registration via django-allauth_ -* Comes with custom user model ready to go. +* Comes with custom user model ready to go * Grunt build for compass and livereload -* Basic e-mail configurations for sending emails via Mailgun_ +* Send emails via Anymail_ (using Mailgun_ by default, but switchable) * Media storage using Amazon S3 * Docker support using docker-compose_ for development and production * Procfile_ for deploying to Heroku * Instructions for deploying to PythonAnywhere_ * Works with Python 2.7.x or 3.5.x * Run tests with unittest or py.test +* Customizable PostgreSQL version Optional Integrations @@ -50,24 +53,22 @@ Optional Integrations * Configuration for Celery_ * Integration with MailHog_ for local email testing * Integration with Sentry_ for error logging -* Integration with NewRelic_ for performance monitoring * Integration with Opbeat_ for performance monitoring -.. _alpha: http://blog.getbootstrap.com/2015/08/19/bootstrap-4-alpha/ +.. _`alpha 3`: http://blog.getbootstrap.com/2016/07/27/bootstrap-4-alpha-3/ .. _Bootstrap: https://github.com/twbs/bootstrap -.. _AngularJS: https://github.com/angular/angular.js .. _django-environ: https://github.com/joke2k/django-environ .. _12-Factor: http://12factor.net/ .. _django-allauth: https://github.com/pennersr/django-allauth -.. _django-avatar: https://github.com/jezdez/django-avatar/ +.. _django-avatar: https://github.com/grantmcconnaughey/django-avatar .. _Procfile: https://devcenter.heroku.com/articles/procfile -.. _Mailgun: https://mailgun.com/ +.. _Mailgun: http://www.mailgun.com/ .. _Whitenoise: https://whitenoise.readthedocs.io/ .. _Celery: http://www.celeryproject.org/ +.. _Anymail: https://github.com/anymail/django-anymail .. _MailHog: https://github.com/mailhog/MailHog -.. _Sentry: https://getsentry.com -.. _NewRelic: https://newrelic.com -.. _docker-compose: https://www.github.com/docker/compose +.. _Sentry: https://getsentry.com/welcome/ +.. _docker-compose: https://github.com/docker/compose .. _Opbeat: https://opbeat.com/ .. _PythonAnywhere: https://www.pythonanywhere.com/ @@ -76,7 +77,7 @@ Constraints ----------- * Only maintained 3rd party libraries are used. -* PostgreSQL everywhere (9.0+) +* Uses PostgreSQL everywhere (9.2+) * Environment variables for configuration (This won't work with Apache/mod_wsgi). @@ -98,8 +99,6 @@ You'll be prompted for some values. Provide them, then a Django project will be **Warning**: After this point, change 'Daniel Greenfeld', 'pydanny', etc to your own information. -**Warning**: project_slug must be a valid Python module name or you will have issues on imports. - Answer the prompts with your own desired options_. For example:: Cloning into 'cookiecutter-django'... @@ -108,34 +107,45 @@ Answer the prompts with your own desired options_. For example:: remote: Total 550 (delta 283), reused 479 (delta 222) Receiving objects: 100% (550/550), 127.66 KiB | 58 KiB/s, done. Resolving deltas: 100% (283/283), done. - project_name [project_name]: Reddit Clone - project_slug [Reddit_Clone]: reddit - author_name [Your Name]: Daniel Roy Greenfeld - email [Your email]: pydanny@gmail.com + project_name [Project Name]: Reddit Clone + project_slug [reddit_clone]: reddit + author_name [Daniel Roy Greenfeld]: Daniel Greenfeld + email [you@example.com]: pydanny@gmail.com description [A short description of the project.]: A reddit clone. domain_name [example.com]: myreddit.com version [0.1.0]: 0.0.1 timezone [UTC]: America/Los_Angeles - now [2016/03/01]: 2016/03/05 - year [2016]: use_whitenoise [y]: n use_celery [n]: y use_mailhog [n]: n - use_sentry [n]: y - use_newrelic [n]: y + use_sentry_for_error_reporting [y]: y use_opbeat [n]: y use_pycharm [n]: y windows [n]: n - use_python2 [n]: n - use_docker [y]: y - use_heroku [n]: n - use_grunt [n]: y - use_angular [n]: n + use_python3 [y]: y + use_docker [y]: n + use_heroku [n]: y + use_compressor [n]: y + Select postgresql_version: + 1 - 9.5 + 2 - 9.4 + 3 - 9.3 + 4 - 9.2 + Choose from 1, 2, 3, 4 [1]: 1 + Select js_task_runner: + 1 - Gulp + 2 - Grunt + 3 - Webpack + 4 - None + Choose from 1, 2, 3, 4 [1]: 1 + use_lets_encrypt [n]: n Select open_source_license: 1 - MIT 2 - BSD - 3 - Not open source - Choose from 1, 2, 3 [1]: 1 + 3 - GPLv3 + 4 - Apache Software License 2.0 + 5 - Not open source + Choose from 1, 2, 3, 4, 5 [1]: 1 Enter the project and take a look around:: @@ -152,7 +162,7 @@ Create a git repo and push it there:: Now take a look at your repo. Don't forget to carefully look at the generated README. Awesome, right? -For development, see the following for local development: +For local development, see the following: * `Developing locally`_ * `Developing locally using docker`_ @@ -164,7 +174,7 @@ For development, see the following for local development: Community ----------- -* Got questions? **Before you ask questions anywhere else**, please post your question on `Stack Overflow`_ under the *cookiecutter-django* tag. We check there periodically for questions. +* Have questions? **Before you ask questions anywhere else**, please post your question on `Stack Overflow`_ under the *cookiecutter-django* tag. We check there periodically for questions. * If you think you found a bug or want to request a feature, please open an issue_. * For anything else, you can chat with us on `Gitter`_. @@ -185,7 +195,7 @@ Scattered throughout the Python and HTML of this project are places marked with Releases -------- -Want a stable release? You can find them at https://github.com/pydanny/cookiecutter-django/releases +Need a stable release? You can find them at https://github.com/pydanny/cookiecutter-django/releases Not Exactly What You Want? @@ -208,10 +218,10 @@ If you do rename your fork, I encourage you to submit it to the following places .. _cookiecutter: https://github.com/audreyr/cookiecutter .. _grid: https://www.djangopackages.com/grids/g/cookiecutters/ -Or Submit a Pull Request -~~~~~~~~~~~~~~~~~~~~~~~~~ +Submit a Pull Request +~~~~~~~~~~~~~~~~~~~~~~ -We also accept pull requests on this, if they're small, atomic, and if they make our own project development +We accept pull requests if they're small, atomic, and make our own project development experience better. Articles @@ -223,14 +233,20 @@ Articles * `Introduction to Cookiecutter-Django`_ - Feb. 19, 2016 * `Django and GitLab - Running Continuous Integration and tests with your FREE account`_ - May. 11, 2016 -Got a blog or online publication? Write about your cookiecutter-django tips and tricks, then send us a pull request with the link. +Have a blog or online publication? Write about your cookiecutter-django tips and tricks, then send us a pull request with the link. -.. _`Development and Deployment of Cookiecutter-Django via Docker`: https://realpython.com/blog/python/development-and-deployment-of-cookiecutter-django-via-docker +.. _`Development and Deployment of Cookiecutter-Django via Docker`: https://realpython.com/blog/python/development-and-deployment-of-cookiecutter-django-via-docker/ .. _`Development and Deployment of Cookiecutter-Django on Fedora`: https://realpython.com/blog/python/development-and-deployment-of-cookiecutter-django-on-fedora/ -.. _`How to create a Django Application using Cookiecutter and Django 1.8`: http://blog.swapps.co/how-to-create-a-django-application-using-cookiecutter-and-django-1-8/#.VxKfBpMrKRs +.. _`How to create a Django Application using Cookiecutter and Django 1.8`: https://www.swapps.io/blog/how-to-create-a-django-application-using-cookiecutter-and-django-1-8/ .. _`Introduction to Cookiecutter-Django`: http://krzysztofzuraw.com/blog/2016/django-cookiecutter.html .. _`Django and GitLab - Running Continuous Integration and tests with your FREE account`: http://dezoito.github.io/2016/05/11/django-gitlab-continuous-integration-phantomjs.html +Code of Conduct +--------------- + +Everyone interacting in the Cookiecutter project's codebases, issue trackers, chat +rooms, and mailing lists is expected to follow the `PyPA Code of Conduct`_. + Support This Project --------------------------- @@ -240,4 +256,6 @@ This project is maintained by volunteers. Support their efforts by spreading the :name: Two Scoops Academy :align: center :alt: Two Scoops Academy - :target: http://www.twoscoops.academy/ + :target: https://twoscoops.academy/ + +.. _`PyPA Code of Conduct`: https://www.pypa.io/en/latest/code-of-conduct/ diff --git a/cookiecutter.json b/cookiecutter.json index 8fe7010a2..9b9c67077 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -1,26 +1,25 @@ { - "project_name": "project_name", + "project_name": "Project Name", "project_slug": "{{ cookiecutter.project_name.lower()|replace(' ', '_')|replace('-', '_') }}", - "author_name": "Your Name", - "email": "Your email", + "author_name": "Daniel Roy Greenfeld", + "email": "you@example.com", "description": "A short description of the project.", "domain_name": "example.com", "version": "0.1.0", "timezone": "UTC", - "now": "{% now 'local' %}", - "year": "{{ cookiecutter.now[:4] }}", "use_whitenoise": "y", "use_celery": "n", "use_mailhog": "n", - "use_sentry": "n", - "use_newrelic": "n", + "use_sentry_for_error_reporting": "y", "use_opbeat": "n", "use_pycharm": "n", "windows": "n", - "use_python2": "n", + "use_python3": "y", "use_docker": "y", "use_heroku": "n", - "use_grunt": "n", - "use_angular": "n", - "open_source_license": ["MIT", "BSD", "Not open source"] + "use_compressor": "n", + "postgresql_version": ["9.5", "9.4", "9.3", "9.2"], + "js_task_runner": ["Gulp", "Grunt", "None"], + "use_lets_encrypt": "n", + "open_source_license": ["MIT", "BSD", "GPLv3", "Apache Software License 2.0", "Not open source"] } diff --git a/docs/conf.py b/docs/conf.py index 2fdeb69e6..293d0fc14 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -46,7 +46,7 @@ master_doc = 'index' # General information about the project. project = 'Cookiecutter Django' -copyright = '2013-{}, Daniel Roy Greenfeld'.format(now.year) +copyright = "2013-2016, Daniel Roy Greenfeld".format(now.year) # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the diff --git a/docs/deployment-on-heroku.rst b/docs/deployment-on-heroku.rst index 82bdbace4..5b9b4a2c4 100644 --- a/docs/deployment-on-heroku.rst +++ b/docs/deployment-on-heroku.rst @@ -16,8 +16,8 @@ You can either push the 'deploy' button in your generated README.rst or run thes heroku addons:create heroku-redis:hobby-dev heroku addons:create mailgun - heroku config:set DJANGO_ADMIN_URL=`openssl rand -base64 32` - heroku config:set DJANGO_SECRET_KEY=`openssl rand -base64 64` + heroku config:set DJANGO_ADMIN_URL="$(openssl rand -base64 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' diff --git a/docs/deployment-with-docker.rst b/docs/deployment-with-docker.rst index de3abf7d4..03aefd486 100644 --- a/docs/deployment-with-docker.rst +++ b/docs/deployment-with-docker.rst @@ -1,49 +1,104 @@ Deployment with Docker -================================================= +======================= .. index:: Docker, deployment -TODO: Review and revise +Prerequisites +------------- -**Warning** +* Docker (at least 1.10) +* Docker Compose (at least 1.6) -Docker is evolving extremely fast, but it has still some rough edges here and there. Compose is currently (as of version 1.4) -not considered production ready. That means you won't be able to scale to multiple servers and you won't be able to run -zero downtime deployments out of the box. Consider all this as experimental until you understand all the implications -to run docker (with compose) on production. - -**Run your app with docker-compose** - -Prerequisites: - -* docker (at least 1.10) -* docker-compose (at least 1.6) +Understand the Compose Setup +-------------------------------- Before you start, check out the `docker-compose.yml` file in the root of this project. This is where each component -of this application gets its configuration from. It consists of a `postgres` service that runs the database, `redis` -for caching, `nginx` as reverse proxy and last but not least the `django` application run by gunicorn. -{% if cookiecutter.use_celery == 'y' -%} -Since this application also runs Celery, there are two more services with a service called `celeryworker` that runs the -celery worker process and `celerybeat` that runs the celery beat process. -{% endif %} +of this application gets its configuration from. Notice how it provides configuration for these services: +* `postgres` service that runs the database +* `redis` for caching +* `nginx` as reverse proxy +* `django` is the Django project run by gunicorn -All of these services except `redis` rely on environment variables set by you. There is an `env.example` file in the +If you chose the `use_celery` option, there are two more services: + +* `celeryworker` which runs the celery worker process +* `celerybeat` which runs the celery beat process + +If you chose the `use_letsencrypt` option, you also have: + +* `certbot` which keeps your certs from letsencrypt up-to-date + +Populate .env With Your Environment Variables +--------------------------------------------- + +Some of these services rely on environment variables set by you. There is an `env.example` file in the root directory of this project as a starting point. Add your own variables to the file and rename it to `.env`. This file won't be tracked by git by default so you'll have to make sure to use some other mechanism to copy your secret if you are relying solely on git. +Optional: nginx-proxy Setup +--------------------------- By default, the application is configured to listen on all interfaces on port 80. If you want to change that, open the -`docker-compose.yml` file and replace `0.0.0.0` with your own ip. If you are using `nginx-proxy`_ to run multiple -application stacks on one host, remove the port setting entirely and add `VIRTUAL_HOST={{cookiecutter.domain_name}}` to your env file. +`docker-compose.yml` file and replace `0.0.0.0` with your own ip. + +If you are using `nginx-proxy`_ to run multiple application stacks on one host, remove the port setting entirely and add `VIRTUAL_HOST=example.com` to your env file. Here, replace example.com with the value you entered for `domain_name`. + This pass all incoming requests on `nginx-proxy`_ to the nginx service your application is using. .. _nginx-proxy: https://github.com/jwilder/nginx-proxy +Optional: Postgres Data Volume Modifications +--------------------------------------------- + Postgres is saving its database files to the `postgres_data` volume by default. Change that if you wan't something else and make sure to make backups since this is not done automatically. +Optional: Certbot and Let's Encrypt Setup +------------------------------------------ + +If you chose `use_letsencrypt` and will be using certbot for https, you must do the following before running anything with docker-compose: + +Replace dhparam.pem.example with a generated dhparams.pem file before running anything with docker-compose. You can generate this on ubuntu or OS X by running the following in the project root: + +:: + + $ openssl dhparam -out /path/to/project/compose/nginx/dhparams.pem 2048 + +If you would like to add additional subdomains to your certificate, you must add additional parameters to the certbot command in the `docker-compose.yml` file: + +Replace: + +:: + + command: bash -c "sleep 6 && certbot certonly -n --standalone -d {{ cookiecutter.domain_name }} --text --agree-tos --email mjsisley@relawgo.com --server https://acme-v01.api.letsencrypt.org/directory --rsa-key-size 4096 --verbose --keep-until-expiring --standalone-supported-challenges http-01" + +With: + +:: + + command: bash -c "sleep 6 && certbot certonly -n --standalone -d {{ cookiecutter.domain_name }} -d www.{{ cookiecutter.domain_name }} -d etc.{{ cookiecutter.domain_name }} --text --agree-tos --email {{ cookiecutter.email }} --server https://acme-v01.api.letsencrypt.org/directory --rsa-key-size 4096 --verbose --keep-until-expiring --standalone-supported-challenges http-01" + +Please be cognizant of Certbot/Letsencrypt certificate requests limits when getting this set up. The provide a test server that does not count against the limit while you are getting set up. + +The certbot certificates expire after 3 months. +If you would like to set up autorenewal of your certificates, the following commands can be put into a bash script: + +:: + + #!/bin/bash + cd + docker-compose run --rm --name certbot certbot bash -c "sleep 6 && certbot certonly --standalone -d {{ cookiecutter.domain_name }} --text --agree-tos --email {{ cookiecutter.email }} --server https://acme-v01.api.letsencrypt.org/directory --rsa-key-size 4096 --verbose --keep-until-expiring --standalone-supported-challenges http-01" + docker exec pearl_nginx_1 nginx -s reload + +And then set a cronjob by running `crontab -e` and placing in it (period can be adjusted as desired):: + + 0 4 * * 1 /path/to/bashscript/renew_certbot.sh + +Run your app with docker-compose +-------------------------------- + To get started, pull your code from source control (don't forget the `.env` file) and change to your projects root directory. @@ -55,7 +110,6 @@ Once this is ready, you can run it with:: docker-compose up - To run a migration, open up a second terminal and run:: docker-compose run django python manage.py migrate @@ -64,7 +118,6 @@ To create a superuser, run:: docker-compose run django python manage.py createsuperuser - If you need a shell, run:: docker-compose run django python manage.py shell @@ -80,8 +133,15 @@ If you want to scale your application, run:: docker-compose scale django=4 docker-compose scale celeryworker=2 +.. warning:: Don't run the scale command on postgres, celerybeat, certbot, or nginx. -**Don't run the scale command on postgres or celerybeat** +If you have errors, you can always check your stack with `docker-compose`. Switch to your projects root directory and run:: + + docker-compose ps + + +Supervisor Example +------------------- Once you are ready with your initial setup, you wan't to make sure that your application is run by a process manager to survive reboots and auto restarts in case of an error. You can use the process manager you are most familiar with. All @@ -97,7 +157,6 @@ If you are using `supervisor`, you can use this file as a starting point:: autorestart=true priority=10 - Place it in `/etc/supervisor/conf.d/{{cookiecutter.project_slug}}.conf` and run:: supervisorctl reread @@ -106,7 +165,3 @@ Place it in `/etc/supervisor/conf.d/{{cookiecutter.project_slug}}.conf` and run: To get the status, run:: supervisorctl status - -If you have errors, you can always check your stack with `docker-compose`. Switch to your projects root directory and run:: - - docker-compose ps diff --git a/docs/developing-locally-docker.rst b/docs/developing-locally-docker.rst index 7f23082af..5e2d9a9c6 100644 --- a/docs/developing-locally-docker.rst +++ b/docs/developing-locally-docker.rst @@ -1,5 +1,5 @@ -Getting Up and Running with Docker -================================== +Getting Up and Running Locally With Docker +========================================== .. index:: Docker @@ -9,40 +9,17 @@ All of these commands assume you are in the root of your generated project. Prerequisites ------------- -You'll need at least docker 1.10. +You'll need at least Docker 1.10. If you don't already have it installed, follow the instructions for your OS: - - On Mac OS X/Windows, you'll need `Docker Toolbox`_ + - On Mac OS X, you'll need `Docker for Mac`_ + - On Windows, you'll need `Docker for Windows`_ - On Linux, you'll need `docker-engine`_ -.. _`Docker Toolbox`: https://github.com/docker/toolbox/releases +.. _`Docker for Mac`: https://docs.docker.com/engine/installation/mac/ +.. _`Docker for Windows`: https://docs.docker.com/engine/installation/windows/ .. _`docker-engine`: https://docs.docker.com/engine/installation/ -Create the Machine (Optional) ------------------------------ - -On Linux you have native Docker, so you don't need to create a VM with -docker-machine to use it. - -However, on Mac/Windows/other systems without native Docker, you'll want to -start by creating a VM with docker-machine:: - - $ docker-machine create --driver virtualbox dev1 - -**Note:** If you want to have more than one docker development environment, then -name them accordingly. Instead of 'dev1' you might have 'dev2', 'myproject', -'djangopackages', et al. - -Get the IP Address ------------------- - -Once your machine is up and running, run this:: - - $ docker-machine ip dev1 - 123.456.789.012 - -This is also the IP address where the Django project will be served from. - Build the Stack --------------- @@ -105,35 +82,6 @@ Production Mode Instead of using `dev.yml`, you would use `docker-compose.yml`. -Database Backups -~~~~~~~~~~~~~~~~ - -The database has to be running to create/restore a backup. - -First, run the app with `docker-compose -f dev.yml up`. - -To create a backup, run:: - - docker-compose -f dev.yml run postgres backup - - -To list backups, run:: - - docker-compose -f dev.yml run postgres list-backups - - -To restore a backup, run:: - - docker-compose -f dev.yml run postgres restore filename.sql - -To copy the files from the running Postgres container to the host system:: - - docker cp :/backups /host/path/target - -Where is the ID of the Postgres container. To get it, run:: - - docker ps - Other Useful Tips ----------------- @@ -155,3 +103,54 @@ If you want to run the stack in detached mode (in the background), use the ``-d` :: $ docker-compose -f dev.yml up -d + +Debugging +~~~~~~~~~~~~~ + +ipdb +""""" + +If you are using the following within your code to debug: + +:: + + import ipdb; ipdb.set_trace() + +Then you may need to run the following for it to work as desired: + +:: + + $ docker-compose run -f dev.yml --service-ports django + + +django-debug-toolbar +"""""""""""""""""""" + +In order for django-debug-toolbar to work with docker you need to add your docker-machine ip address (the output of `Get the IP ADDRESS`_) to INTERNAL_IPS in local.py + + +.. May be a better place to put this, as it is not Docker specific. + +You may need to add the following to your css in order for the django-debug-toolbar to be visible (this applies whether Docker is being used or not): + +.. code-block:: css + + /* Override Bootstrap 4 styling on Django Debug Toolbar */ + #djDebug[hidden], #djDebug [hidden] { + display: block !important; + } + + #djDebug [hidden][style='display: none;'] { + display: none !important; + } + + +Using the Mailhog Docker Container +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +In development you can (optionally) use MailHog_ for email testing. If you selected `use_docker`, MailHog is added as a Docker container. To use MailHog: + +1. Make sure, that ``mailhog`` docker container is up and running +2. Open your browser and go to ``http://127.0.0.1:8025`` + +.. _Mailhog: https://github.com/mailhog/MailHog/ diff --git a/docs/developing-locally.rst b/docs/developing-locally.rst index af4bf94ce..6c84ca3c2 100644 --- a/docs/developing-locally.rst +++ b/docs/developing-locally.rst @@ -9,40 +9,50 @@ The steps below will get you up and running with a local development environment * virtualenv * PostgreSQL -First make sure to create and activate a virtualenv_, then open a terminal at the project root and install the os dependencies:: +First make sure to create and activate a virtualenv_. - $ sudo ./install_os_dependencies.sh install +.. _virtualenv: http://docs.python-guide.org/en/latest/dev/virtualenvs/ Then install the requirements for your local development:: $ pip install -r requirements/local.txt -.. _virtualenv: http://docs.python-guide.org/en/latest/dev/virtualenvs/ - Then, create a PostgreSQL database with the following command, where `[project_slug]` is what value you entered for your project's `project_slug`:: $ createdb [project_slug] -`Cookiecutter Django` uses the excellent `django-environ`_ package with its ``DATABASE_URL`` environment variable to simplify database configuration in your Django settings. Now all you have to do is rename env.example to .env and then compose a definition for ``DATABASE_URL`` as shown below and add it to the .env file: - -.. parsed-literal:: - - $ export DATABASE_URL="postgres://**:**\ @127.0.0.1:\ **/**" - -.. _django-environ: http://django-environ.readthedocs.io - You can now run the usual Django ``migrate`` and ``runserver`` commands:: $ python manage.py migrate $ python manage.py runserver -**Setup your email backend** +At this point you can take a break from setup and start getting to know the files in the project. + +But if you want to go further with setup, read on. + +(Note: the following sections still need to be revised) + +Setting Up Env Vars for Production +----------------------------------- + +`Cookiecutter Django` uses the excellent `django-environ`_ package, which includes a ``DATABASE_URL`` environment variable to simplify database configuration in your Django settings. + +Rename env.example to .env to begin updating the file with your own environment variables. To add your database, define ``DATABASE_URL`` and add it to the .env file, as shown below: + +.. parsed-literal:: + + DATABASE_URL="postgres://**:**\ @127.0.0.1:\ **/**" + +.. _django-environ: http://django-environ.readthedocs.io + +Setup your email backend +------------------------- django-allauth sends an email to verify users (and superusers) after signup and login (if they are still not verified). To send email you need to `configure your email backend`_ .. _configure your email backend: http://docs.djangoproject.com/en/1.9/topics/email/#smtp-backend -In development you can (optionally) use MailHog_ for email testing. MailHog is built with Go so there are no dependencies. To use MailHog:: +In development you can (optionally) use MailHog_ for email testing. MailHog is built with Go so there are no dependencies. To use MailHog: 1. `Download the latest release`_ for your operating system 2. Rename the executable to ``mailhog`` and copy it to the root of your project directory @@ -61,22 +71,6 @@ In production basic email configuration is setup to send emails with Mailgun_ **Live reloading and Sass CSS compilation** -If you'd like to take advantage of live reloading and Sass / Compass CSS compilation you can do so with the included Grunt task. +If you’d like to take advantage of live reloading and Sass / Compass CSS compilation you can do so with a little bit of `prep work`_. -Make sure that nodejs_ is installed. Then in the project root run:: - - $ npm install - -.. _nodejs: http://nodejs.org/download/ - -Now you just need:: - - $ grunt serve - -The base app will now run as it would with the usual ``manage.py runserver`` but with live reloading and Sass compilation enabled. - -To get live reloading to work you'll probably need to install an `appropriate browser extension`_ - -.. _appropriate browser extension: http://feedback.livereload.com/knowledgebase/articles/86242-how-do-i-install-and-use-the-browser-extensions- - -It's time to write the code!!! +.. _prep work: https://cookiecutter-django.readthedocs.io/en/latest/live-reloading-and-sass-compilation.html diff --git a/docs/docker-postgres-backups.rst b/docs/docker-postgres-backups.rst new file mode 100644 index 000000000..6f2a3cc5b --- /dev/null +++ b/docs/docker-postgres-backups.rst @@ -0,0 +1,40 @@ +============================ +Database Backups with Docker +============================ + +The database has to be running to create/restore a backup. These examples show local examples. If you want to use it on a remote server, remove ``-f dev.yml`` from each example. + +Running Backups +================ + +Run the app with `docker-compose -f dev.yml up`. + +To create a backup, run:: + + docker-compose -f dev.yml run postgres backup + + +To list backups, run:: + + docker-compose -f dev.yml run postgres list-backups + + +To restore a backup, run:: + + docker-compose -f dev.yml run postgres restore filename.sql + +Where is the ID of the Postgres container. To get it, run:: + + docker ps + +To copy the files from the running Postgres container to the host system:: + + docker cp :/backups /host/path/target + +Restoring From Backups +====================== + +To restore the production database to a local PostgreSQL database:: + + createdb NAME_OF_DATABASE + psql NAME_OF_DATABASE < NAME_OF_BACKUP_FILE diff --git a/docs/index.rst b/docs/index.rst index beafb44cf..07cedc4ab 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -7,14 +7,11 @@ A Cookiecutter_ template for Django. .. _cookiecutter: https://github.com/audreyr/cookiecutter -.. note:: This is an in-progress documentation reorganization. Locations of files may change dramatically over the course of the next few days. See https://github.com/pydanny/cookiecutter-django/issues/335 - Contents: .. toctree:: :maxdepth: 2 - project-generation-options developing-locally developing-locally-docker @@ -24,7 +21,10 @@ Contents: deployment-on-pythonanywhere deployment-on-heroku deployment-with-docker + docker-postgres-backups faq + troubleshooting + my-favorite-cookie Indices and tables ================== diff --git a/docs/installing_postgres.rst b/docs/installing_postgres.rst new file mode 100644 index 000000000..3b37e8196 --- /dev/null +++ b/docs/installing_postgres.rst @@ -0,0 +1,17 @@ +PostgreSQL Installation Basics +============================== + +.. index:: pip, virtualenv, PostgreSQL + +The steps below will get you up and running with PostgreSQL. This assumes you have pip and virtualenv_ installed. + +.. _virtualenv: http://docs.python-guide.org/en/latest/dev/virtualenvs/ + +On Mac + +Install PostgreSQLapp_ from the browser and move PostGresSQL into your applications folder. Then install PostgreSQL from HomeBrew_. + + $ brew install postgres + +.. _PostgreSQLapp: http://postgresapp.com/ +.. _HomeBrew: http://brew.sh/ \ No newline at end of file diff --git a/docs/my-favorite-cookie.rst b/docs/my-favorite-cookie.rst new file mode 100644 index 000000000..a65833526 --- /dev/null +++ b/docs/my-favorite-cookie.rst @@ -0,0 +1,100 @@ +************************************************ +Creating your first app with Cookiecutter-Django +************************************************ + +This tutorial will show you how to build a simple app using the `Cookiecutter Django `_ templating system. We'll be building a cookie polling app to determine the most popular flavor of cookie. + +Developers who have never used Django will learn the basics of creating a Django app; developers who are experienced with Django will learn how to set up a project within the Cookiecutter system. While many Django tutorials use the default SQLite database, Cookiecutter Django uses PostGres only, so we'll have you install and use that. + + +Dependencies +============ +This tutorial was written on Windows 10 using `git bash `_; alternate instructions for Mac OS and Linux will be provided when needed. Any Linux-style shell should work for the following commands. + +You should have your preferred versions of `Python `_ +and `Django `_ installed. Use the latest stable versions if you have no preference. + +You should have `Virtualenv `_ and `Cookiecutter `_ installed: + +.. code-block:: python + + $ pip install virtualenv + $ pip install cookiecutter + +You should also have `PostgreSQL `_ installed on your machine--just download and run the installer for your OS. The install menu will prompt you for a password, which you'll use when creating the project's database. + + +Instructions +============ + +1. **Setup** -- how to set up a virtual environment +2. **Cookiecutter** -- use Cookiecutter to initialize a project with your own customized information. +3. **Building the App** -- creating the My Favorite Cookie application. + +============ +1. Setup +============ + +Virtual Environment +""""""""""""""""""" + +Create a virtual environment for your project. Cookiecutter will install a bunch of dependencies for you automatically; using a virtualenv will prevent this from interfering with your other work. + +.. code-block:: python + + $ virtualenv c:/.virtualenvs/cookie_polls + +Replace ``c:/.virtualenvs`` with the path to your own ``.virtualenvs`` folder. + +Activate the virtual environment by calling ``source`` on the ``activate`` shell script . On Windows you'll call this from the virtualenv's ``scripts`` folder: + +.. code-block:: python + + $ source /path/to/.virtualenvs/cookie_polls/scripts/activate + +On other operating systems, it'll be found in the ``bin`` folder. + +.. code-block:: python + + $ source /path/to/.virtualenvs/cookie_polls/bin/activate + +You'll know the virtual environment is active because its name will appear in parentheses before the command prompt. When you're done with this project, you can leave the virtual environment with the ``deactivate`` command. + +.. code-block:: python + + (cookie_polls) + $ deactivate + + +Now you're ready to create your project using Cookiecutter. + + +=============== +2. Cookiecutter +=============== + +Django developers may be familiar with the ``startproject`` command, which initializes the directory structure and required files for a bare-bones Django project. While this is fine when you're just learning Django for the first time, it's not great for a real production app. Cookiecutter takes care of a lot of standard tasks for you, including installing software dependencies, setting up testing files, and including and organizing common libraries like Bootstrap and AngularJS. It also generates a software license and a README. + +Change directories into the folder where you want your project to live, and run ``cookiecutter`` followed by the URL of Cookiecutter's Github repo. + +.. code-block:: python + + $ cd /my/project/folder + (cookie_polls) + my/project/folder + $ cookiecutter https://github.com/pydanny/cookiecutter-django + +This will prompt you for a bunch of values specific to your project. Press "enter" without typing anything to use the default values, which are shown in [brackets] after the question. You can learn about all the different options `here, `_ but for now we'll use the defaults for everything but your name, your email, the project's name, and the project's description. + +.. code-block:: python + + project_name [project_name]: My Favorite Cookie + project_slug [My_Favorite_Cookie]: + author_name [Your Name]: Emily Cain + email [Your email]: contact@emcain.net + description [A short description of the project.]: Poll your friends to determine the most popular cookie. + +Then hit "enter" to use the default values for everything else. + + + diff --git a/docs/project-generation-options.rst b/docs/project-generation-options.rst index 9ffad1e5f..c2b14e874 100644 --- a/docs/project-generation-options.rst +++ b/docs/project-generation-options.rst @@ -37,19 +37,75 @@ use_celery [n] use_mailhog [n] Whether to use MailHog_. MailHog is a tool that simulates email receiving for development purposes. It runs a simple SMTP server which catches - any message sent to it. Messages are displayed in a web interface which runs at ``http://localhost:8025/`` You need to download the MailHog executable for your operating system, see the 'Developing Locally' docs for instructions. + any message sent to it. Messages are displayed in a web interface which + runs at ``http://localhost:8025/`` You need to download the MailHog + executable for your operating system, see the 'Developing Locally' docs + for instructions. -use_sentry [n] +use_sentry_for_error_reporting [n] Whether to use Sentry_ to log errors from your project. +use_opbeat [n] + Whether to use Opbeat_ for preformance monitoring and code optimization. + +use_pycharm [n] + Adds support for developing in PyCharm_ with a preconfigured .idea directory. + windows [n] Whether you'll be developing on Windows. -use_python2 [n] +use_python3 [y] By default, the Python code generated will be for Python 3.x. But if you - answer `y` here, it will be legacy Python 2.7 code. + answer `n` here, it will be legacy Python 2.7 code. + +use_docker [y] + Whether to use Docker_, separating the app and database into separate + containers. + +use_heroku [n] + Add configuration to deploy the application to a Heroku_ instance. + +use_compressor [n] + Use `Django Compressor`_ to minify and combine rendered JavaScript and CSS + into cachable static resources. + +js_task_runner [1] + Select a JavaScript task runner. The choices are: + + 1. Gulp_ + 2. Grunt_ + 3. Webpack_ + 4. None + +use_lets_encrypt [n] + Use `Let's Encrypt`_ as the certificate authority for this project. + +open_source_license [1] + Select a software license for the project. The choices are: + + 1. MIT_ + 2. BSD_ + 3. GPLv3_ + 4. `Apache Software License 2.0`_ + 5. Not open source + +**NOTE:** *If you choose to use Docker, selecting a JavaScript task runner is +not supported out of the box.* .. _WhiteNoise: https://github.com/evansd/whitenoise .. _Celery: https://github.com/celery/celery .. _MailHog: https://github.com/mailhog/MailHog .. _Sentry: https://github.com/getsentry/sentry +.. _Opbeat: https://github.com/opbeat/opbeat_python +.. _PyCharm: https://www.jetbrains.com/pycharm/ +.. _Docker: https://github.com/docker/docker +.. _Heroku: https://github.com/heroku/heroku-buildpack-python +.. _Django Compressor: https://github.com/django-compressor/django-compressor +.. _Gulp: https://github.com/gulpjs/gulp +.. _Grunt: https://github.com/gruntjs/grunt +.. _Webpack: https://github.com/webpack/webpack +.. _Let's Encrypt: https://github.com/certbot/certbot +.. _MIT: https://opensource.org/licenses/MIT +.. _BSD: https://opensource.org/licenses/BSD-3-Clause +.. _GPLv3: https://www.gnu.org/licenses/gpl.html +.. _Apache Software License 2.0: http://www.apache.org/licenses/LICENSE-2.0 diff --git a/docs/troubleshooting.rst b/docs/troubleshooting.rst new file mode 100644 index 000000000..fe121b9cd --- /dev/null +++ b/docs/troubleshooting.rst @@ -0,0 +1,9 @@ +Troubleshooting +===================================== + +This page contains some advice about errors and problems commonly encountered during the development of Cookiecutter Django applications. + +#. If you get the error ``jinja2.exceptions.TemplateSyntaxError: Encountered unknown tag 'now'.`` , please upgrade your cookiecutter version to >= 1.4 (see issue # 528_ ) +#. ``project_slug`` must be a valid Python module name or you will have issues on imports. + +.. _528: https://github.com/pydanny/cookiecutter-django/issues/528#issuecomment-212650373 \ No newline at end of file diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 5c2e3ed69..dd6a3f07d 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -82,6 +82,11 @@ def make_secret_key(project_directory): set_secret_key(env_file) +def remove_file(file_name): + if os.path.exists(file_name): + os.remove(file_name) + + def remove_task_app(project_directory): """Removes the taskapp if celery isn't going to be used""" # Determine the local_setting_file_location @@ -111,9 +116,8 @@ def remove_heroku_files(): Removes files needed for heroku if it isn't going to be used """ for filename in ["app.json", "Procfile", "requirements.txt", "runtime.txt"]: - os.remove(os.path.join( - PROJECT_DIRECTORY, filename - )) + file_name = os.path.join(PROJECT_DIRECTORY, filename) + remove_file(file_name) def remove_docker_files(): @@ -134,7 +138,43 @@ def remove_grunt_files(): """ Removes files needed for grunt if it isn't going to be used """ - for filename in ["Gruntfile.js", "package.json"]: + for filename in ["Gruntfile.js"]: + os.remove(os.path.join( + PROJECT_DIRECTORY, filename + )) + +def remove_gulp_files(): + """ + Removes files needed for grunt if it isn't going to be used + """ + for filename in ["gulpfile.js"]: + os.remove(os.path.join( + PROJECT_DIRECTORY, filename + )) + +def remove_packageJSON_file(): + """ + Removes files needed for grunt if it isn't going to be used + """ + for filename in ["package.json"]: + os.remove(os.path.join( + PROJECT_DIRECTORY, filename + )) + +def remove_certbot_files(): + """ + Removes files needed for certbot if it isn't going to be used + """ + nginx_dir_location = os.path.join(PROJECT_DIRECTORY, 'compose/nginx') + for filename in ["nginx-secure.conf", "start.sh", "dhparams.example.pem"]: + file_name = os.path.join(nginx_dir_location, filename) + remove_file(file_name) + +def remove_copying_files(): + """ + Removes files needed for the GPLv3 licence if it isn't going to be used + """ + for filename in ["COPYING"]: os.remove(os.path.join( PROJECT_DIRECTORY, filename )) @@ -176,19 +216,47 @@ if '{{ cookiecutter.use_heroku }}'.lower() != 'y': if '{{ cookiecutter.use_docker }}'.lower() != 'y': remove_docker_files() -# 6. Removes all grunt files if it isn't going to be used -if '{{ cookiecutter.use_grunt }}'.lower() != 'y': +# 6. Removes all JS task manager files if it isn't going to be used +if '{{ cookiecutter.js_task_runner}}'.lower() == 'gulp': remove_grunt_files() +elif '{{ cookiecutter.js_task_runner}}'.lower() == 'grunt': + remove_gulp_files() +else: + remove_gulp_files() + remove_grunt_files() + remove_packageJSON_file() +# 7. Removes all certbot/letsencrypt files if it isn't going to be used +if '{{ cookiecutter.use_lets_encrypt }}'.lower() != 'y': + remove_certbot_files() -# 7. Display a warning if use_docker and use_grunt are selected. Grunt isn't supported by our -# docker config atm. -if '{{ cookiecutter.use_grunt }}'.lower() == 'y' and '{{ cookiecutter.use_docker }}'.lower() == 'y': +# 8. Display a warning if use_docker and use_grunt are selected. Grunt isn't +# supported by our docker config atm. +if '{{ cookiecutter.js_task_runner }}'.lower() in ['grunt', 'gulp'] and '{{ cookiecutter.use_docker }}'.lower() == 'y': print( - "You selected to use docker and grunt. This is NOT supported out of the box for now. You " + "You selected to use docker and a JS task runner. This is NOT supported out of the box for now. You " "can continue to use the project like you normally would, but you will need to add a " - " grunt service to your docker configuration manually." + "js task runner service to your docker configuration manually." ) +# 9. Removes the certbot/letsencrypt files and display a warning if use_lets_encrypt is selected and use_docker isn't. +if '{{ cookiecutter.use_lets_encrypt }}'.lower() == 'y' and '{{ cookiecutter.use_docker }}'.lower() != 'y': + remove_certbot_files() + print( + "You selected to use Let's Encrypt and didn't select to use docker. This is NOT supported out of the box for now. You " + "can continue to use the project like you normally would, but Let's Encrypt files have been included." + ) + +# 10. Directs the user to the documentation if certbot and docker are selected. +if '{{ cookiecutter.use_lets_encrypt }}'.lower() == 'y' and '{{ cookiecutter.use_docker }}'.lower() == 'y': + print( + "You selected to use Let's Encrypt, please see the documentation for instructions on how to use this in production. " + "You must generate a dhparams.pem file before running docker-compose in a production environment." + ) + +# 11. Removes files needed for the GPLv3 licence if it isn't going to be used. +if '{{ cookiecutter.open_source_license}}' != 'GPLv3': + remove_copying_files() + # 4. Copy files from /docs/ to {{ cookiecutter.project_slug }}/docs/ # copy_doc_files(PROJECT_DIRECTORY) diff --git a/hooks/pre_gen_project.py b/hooks/pre_gen_project.py index 3dfc190a2..9cd168bce 100644 --- a/hooks/pre_gen_project.py +++ b/hooks/pre_gen_project.py @@ -1,8 +1,6 @@ -import cookiecutter - project_slug = '{{ cookiecutter.project_slug }}' if hasattr(project_slug, 'isidentifier'): assert project_slug.isidentifier(), 'Project slug should be valid Python identifier!' -assert cookiecutter.__version__ > '1.3.0', 'Please upgrade your Cookiecutter installation' + diff --git a/requirements.txt b/requirements.txt index d63bed873..c0665d454 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,11 +1,11 @@ cookiecutter==1.4.0 -flake8==2.5.4 +flake8==3.0.4 # pyup: != 2.6.0 sh==1.11 binaryornot==0.4.0 # Testing -pytest==2.9.1 +pytest==3.0.2 pep8==1.7.0 -pyflakes==1.2.3 +pyflakes==1.3.0 tox==2.3.1 pytest-cookies==0.2.0 diff --git a/requirements_to_watch.txt b/requirements_to_watch.txt new file mode 100644 index 000000000..3e25cb204 --- /dev/null +++ b/requirements_to_watch.txt @@ -0,0 +1,2 @@ +# These requirements prevented an upgrade to Django 1.10. +django-coverage-plugin==1.3.1 diff --git a/setup.py b/setup.py index e52d1b3b1..469e173c7 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 = '1.9.6' +version = '1.9.9-03' if sys.argv[-1] == 'tag': os.system('git tag -a %s -m "version %s"' % (version, version)) diff --git a/tests/test_cookiecutter_generation.py b/tests/test_cookiecutter_generation.py index 6815751a8..e0e06ce6a 100644 --- a/tests/test_cookiecutter_generation.py +++ b/tests/test_cookiecutter_generation.py @@ -22,8 +22,6 @@ def context(): 'domain_name': 'example.com', 'version': '0.1.0', 'timezone': 'UTC', - 'now': '2015/01/13', - 'year': '2015' } diff --git a/tox.ini b/tox.ini index deb1dd503..d2cfed18c 100644 --- a/tox.ini +++ b/tox.ini @@ -6,7 +6,7 @@ envlist = py27,py34,py35 passenv = LC_ALL, LANG, HOME deps = binaryornot - flake8 + flake8==2.5.5 pytest-cookies sh commands = py.test {posargs:tests} diff --git a/{{cookiecutter.project_slug}}/.travis.yml b/{{cookiecutter.project_slug}}/.travis.yml index befee8783..4001cbe3a 100644 --- a/{{cookiecutter.project_slug}}/.travis.yml +++ b/{{cookiecutter.project_slug}}/.travis.yml @@ -8,7 +8,7 @@ before_install: - sudo apt-get install -qq libsqlite3-dev libxml2 libxml2-dev libssl-dev libbz2-dev wget curl llvm language: python python: -{% if cookiecutter.use_python2 == 'n' -%} +{% if cookiecutter.use_python3 == 'y' -%} - "3.5" {% else %} - "2.7" diff --git a/{{cookiecutter.project_slug}}/CONTRIBUTORS.txt b/{{cookiecutter.project_slug}}/CONTRIBUTORS.txt index 25e9ec56f..82a80bfc1 100644 --- a/{{cookiecutter.project_slug}}/CONTRIBUTORS.txt +++ b/{{cookiecutter.project_slug}}/CONTRIBUTORS.txt @@ -1 +1 @@ -{{cookiecutter.author_name}} +{{ cookiecutter.author_name }} diff --git a/{{cookiecutter.project_slug}}/COPYING b/{{cookiecutter.project_slug}}/COPYING new file mode 100644 index 000000000..94a9ed024 --- /dev/null +++ b/{{cookiecutter.project_slug}}/COPYING @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + 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 . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/{{cookiecutter.project_slug}}/LICENSE b/{{cookiecutter.project_slug}}/LICENSE index e6d8e8103..3a6c7e13a 100644 --- a/{{cookiecutter.project_slug}}/LICENSE +++ b/{{cookiecutter.project_slug}}/LICENSE @@ -1,6 +1,6 @@ {% if cookiecutter.open_source_license == 'MIT' %} The MIT License (MIT) -Copyright (c) {{ cookiecutter.year }}, {{ cookiecutter.author_name }} +Copyright (c) {% now 'utc', '%Y' %}, {{ cookiecutter.author_name }} Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: @@ -8,7 +8,7 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. {% elif cookiecutter.open_source_license == 'BSD' %} -Copyright (c) {{ cookiecutter.year }}, {{ cookiecutter.author_name }} +Copyright (c) {% now 'utc', '%Y' %}, {{ cookiecutter.author_name }} All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -35,4 +35,19 @@ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +{% elif cookiecutter.open_source_license == 'GPLv3' %} +Copyright (c) {% now 'utc', '%Y' %}, {{ cookiecutter.author_name }} + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +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 . {% endif %} diff --git a/{{cookiecutter.project_slug}}/Procfile b/{{cookiecutter.project_slug}}/Procfile index a5476341a..c77d76d96 100644 --- a/{{cookiecutter.project_slug}}/Procfile +++ b/{{cookiecutter.project_slug}}/Procfile @@ -1,4 +1,4 @@ web: gunicorn config.wsgi:application {% if cookiecutter.use_celery == "y" -%} -worker: {% if cookiecutter.use_newrelic == "y" %}newrelic-admin run-program {% endif %}celery worker --app={{cookiecutter.project_slug}}.taskapp --loglevel=info +worker: celery worker --app={{cookiecutter.project_slug}}.taskapp --loglevel=info {%- endif %} diff --git a/{{cookiecutter.project_slug}}/README.rst b/{{cookiecutter.project_slug}}/README.rst index 38d923b66..f760a1e2c 100644 --- a/{{cookiecutter.project_slug}}/README.rst +++ b/{{cookiecutter.project_slug}}/README.rst @@ -1,18 +1,18 @@ {{cookiecutter.project_name}} -============================== +{{ '=' * cookiecutter.project_name|length }} {{cookiecutter.description}} .. image:: https://img.shields.io/badge/built%20with-Cookiecutter%20Django-ff69b4.svg :target: https://github.com/pydanny/cookiecutter-django/ :alt: Built with Cookiecutter Django - {% if cookiecutter.open_source_license != "Not open source" %} -LICENSE: {{cookiecutter.open_source_license}} + +:License: {{cookiecutter.open_source_license}} {% endif %} Settings ------------- +-------- Moved to settings_. @@ -42,7 +42,7 @@ To run the tests, check your test coverage, and generate an HTML coverage report $ open htmlcov/index.html Running tests with py.test -~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~ :: @@ -72,7 +72,6 @@ To run a celery worker: Please note: For Celery's import magic to work, it is important *where* the celery commands are run. If you are in the same folder with *manage.py*, you should be right. {% endif %} - {% if cookiecutter.use_mailhog == "y" %} Email Server @@ -103,23 +102,21 @@ To view messages that are sent by your application, open your browser and go to The email server will exit when you exit the Grunt task on the CLI with Ctrl+C. {% endif %} {% endif %} - -{% if cookiecutter.use_sentry == "y" %} +{% if cookiecutter.use_sentry_for_error_reporting == "y" %} Sentry ^^^^^^ -Sentry is an error logging aggregator service. You can sign up for a free account at http://getsentry.com or download and host it yourself. +Sentry is an error logging aggregator service. You can sign up for a free account at https://getsentry.com/signup/?code=cookiecutter or download and host it yourself. The system is setup with reasonable defaults, including 404 logging and integration with the WSGI application. You must set the DSN url in production. - {% endif %} - Deployment ---------- +The following details how to deploy this application. {% if cookiecutter.use_heroku == "y" %} Heroku @@ -131,9 +128,7 @@ Heroku See detailed `cookiecutter-django Heroku documentation`_. .. _`cookiecutter-django Heroku documentation`: http://cookiecutter-django.readthedocs.io/en/latest/deployment-on-heroku.html - {% endif %} - {% if cookiecutter.use_docker == "y" %} Docker @@ -142,5 +137,4 @@ Docker See detailed `cookiecutter-django Docker documentation`_. .. _`cookiecutter-django Docker documentation`: http://cookiecutter-django.readthedocs.io/en/latest/deployment-with-docker.html - {% endif %} diff --git a/{{cookiecutter.project_slug}}/app.json b/{{cookiecutter.project_slug}}/app.json index 6e6585fd7..96ab574f4 100644 --- a/{{cookiecutter.project_slug}}/app.json +++ b/{{cookiecutter.project_slug}}/app.json @@ -20,18 +20,19 @@ "DJANGO_AWS_SECRET_ACCESS_KEY": "", "DJANGO_AWS_STORAGE_BUCKET_NAME": "", "DJANGO_MAILGUN_SERVER_NAME": "", - {% if cookiecutter.use_newrelic == "y" -%} - "NEW_RELIC_LICENSE_KEY": "", - "NEW_RELIC_APP_NAME": "", - {%- endif %} - "DJANGO_MAILGUN_API_KEY": ""{% if cookiecutter.use_sentry == "y" -%}, - "DJANGO_SENTRY_DSN": ""{%- endif %} + "DJANGO_MAILGUN_API_KEY": ""{% if cookiecutter.use_sentry_for_error_reporting == "y" -%}, + "DJANGO_SENTRY_DSN": ""{%- endif %} }, "scripts": { "postdeploy": "python manage.py migrate" }, "addons": [ - "heroku-postgresql:hobby-dev", + { + "plan": "heroku-postgresql:hobby-dev", + "options": { + "version": "{{ cookiecutter.postgresql_version }}" + } + }, "heroku-redis:hobby-dev", "mailgun" ] diff --git a/{{cookiecutter.project_slug}}/compose/django/Dockerfile b/{{cookiecutter.project_slug}}/compose/django/Dockerfile index f2f662d5d..91c2297dd 100644 --- a/{{cookiecutter.project_slug}}/compose/django/Dockerfile +++ b/{{cookiecutter.project_slug}}/compose/django/Dockerfile @@ -1,4 +1,4 @@ -{% if cookiecutter.use_python2 == 'n' -%} +{% if cookiecutter.use_python3 == 'y' -%} FROM python:3.5 {% else %} FROM python:2.7 @@ -8,18 +8,21 @@ ENV PYTHONUNBUFFERED 1 # Requirements have to be pulled and installed here, otherwise caching won't work COPY ./requirements /requirements -RUN pip install -r /requirements/production.txt +RUN pip install -r /requirements/production.txt \ + && groupadd -r django \ + && useradd -r -g django django -RUN groupadd -r django && useradd -r -g django django COPY . /app RUN chown -R django /app COPY ./compose/django/gunicorn.sh /gunicorn.sh COPY ./compose/django/entrypoint.sh /entrypoint.sh -RUN sed -i 's/\r//' /entrypoint.sh -RUN sed -i 's/\r//' /gunicorn.sh -RUN chmod +x /entrypoint.sh && chown django /entrypoint.sh -RUN chmod +x /gunicorn.sh && chown django /gunicorn.sh +RUN sed -i 's/\r//' /entrypoint.sh \ + && sed -i 's/\r//' /gunicorn.sh \ + && chmod +x /entrypoint.sh \ + && chown django /entrypoint.sh \ + && chmod +x /gunicorn.sh \ + && chown django /gunicorn.sh WORKDIR /app diff --git a/{{cookiecutter.project_slug}}/compose/django/Dockerfile-dev b/{{cookiecutter.project_slug}}/compose/django/Dockerfile-dev index c3f54a9e3..3390aa098 100644 --- a/{{cookiecutter.project_slug}}/compose/django/Dockerfile-dev +++ b/{{cookiecutter.project_slug}}/compose/django/Dockerfile-dev @@ -1,4 +1,4 @@ -{% if cookiecutter.use_python2 == 'n' -%} +{% if cookiecutter.use_python3 == 'y' -%} FROM python:3.5 {% else %} FROM python:2.7 @@ -13,6 +13,10 @@ COPY ./compose/django/entrypoint.sh /entrypoint.sh RUN sed -i 's/\r//' /entrypoint.sh RUN chmod +x /entrypoint.sh +COPY ./compose/django/start-dev.sh /start-dev.sh +RUN sed -i 's/\r//' /start-dev.sh +RUN chmod +x /start-dev.sh + WORKDIR /app ENTRYPOINT ["/entrypoint.sh"] diff --git a/{{cookiecutter.project_slug}}/compose/django/entrypoint.sh b/{{cookiecutter.project_slug}}/compose/django/entrypoint.sh index e9286baa5..9fe7f5c88 100644 --- a/{{cookiecutter.project_slug}}/compose/django/entrypoint.sh +++ b/{{cookiecutter.project_slug}}/compose/django/entrypoint.sh @@ -1,5 +1,7 @@ #!/bin/bash set -e +cmd="$@" + # This entrypoint is used to play nicely with the current cookiecutter configuration. # Since docker-compose relies heavily on environment variables itself for configuration, we'd have to define multiple # environment variables just to support cookiecutter out of the box. That makes no sense, so this little entrypoint @@ -15,4 +17,23 @@ export DATABASE_URL=postgres://$POSTGRES_USER:$POSTGRES_PASSWORD@postgres:5432/$ {% if cookiecutter.use_celery == 'y' %} export CELERY_BROKER_URL=$REDIS_URL/0 {% endif %} -exec "$@" + +function postgres_ready(){ +python << END +import sys +import psycopg2 +try: + conn = psycopg2.connect(dbname="$POSTGRES_USER", user="$POSTGRES_USER", password="$POSTGRES_PASSWORD", host="postgres") +except psycopg2.OperationalError: + sys.exit(-1) +sys.exit(0) +END +} + +until postgres_ready; do + >&2 echo "Postgres is unavailable - sleeping" + sleep 1 +done + +>&2 echo "Postgres is up - continuing..." +exec $cmd diff --git a/{{cookiecutter.project_slug}}/compose/django/start-dev.sh b/{{cookiecutter.project_slug}}/compose/django/start-dev.sh new file mode 100644 index 000000000..04e06981f --- /dev/null +++ b/{{cookiecutter.project_slug}}/compose/django/start-dev.sh @@ -0,0 +1,3 @@ +#!/bin/sh +python manage.py migrate +python manage.py runserver_plus 0.0.0.0:8000 diff --git a/{{cookiecutter.project_slug}}/compose/nginx/Dockerfile b/{{cookiecutter.project_slug}}/compose/nginx/Dockerfile index 196395763..7ab10d4d6 100644 --- a/{{cookiecutter.project_slug}}/compose/nginx/Dockerfile +++ b/{{cookiecutter.project_slug}}/compose/nginx/Dockerfile @@ -1,2 +1,9 @@ FROM nginx:latest -ADD nginx.conf /etc/nginx/nginx.conf \ No newline at end of file +ADD nginx.conf /etc/nginx/nginx.conf + +{% if cookiecutter.use_lets_encrypt == 'y' and cookiecutter.use_docker == 'y' %} +ADD start.sh /start.sh +ADD nginx-secure.conf /etc/nginx/nginx-secure.conf +ADD dhparams.pem /etc/ssl/private/dhparams.pem +CMD /start.sh +{% endif %} diff --git a/{{cookiecutter.project_slug}}/compose/nginx/dhparams.example.pem b/{{cookiecutter.project_slug}}/compose/nginx/dhparams.example.pem new file mode 100755 index 000000000..e88d8123f --- /dev/null +++ b/{{cookiecutter.project_slug}}/compose/nginx/dhparams.example.pem @@ -0,0 +1,3 @@ +-----BEGIN DH PARAMETERS----- +EXAMPLE_FILE +-----END DH PARAMETERS----- diff --git a/{{cookiecutter.project_slug}}/compose/nginx/nginx-secure.conf b/{{cookiecutter.project_slug}}/compose/nginx/nginx-secure.conf new file mode 100755 index 000000000..cd0fe9a38 --- /dev/null +++ b/{{cookiecutter.project_slug}}/compose/nginx/nginx-secure.conf @@ -0,0 +1,96 @@ +user nginx; +worker_processes 1; + +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; + + +events { + worker_connections 1024; +} + +http { + + include /etc/nginx/mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + + sendfile on; + #tcp_nopush on; + + keepalive_timeout 65; + + proxy_headers_hash_bucket_size 52; + + gzip on; + + upstream app { + server django:5000; + } + server { + listen 80; + server_name ___my.example.com___ www.___my.example.com___; + + location /.well-known/acme-challenge { + # Since the certbot container isn't up constantly, need to resolve ip dynamically using docker's dns + resolver ___NAMESERVER___; + set $certbot_addr_port certbot:80; + proxy_pass http://$certbot_addr_port; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location / { + return 301 https://$server_name$request_uri; + } + + } + + server { + listen 443; + server_name ___my.example.com___ www.___my.example.com___; + + ssl on; + ssl_certificate /etc/letsencrypt/live/___my.example.com___/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/___my.example.com___/privkey.pem; + ssl_session_timeout 5m; + ssl_protocols TLSv1 TLSv1.1 TLSv1.2; + ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH'; + ssl_prefer_server_ciphers on; + + ssl_session_cache shared:SSL:10m; + ssl_dhparam /etc/ssl/private/dhparams.pem; + + location /.well-known/acme-challenge { + resolver ___NAMESERVER___; + set $certbot_addr_port certbot:443; + proxy_pass http://$certbot_addr_port; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header X-Forwarded-Proto https; + } + + location / { + # checks for static file, if not found proxy to app + try_files $uri @proxy_to_app; + } + + # cookiecutter-django app + location @proxy_to_app { + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $http_host; + proxy_redirect off; + + proxy_pass http://app; + + } + + } + +} diff --git a/{{cookiecutter.project_slug}}/compose/nginx/nginx.conf b/{{cookiecutter.project_slug}}/compose/nginx/nginx.conf index 720b22e5b..5d7faa394 100644 --- a/{{cookiecutter.project_slug}}/compose/nginx/nginx.conf +++ b/{{cookiecutter.project_slug}}/compose/nginx/nginx.conf @@ -9,9 +9,9 @@ events { worker_connections 1024; } - http { - include /etc/nginx/mime.types; + + include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' @@ -31,23 +31,40 @@ http { server django:5000; } - server { - listen 80; - charset utf-8; + server { + listen 80; + charset utf-8; + {% if cookiecutter.use_lets_encrypt == 'y' and cookiecutter.use_docker == 'y' %} + server_name ___my.example.com___ ; - location / { + location /.well-known/acme-challenge { + proxy_pass http://certbot:80; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header X-Forwarded-Proto https; + } + + {% endif %} + + location / { # checks for static file, if not found proxy to app try_files $uri @proxy_to_app; } - location @proxy_to_app { + + # cookiecutter-django app + location @proxy_to_app { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://app; - } - } -} \ No newline at end of file + } + } +} + + + + diff --git a/{{cookiecutter.project_slug}}/compose/nginx/start.sh b/{{cookiecutter.project_slug}}/compose/nginx/start.sh new file mode 100755 index 000000000..fa40ed9ab --- /dev/null +++ b/{{cookiecutter.project_slug}}/compose/nginx/start.sh @@ -0,0 +1,62 @@ +echo sleep 5 +sleep 5 + +echo build starting nginx config + + +echo replacing ___my.example.com___/$MY_DOMAIN_NAME + +# Put your domain name into the nginx reverse proxy config. +sed -i "s/___my.example.com___/$MY_DOMAIN_NAME/g" /etc/nginx/nginx.conf + +cat /etc/nginx/nginx.conf +echo . +echo Firing up nginx in the background. +nginx + +# # Check user has specified domain name +if [ -z "$MY_DOMAIN_NAME" ]; then + echo "Need to set MY_DOMAIN_NAME (to a letsencrypt-registered name)." + exit 1 +fi + +# This bit waits until the letsencrypt container has done its thing. +# We see the changes here bceause there's a docker volume mapped. +echo Waiting for folder /etc/letsencrypt/live/$MY_DOMAIN_NAME to exist +while [ ! -d /etc/letsencrypt/live/$MY_DOMAIN_NAME ] ; +do + sleep 2 +done + +while [ ! -f /etc/letsencrypt/live/$MY_DOMAIN_NAME/fullchain.pem ] ; +do + echo Waiting for file fullchain.pem to exist + sleep 2 +done + +while [ ! -f /etc/letsencrypt/live/$MY_DOMAIN_NAME/privkey.pem ] ; +do + echo Waiting for file privkey.pem to exist + sleep 2 +done + +# This is added so that when the certificate is being renewed or is already in place, nginx waits for everything to be good. +sleep 15 + +echo replacing ___my.example.com___/$MY_DOMAIN_NAME + + +# Put your domain name into the nginx reverse proxy config. +sed -i "s/___my.example.com___/$MY_DOMAIN_NAME/g" /etc/nginx/nginx-secure.conf + +# Add the system's nameserver (the docker network dns) so we can resolve container names in nginx +NAMESERVER=`cat /etc/resolv.conf | grep "nameserver" | awk '{print $2}' | tr '\n' ' '` +echo replacing ___NAMESERVER___/$NAMESERVER +sed -i "s/___NAMESERVER___/$NAMESERVER/g" /etc/nginx/nginx-secure.conf + + +#go! +kill $(ps aux | grep 'nginx' | grep -v 'grep' | awk '{print $2}') +cp /etc/nginx/nginx-secure.conf /etc/nginx/nginx.conf + +nginx -g 'daemon off;' diff --git a/{{cookiecutter.project_slug}}/compose/postgres/Dockerfile b/{{cookiecutter.project_slug}}/compose/postgres/Dockerfile index 332723640..9cdaaba30 100644 --- a/{{cookiecutter.project_slug}}/compose/postgres/Dockerfile +++ b/{{cookiecutter.project_slug}}/compose/postgres/Dockerfile @@ -1,4 +1,4 @@ -FROM postgres:9.5 +FROM postgres:{{ cookiecutter.postgresql_version }} # add backup scripts ADD backup.sh /usr/local/bin/backup diff --git a/{{cookiecutter.project_slug}}/compose/postgres/backup.sh b/{{cookiecutter.project_slug}}/compose/postgres/backup.sh index 97c95e1df..47f7a5140 100644 --- a/{{cookiecutter.project_slug}}/compose/postgres/backup.sh +++ b/{{cookiecutter.project_slug}}/compose/postgres/backup.sh @@ -16,7 +16,7 @@ export PGPASSWORD=$POSTGRES_PASSWORD echo "creating backup" echo "---------------" -FILENAME=backup_$(date +'%Y_%m_%dT%H_%M_%S').sql -pg_dump -h postgres -U $POSTGRES_USER >> /backups/$FILENAME +FILENAME=backup_$(date +'%Y_%m_%dT%H_%M_%S').sql.gz +pg_dump -h postgres -U $POSTGRES_USER | gzip > /backups/$FILENAME echo "successfully created backup $FILENAME" diff --git a/{{cookiecutter.project_slug}}/compose/postgres/restore.sh b/{{cookiecutter.project_slug}}/compose/postgres/restore.sh index 750082803..0ac8d1e07 100644 --- a/{{cookiecutter.project_slug}}/compose/postgres/restore.sh +++ b/{{cookiecutter.project_slug}}/compose/postgres/restore.sh @@ -53,4 +53,4 @@ createdb -h postgres -U $POSTGRES_USER $POSTGRES_USER -O $POSTGRES_USER # restore the database echo "restoring database $POSTGRES_USER" -psql -h postgres -U $POSTGRES_USER < $BACKUPFILE +gunzip -c $BACKUPFILE | psql -h postgres -U $POSTGRES_USER diff --git a/{{cookiecutter.project_slug}}/config/settings/common.py b/{{cookiecutter.project_slug}}/config/settings/common.py index 3668b4274..c9433416c 100644 --- a/{{cookiecutter.project_slug}}/config/settings/common.py +++ b/{{cookiecutter.project_slug}}/config/settings/common.py @@ -43,7 +43,8 @@ THIRD_PARTY_APPS = ( # Apps specific for this project go here. LOCAL_APPS = ( - '{{ cookiecutter.project_slug }}.users', # custom users app + # custom users app + '{{ cookiecutter.project_slug }}.users.apps.UsersConfig', # Your stuff: custom apps go here ) @@ -53,7 +54,7 @@ INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS # MIDDLEWARE CONFIGURATION # ------------------------------------------------------------------------------ MIDDLEWARE_CLASSES = ( - # Make sure djangosecure.middleware.SecurityMiddleware is listed first + 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', @@ -98,7 +99,6 @@ MANAGERS = ADMINS # ------------------------------------------------------------------------------ # See: https://docs.djangoproject.com/en/dev/ref/settings/#databases DATABASES = { - # Raises ImproperlyConfigured exception if DATABASE_URL not in os.environ 'default': env.db('DATABASE_URL', default='postgres://{% if cookiecutter.windows == 'y' %}localhost{% endif %}/{{cookiecutter.project_slug}}'), } DATABASES['default']['ATOMIC_REQUESTS'] = True @@ -164,7 +164,7 @@ TEMPLATES = [ ] # See: http://django-crispy-forms.readthedocs.io/en/latest/install.html#template-packs -CRISPY_TEMPLATE_PACK = 'bootstrap3' +CRISPY_TEMPLATE_PACK = 'bootstrap4' # STATIC FILE CONFIGURATION # ------------------------------------------------------------------------------ @@ -230,10 +230,22 @@ INSTALLED_APPS += ('{{cookiecutter.project_slug}}.taskapp.celery.CeleryConfig',) # if you are not using the django database broker (e.g. rabbitmq, redis, memcached), you can remove the next line. INSTALLED_APPS += ('kombu.transport.django',) BROKER_URL = env('CELERY_BROKER_URL', default='django://') +if BROKER_URL == 'django://': + CELERY_RESULT_BACKEND = 'redis://' +else: + CELERY_RESULT_BACKEND = BROKER_URL ########## END CELERY {% endif %} +{%- if cookiecutter.use_compressor == 'y'-%} +# django-compressor +# ------------------------------------------------------------------------------ +INSTALLED_APPS += ("compressor", ) +STATICFILES_FINDERS += ("compressor.finders.CompressorFinder", ) +{%- endif %} + # Location of root django.contrib.admin URL, use {% raw %}{% url 'admin:index' %}{% endraw %} ADMIN_URL = r'^admin/' # Your common stuff: Below this line define 3rd party library settings +# ------------------------------------------------------------------------------ diff --git a/{{cookiecutter.project_slug}}/config/settings/local.py b/{{cookiecutter.project_slug}}/config/settings/local.py index 8dfd1b323..ac7ad0589 100644 --- a/{{cookiecutter.project_slug}}/config/settings/local.py +++ b/{{cookiecutter.project_slug}}/config/settings/local.py @@ -3,11 +3,17 @@ Local settings - Run in Debug mode +{% if cookiecutter.use_mailhog == 'y' and cookiecutter.use_docker == 'y' %} +- Use mailhog for emails +{% else %} - Use console backend for emails +{% endif %} - Add Django Debug Toolbar - Add django-extensions as app """ +import socket +import os from .common import * # noqa # DEBUG @@ -49,7 +55,11 @@ CACHES = { MIDDLEWARE_CLASSES += ('debug_toolbar.middleware.DebugToolbarMiddleware',) INSTALLED_APPS += ('debug_toolbar', ) -INTERNAL_IPS = ('127.0.0.1', '10.0.2.2',) +INTERNAL_IPS = ['127.0.0.1', '10.0.2.2', ] +# tricks to have debug toolbar when developing with docker +if os.environ.get('USE_DOCKER') == 'yes': + ip = socket.gethostbyname(socket.gethostname()) + INTERNAL_IPS += [ip[:-1] + "1"] DEBUG_TOOLBAR_CONFIG = { 'DISABLE_PANELS': [ @@ -72,3 +82,4 @@ CELERY_ALWAYS_EAGER = True ########## END CELERY {% endif %} # Your local stuff: Below this line define 3rd party library settings +# ------------------------------------------------------------------------------ diff --git a/{{cookiecutter.project_slug}}/config/settings/production.py b/{{cookiecutter.project_slug}}/config/settings/production.py index cf35861fa..04a9426fd 100644 --- a/{{cookiecutter.project_slug}}/config/settings/production.py +++ b/{{cookiecutter.project_slug}}/config/settings/production.py @@ -2,11 +2,10 @@ """ Production Configurations -- Use djangosecure - Use Amazon's S3 for storing static files and uploaded media - Use mailgun to send emails -- Use Redis on Heroku -{% if cookiecutter.use_sentry == 'y' %} +- Use Redis for cache +{% if cookiecutter.use_sentry_for_error_reporting == 'y' %} - Use sentry for error logging {% endif %} {% if cookiecutter.use_opbeat == 'y' %} @@ -17,7 +16,7 @@ from __future__ import absolute_import, unicode_literals from boto.s3.connection import OrdinaryCallingFormat from django.utils import six -{% if cookiecutter.use_sentry == 'y' %} +{% if cookiecutter.use_sentry_for_error_reporting == 'y' %} import logging {% endif %} @@ -29,40 +28,27 @@ from .common import * # noqa # Raises ImproperlyConfigured exception if DJANGO_SECRET_KEY not in os.environ SECRET_KEY = env('DJANGO_SECRET_KEY') + # This ensures that Django will be able to detect a secure connection # properly on Heroku. SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') -# django-secure -# ------------------------------------------------------------------------------ -INSTALLED_APPS += ('djangosecure', ) -{% if cookiecutter.use_sentry == 'y' -%} +{%- if cookiecutter.use_sentry_for_error_reporting == 'y' %} # raven sentry client # See https://docs.getsentry.com/hosted/clients/python/integrations/django/ INSTALLED_APPS += ('raven.contrib.django.raven_compat', ) -{%- endif %} -SECURITY_MIDDLEWARE = ( - 'djangosecure.middleware.SecurityMiddleware', -) -{% if cookiecutter.use_whitenoise == 'y' -%} +{% endif %} +{%- if cookiecutter.use_whitenoise == 'y' %} # Use Whitenoise to serve static files # See: https://whitenoise.readthedocs.io/ -WHITENOISE_MIDDLEWARE = ( - 'whitenoise.middleware.WhiteNoiseMiddleware', -) +WHITENOISE_MIDDLEWARE = ('whitenoise.middleware.WhiteNoiseMiddleware', ) MIDDLEWARE_CLASSES = WHITENOISE_MIDDLEWARE + MIDDLEWARE_CLASSES -{%- endif %} -{% if cookiecutter.use_sentry == 'y' -%} -RAVEN_MIDDLEWARE = ( - 'raven.contrib.django.raven_compat.middleware.SentryResponseErrorIdMiddleware', -) +{% endif %} +{%- if cookiecutter.use_sentry_for_error_reporting == 'y' -%} +RAVEN_MIDDLEWARE = ('raven.contrib.django.raven_compat.middleware.SentryResponseErrorIdMiddleware', ) MIDDLEWARE_CLASSES = RAVEN_MIDDLEWARE + MIDDLEWARE_CLASSES -{%- endif %} - -# Make sure djangosecure.middleware.SecurityMiddleware is listed first -MIDDLEWARE_CLASSES = SECURITY_MIDDLEWARE + MIDDLEWARE_CLASSES - -{% if cookiecutter.use_opbeat == 'y' -%} +{% endif %} +{%- if cookiecutter.use_opbeat == 'y' -%} # opbeat integration # See https://opbeat.com/languages/django/ INSTALLED_APPS += ('opbeat.contrib.django',) @@ -74,7 +60,13 @@ OPBEAT = { MIDDLEWARE_CLASSES = ( 'opbeat.contrib.django.middleware.OpbeatAPMMiddleware', ) + MIDDLEWARE_CLASSES -{%- endif %} +{% endif %} + +# SECURITY CONFIGURATION +# ------------------------------------------------------------------------------ +# See https://docs.djangoproject.com/en/1.9/ref/middleware/#module-django.middleware.security +# and https://docs.djangoproject.com/ja/1.9/howto/deployment/checklist/#run-manage-py-check-deploy + # set this to 60 seconds and then to 518400 when you can prove it works SECURE_HSTS_SECONDS = 60 SECURE_HSTS_INCLUDE_SUBDOMAINS = env.bool( @@ -82,9 +74,12 @@ SECURE_HSTS_INCLUDE_SUBDOMAINS = env.bool( SECURE_CONTENT_TYPE_NOSNIFF = env.bool( 'DJANGO_SECURE_CONTENT_TYPE_NOSNIFF', default=True) SECURE_BROWSER_XSS_FILTER = True -SESSION_COOKIE_SECURE = False +SESSION_COOKIE_SECURE = True SESSION_COOKIE_HTTPONLY = True SECURE_SSL_REDIRECT = env.bool('DJANGO_SECURE_SSL_REDIRECT', default=True) +CSRF_COOKIE_SECURE = True +CSRF_COOKIE_HTTPONLY = True +X_FRAME_OPTIONS = 'DENY' # SITE CONFIGURATION # ------------------------------------------------------------------------------ @@ -95,6 +90,7 @@ ALLOWED_HOSTS = env.list('DJANGO_ALLOWED_HOSTS', default=['{{cookiecutter.domain INSTALLED_APPS += ('gunicorn', ) + # STORAGE CONFIGURATION # ------------------------------------------------------------------------------ # Uploaded Media Files @@ -143,27 +139,32 @@ STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' {% else %} STATIC_URL = 'https://s3.amazonaws.com/%s/static/' % AWS_STORAGE_BUCKET_NAME STATICFILES_STORAGE = 'config.settings.production.StaticRootS3BotoStorage' - # See: https://github.com/antonagestam/collectfast # For Django 1.7+, 'collectfast' should come before # 'django.contrib.staticfiles' AWS_PRELOAD_METADATA = True INSTALLED_APPS = ('collectfast', ) + INSTALLED_APPS {%- endif %} - +{% if cookiecutter.use_compressor == 'y'-%} +# COMPRESSOR +# ------------------------------------------------------------------------------ +COMPRESS_STORAGE = 'storages.backends.s3boto.S3BotoStorage' +COMPRESS_URL = STATIC_URL +COMPRESS_ENABLED = env.bool('COMPRESS_ENABLED', default=True) +{%- endif %} # EMAIL # ------------------------------------------------------------------------------ DEFAULT_FROM_EMAIL = env('DJANGO_DEFAULT_FROM_EMAIL', default='{{cookiecutter.project_name}} ') -EMAIL_BACKEND = 'django_mailgun.MailgunBackend' -MAILGUN_ACCESS_KEY = env('DJANGO_MAILGUN_API_KEY') -MAILGUN_SERVER_NAME = env('DJANGO_MAILGUN_SERVER_NAME') EMAIL_SUBJECT_PREFIX = env('DJANGO_EMAIL_SUBJECT_PREFIX', default='[{{cookiecutter.project_name}}] ') SERVER_EMAIL = env('DJANGO_SERVER_EMAIL', default=DEFAULT_FROM_EMAIL) -{% if cookiecutter.use_newrelic == 'y'-%} -NEW_RELIC_LICENSE_KEY = env('NEW_RELIC_LICENSE_KEY') -NEW_RELIC_APP_NAME = env('NEW_RELIC_APP_NAME') -{%- endif %} + +# Anymail with Mailgun +INSTALLED_APPS += ("anymail", ) +ANYMAIL = { + "MAILGUN_API_KEY": env('DJANGO_MAILGUN_API_KEY'), +} +EMAIL_BACKEND = "anymail.backends.mailgun.MailgunBackend" # TEMPLATE CONFIGURATION # ------------------------------------------------------------------------------ @@ -194,7 +195,7 @@ CACHES = { } } -{% if cookiecutter.use_sentry == 'y' %} +{% if cookiecutter.use_sentry_for_error_reporting == 'y' %} # Sentry Configuration SENTRY_DSN = env('DJANGO_SENTRY_DSN') SENTRY_CLIENT = env('DJANGO_SENTRY_CLIENT', default='raven.contrib.django.raven_compat.DjangoClient') @@ -250,7 +251,7 @@ RAVEN_CONFIG = { 'CELERY_LOGLEVEL': env.int('DJANGO_SENTRY_LOG_LEVEL', logging.INFO), 'DSN': SENTRY_DSN } -{% elif cookiecutter.use_sentry == 'n' %} +{% elif cookiecutter.use_sentry_for_error_reporting == 'n' %} # LOGGING CONFIGURATION # ------------------------------------------------------------------------------ # See: https://docs.djangoproject.com/en/dev/ref/settings/#logging @@ -303,3 +304,4 @@ LOGGING = { ADMIN_URL = env('DJANGO_ADMIN_URL') # Your production stuff: Below this line define 3rd party library settings +# ------------------------------------------------------------------------------ diff --git a/{{cookiecutter.project_slug}}/config/settings/test.py b/{{cookiecutter.project_slug}}/config/settings/test.py new file mode 100644 index 000000000..6d07eb50c --- /dev/null +++ b/{{cookiecutter.project_slug}}/config/settings/test.py @@ -0,0 +1,62 @@ +# -*- coding: utf-8 -*- +''' +Test settings + +- Used to run tests fast on the continuous integration server and locally +''' + +from .common import * # noqa + + +# DEBUG +# ------------------------------------------------------------------------------ +# Turn debug off so tests run faster +DEBUG = False +TEMPLATES[0]['OPTIONS']['debug'] = False + +# SECRET CONFIGURATION +# ------------------------------------------------------------------------------ +# See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key +# Note: This key only used for development and testing. +SECRET_KEY = env('DJANGO_SECRET_KEY', default='CHANGEME!!!') + +# Mail settings +# ------------------------------------------------------------------------------ +EMAIL_HOST = 'localhost' +EMAIL_PORT = 1025 + +# In-memory email backend stores messages in django.core.mail.outbox +# for unit testing purposes +EMAIL_BACKEND = 'django.core.mail.backends.locmem.EmailBackend' + +# CACHING +# ------------------------------------------------------------------------------ +# Speed advantages of in-memory caching without having to run Memcached +CACHES = { + 'default': { + 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', + 'LOCATION': '' + } +} + +# TESTING +# ------------------------------------------------------------------------------ +TEST_RUNNER = 'django.test.runner.DiscoverRunner' + + +# PASSWORD HASHING +# ------------------------------------------------------------------------------ +# Use fast password hasher so tests run faster +PASSWORD_HASHERS = ( + 'django.contrib.auth.hashers.MD5PasswordHasher', +) + +# TEMPLATE LOADERS +# ------------------------------------------------------------------------------ +# Keep templates in memory so tests run faster +TEMPLATES[0]['OPTIONS']['loaders'] = [ + ('django.template.loaders.cached.Loader', [ + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader', + ]), +] diff --git a/{{cookiecutter.project_slug}}/config/wsgi.py b/{{cookiecutter.project_slug}}/config/wsgi.py index 4790b1b50..636f547a4 100644 --- a/{{cookiecutter.project_slug}}/config/wsgi.py +++ b/{{cookiecutter.project_slug}}/config/wsgi.py @@ -15,13 +15,8 @@ framework. """ import os -{% if cookiecutter.use_newrelic == 'y' -%} -if os.environ.get('DJANGO_SETTINGS_MODULE') == 'config.settings.production': - import newrelic.agent - newrelic.agent.initialize() -{%- endif %} from django.core.wsgi import get_wsgi_application -{% if cookiecutter.use_sentry == 'y' -%} +{% if cookiecutter.use_sentry_for_error_reporting == 'y' -%} if os.environ.get('DJANGO_SETTINGS_MODULE') == 'config.settings.production': from raven.contrib.django.raven_compat.middleware.wsgi import Sentry {%- endif %} @@ -36,14 +31,10 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.production") # file. This includes Django's development server, if the WSGI_APPLICATION # setting points here. application = get_wsgi_application() -{% if cookiecutter.use_sentry == 'y' -%} +{% if cookiecutter.use_sentry_for_error_reporting == 'y' -%} if os.environ.get('DJANGO_SETTINGS_MODULE') == 'config.settings.production': application = Sentry(application) {%- endif %} -{% if cookiecutter.use_newrelic == 'y' -%} -if os.environ.get('DJANGO_SETTINGS_MODULE') == 'config.settings.production': - application = newrelic.agent.WSGIApplicationWrapper(application) -{%- endif %} # Apply WSGI middleware here. # from helloworld.wsgi import HelloWorldApplication # application = HelloWorldApplication(application) diff --git a/{{cookiecutter.project_slug}}/dev.yml b/{{cookiecutter.project_slug}}/dev.yml index 005b58d90..fc1394301 100644 --- a/{{cookiecutter.project_slug}}/dev.yml +++ b/{{cookiecutter.project_slug}}/dev.yml @@ -22,11 +22,12 @@ services: build: context: . dockerfile: ./compose/django/Dockerfile-dev - command: python /app/manage.py runserver_plus 0.0.0.0:8000 + command: /start-dev.sh depends_on: - postgres environment: - POSTGRES_USER={{cookiecutter.project_slug}} + - USE_DOCKER=yes volumes: - .:/app ports: diff --git a/{{cookiecutter.project_slug}}/docker-compose.yml b/{{cookiecutter.project_slug}}/docker-compose.yml index df7ddb49c..e4997f555 100644 --- a/{{cookiecutter.project_slug}}/docker-compose.yml +++ b/{{cookiecutter.project_slug}}/docker-compose.yml @@ -27,12 +27,38 @@ services: build: ./compose/nginx depends_on: - django +{% if cookiecutter.use_lets_encrypt == 'y' %} + - certbot +{% endif %} ports: - "0.0.0.0:80:80" +{% if cookiecutter.use_lets_encrypt == 'y' %} + environment: + - MY_DOMAIN_NAME={{ cookiecutter.domain_name }} + ports: + - "0.0.0.0:80:80" + - "0.0.0.0:443:443" + volumes: + - /etc/letsencrypt:/etc/letsencrypt + - /var/lib/letsencrypt:/var/lib/letsencrypt + + certbot: + image: quay.io/letsencrypt/letsencrypt + command: bash -c "sleep 6 && certbot certonly -n --standalone -d {{ cookiecutter.domain_name }} --text --agree-tos --email {{ cookiecutter.email }} --server https://acme-v01.api.letsencrypt.org/directory --rsa-key-size 4096 --verbose --keep-until-expiring --standalone-supported-challenges http-01" + entrypoint: "" + volumes: + - /etc/letsencrypt:/etc/letsencrypt + - /var/lib/letsencrypt:/var/lib/letsencrypt + ports: + - "80" + - "443" + environment: + - TERM=xterm +{% endif %} redis: - image: redis:3.0 - {% if cookiecutter.use_celery == 'y' %} + image: redis:latest +{% if cookiecutter.use_celery == 'y' %} celeryworker: build: context: . @@ -54,4 +80,4 @@ services: - postgres - redis command: celery -A {{cookiecutter.project_slug}}.taskapp beat -l INFO - {% endif %} +{% endif %} diff --git a/{{cookiecutter.project_slug}}/docs/conf.py b/{{cookiecutter.project_slug}}/docs/conf.py index 78ca7ce5e..03cbe319b 100644 --- a/{{cookiecutter.project_slug}}/docs/conf.py +++ b/{{cookiecutter.project_slug}}/docs/conf.py @@ -44,7 +44,7 @@ master_doc = 'index' # General information about the project. project = '{{ cookiecutter.project_name }}' -copyright = """{{ cookiecutter.year }}, {{ cookiecutter.author_name }}""" +copyright = """{% now 'utc', '%Y' %}, {{ cookiecutter.author_name }}""" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the diff --git a/{{cookiecutter.project_slug}}/env.example b/{{cookiecutter.project_slug}}/env.example index 68ff8a27c..95a6a1d96 100644 --- a/{{cookiecutter.project_slug}}/env.example +++ b/{{cookiecutter.project_slug}}/env.example @@ -1,27 +1,36 @@ +# PostgreSQL POSTGRES_PASSWORD=mysecretpass POSTGRES_USER=postgresuser +# General settings DJANGO_ADMIN_URL= DJANGO_SETTINGS_MODULE=config.settings.production DJANGO_SECRET_KEY=CHANGEME!!! DJANGO_ALLOWED_HOSTS=.{{ cookiecutter.domain_name }} + +# AWS Settings DJANGO_AWS_ACCESS_KEY_ID= DJANGO_AWS_SECRET_ACCESS_KEY= DJANGO_AWS_STORAGE_BUCKET_NAME= + +# Used with email DJANGO_MAILGUN_API_KEY= -DJANGO_MAILGUN_SERVER_NAME= DJANGO_SERVER_EMAIL= + +# Security! Better to use DNS for this task, but you can use redirect DJANGO_SECURE_SSL_REDIRECT=False + +# django-allauth DJANGO_ACCOUNT_ALLOW_REGISTRATION=True -{% if cookiecutter.use_sentry == 'y' -%} +{% if cookiecutter.use_sentry_for_error_reporting == 'y' -%} +# Sentry DJANGO_SENTRY_DSN= {% endif %} -{% if cookiecutter.use_newrelic == 'y' -%} -NEW_RELIC_LICENSE_KEY= -NEW_RELIC_APP_NAME={{cookiecutter.project_slug}} -{% endif %} {% if cookiecutter.use_opbeat == 'y' -%} DJANGO_OPBEAT_ORGANIZATION_ID DJANGO_OPBEAT_APP_ID DJANGO_OPBEAT_SECRET_TOKEN {% endif %} +{% if cookiecutter.use_compressor == 'y' -%} +COMPRESS_ENABLED= +{% endif %} \ No newline at end of file diff --git a/{{cookiecutter.project_slug}}/gulpfile.js b/{{cookiecutter.project_slug}}/gulpfile.js new file mode 100644 index 000000000..73b71339f --- /dev/null +++ b/{{cookiecutter.project_slug}}/gulpfile.js @@ -0,0 +1,108 @@ + +//////////////////////////////// + //Setup// +//////////////////////////////// + +// Plugins +var gulp = require('gulp'), + pjson = require('./package.json'), + gutil = require('gulp-util'), + sass = require('gulp-sass'), + autoprefixer = require('gulp-autoprefixer'), + cssnano = require('gulp-cssnano'), + rename = require('gulp-rename'), + del = require('del'), + plumber = require('gulp-plumber'), + pixrem = require('gulp-pixrem'), + uglify = require('gulp-uglify'), + imagemin = require('gulp-imagemin'), + exec = require('child_process').exec, + runSequence = require('run-sequence'), + browserSync = require('browser-sync').create(), + reload = browserSync.reload; + + +// Relative paths function +var pathsConfig = function (appName) { + this.app = "./" + (appName || pjson.name); + + return { + app: this.app, + templates: this.app + '/templates', + css: this.app + '/static/css', + sass: this.app + '/static/sass', + fonts: this.app + '/static/fonts', + images: this.app + '/static/images', + js: this.app + '/static/js', + } +}; + +var paths = pathsConfig(); + +//////////////////////////////// + //Tasks// +//////////////////////////////// + +// Styles autoprefixing and minification +gulp.task('styles', function() { + return gulp.src(paths.sass + '/project.scss') + .pipe(sass().on('error', sass.logError)) + .pipe(plumber()) // Checks for errors + .pipe(autoprefixer({browsers: ['last 2 version']})) // Adds vendor prefixes + .pipe(pixrem()) // add fallbacks for rem units + .pipe(gulp.dest(paths.css)) + .pipe(rename({ suffix: '.min' })) + .pipe(cssnano()) // Minifies the result + .pipe(gulp.dest(paths.css)); +}); + +// Javascript minification +gulp.task('scripts', function() { + return gulp.src(paths.js + '/project.js') + .pipe(plumber()) // Checks for errors + .pipe(uglify()) // Minifies the js + .pipe(rename({ suffix: '.min' })) + .pipe(gulp.dest(paths.js)); +}); + +// Image compression +gulp.task('imgCompression', function(){ + return gulp.src(paths.images + '/*') + .pipe(imagemin()) // Compresses PNG, JPEG, GIF and SVG images + .pipe(gulp.dest(paths.images)) +}); + +// Run django server +gulp.task('runServer', function() { + exec('python manage.py runserver', function (err, stdout, stderr) { + console.log(stdout); + console.log(stderr); + }); +}); + +// Browser sync server for live reload +gulp.task('browserSync', function() { + browserSync.init( + [paths.css + "/*.css", paths.js + "*.js", paths.templates + '*.html'], { + proxy: "localhost:8000" + }); +}); + +// Default task +gulp.task('default', function() { + runSequence(['styles', 'scripts', 'imgCompression'], 'runServer', 'browserSync'); +}); + +//////////////////////////////// + //Watch// +//////////////////////////////// + +// Watch +gulp.task('watch', ['default'], function() { + + gulp.watch(paths.sass + '/*.scss', ['styles']); + gulp.watch(paths.js + '/*.js', ['scripts']).on("change", reload); + gulp.watch(paths.images + '/*', ['imgCompression']); + gulp.watch(paths.templates + '/**/*.html').on("change", reload); + +}); diff --git a/{{cookiecutter.project_slug}}/package.json b/{{cookiecutter.project_slug}}/package.json index 47cf69441..0c8af4272 100644 --- a/{{cookiecutter.project_slug}}/package.json +++ b/{{cookiecutter.project_slug}}/package.json @@ -3,17 +3,33 @@ "version": "{{ cookiecutter.version }}", "dependencies": {}, "devDependencies": { - "grunt": "~0.4.5", - "grunt-contrib-watch": "~0.6.1", - "grunt-bg-shell": "~2.3.1", - "connect-livereload": "~0.3.2", - "time-grunt": "~1.2.1", - "load-grunt-tasks": "~3.2.0", - "grunt-sass": "~1.0.0", - "grunt-postcss": "~0.5.5", - "cssnano": "~2.1.0", + {% if cookiecutter.js_task_runner == 'Grunt' %} "autoprefixer-core": "~5.2.1", - "pixrem": "~1.3.1" + "connect-livereload": "~0.3.2", + "cssnano": "~2.1.0", + "grunt": "~0.4.5", + "grunt-bg-shell": "~2.3.1", + "grunt-contrib-watch": "~0.6.1", + "grunt-postcss": "~0.5.5", + "grunt-sass": "~1.0.0", + "load-grunt-tasks": "~3.2.0", + "pixrem": "~1.3.1", + "time-grunt": "~1.2.1" + {% elif cookiecutter.js_task_runner == 'Gulp' %} + "browser-sync": "^2.14.0", + "del": "^2.2.2", + "gulp": "^3.9.1", + "gulp-autoprefixer": "^3.1.1", + "gulp-cssnano": "^2.1.2", + "gulp-imagemin": "^3.0.3", + "gulp-pixrem": "^1.0.0", + "gulp-plumber": "^1.1.0", + "gulp-rename": "^1.2.2", + "gulp-sass": "^2.3.2", + "gulp-uglify": "^2.0.0", + "gulp-util": "^3.0.7", + "run-sequence": "^1.2.2" + {% endif %} }, "engines": { "node": ">=0.8.0" diff --git a/{{cookiecutter.project_slug}}/requirements/base.txt b/{{cookiecutter.project_slug}}/requirements/base.txt index f5e35acd6..fcc10ba24 100644 --- a/{{cookiecutter.project_slug}}/requirements/base.txt +++ b/{{cookiecutter.project_slug}}/requirements/base.txt @@ -1,4 +1,4 @@ -{% if cookiecutter.use_python2 == 'n' -%} +{% if cookiecutter.use_python3 == 'y' -%} # Wheel 0.25+ needed to install certain packages on CPython 3.5+ # like Pillow and psycopg2 # See http://bitly.com/wheel-building-fails-CPython-35 @@ -7,52 +7,55 @@ wheel==0.29.0 {%- endif %} # Bleeding edge Django -django==1.9.6 +django==1.9.9 # Configuration django-environ==0.4.0 -django-secure==1.0.1 {% if cookiecutter.use_whitenoise == 'y' -%} -whitenoise==3.0 +whitenoise==3.2.1 {%- endif %} # Forms -django-braces==1.8.1 +django-braces==1.9.0 django-crispy-forms==1.6.0 -django-floppyforms==1.6.2 # Models -django-model-utils==2.5 +django-model-utils==2.5.2 # Images -Pillow==3.2.0 +Pillow==3.3.1 # For user registration, either via email or social # Well-built with regular release cycles! -django-allauth==0.25.2 +django-allauth==0.27.0 {% if cookiecutter.windows == 'y' -%} # On Windows, you must download/install psycopg2 manually # from http://www.lfd.uci.edu/~gohlke/pythonlibs/#psycopg {% else %} # Python-PostgreSQL Database Adapter -psycopg2==2.6.1 +psycopg2==2.6.2 {%- endif %} # Unicode slugification -unicode-slugify==0.1.3 +awesome-slugify==1.6.5 django-autoslug==1.9.3 # Time zones support -pytz==2016.4 +pytz==2016.6.1 # Redis support -django-redis==4.4.2 +django-redis==4.4.4 redis>=2.10.0 {% if cookiecutter.use_celery == "y" %} celery==3.1.23 {% endif %} +{% if cookiecutter.use_compressor == "y" %} +rcssmin==1.0.6 {% if cookiecutter.windows == 'y' %}--install-option="--without-c-extensions"{% endif %} +django-compressor==2.1 +{% endif %} + # Your custom requirements go here diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index c88093fef..bc260ba51 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -1,16 +1,16 @@ # Local development dependencies go here -r base.txt -coverage==4.0.3 -django_coverage_plugin==1.3 -Sphinx -django-extensions==1.6.7 -Werkzeug==0.11.9 -django-test-plus==1.0.12 +coverage==4.2 +django-coverage-plugin==1.3.1 +Sphinx==1.4.5 +django-extensions==1.7.4 +Werkzeug==0.11.11 +django-test-plus==1.0.15 factory_boy==2.7.0 -django-debug-toolbar==1.4 +django-debug-toolbar==1.5 # improved REPL -ipdb==0.10.0 +ipdb==0.10.1 pytest-django==2.9.1 pytest-sugar==0.7.1 diff --git a/{{cookiecutter.project_slug}}/requirements/production.txt b/{{cookiecutter.project_slug}}/requirements/production.txt index b2308d363..f0fbc1cb4 100644 --- a/{{cookiecutter.project_slug}}/requirements/production.txt +++ b/{{cookiecutter.project_slug}}/requirements/production.txt @@ -6,40 +6,34 @@ # Python-PostgreSQL Database Adapter # If using Win for dev, this assumes Unix in prod # ------------------------------------------------ -psycopg2==2.6.1 +psycopg2==2.6.2 {%- endif %} # WSGI Handler # ------------------------------------------------ -gevent==1.1.1 -gunicorn==19.5.0 +gevent==1.1.2 +gunicorn==19.6.0 # Static and Media Storage # ------------------------------------------------ -boto==2.40.0 +boto==2.42.0 django-storages-redux==1.3.2 {% if cookiecutter.use_whitenoise != 'y' -%} Collectfast==0.2.3 {%- endif %} -# Mailgun Support -# --------------- -django-mailgun==0.9.1 +# Email backends for Mailgun, Postmark, SendGrid and more +# ------------------------------------------------------- +django-anymail==0.4.2 -{% if cookiecutter.use_sentry == "y" -%} +{% if cookiecutter.use_sentry_for_error_reporting == "y" -%} # Raven is the Sentry client # -------------------------- -raven -{%- endif %} - -{% if cookiecutter.use_newrelic == "y" -%} -# Newrelic agent for performance monitoring -# ----------------------------------------- -newrelic +raven==5.26.0 {%- endif %} {% if cookiecutter.use_opbeat == "y" -%} # Opbeat agent for performance monitoring # ----------------------------------------- -opbeat +opbeat==3.4.0 {%- endif %} diff --git a/{{cookiecutter.project_slug}}/requirements/test.txt b/{{cookiecutter.project_slug}}/requirements/test.txt index 0451bc60f..b607cbc54 100644 --- a/{{cookiecutter.project_slug}}/requirements/test.txt +++ b/{{cookiecutter.project_slug}}/requirements/test.txt @@ -4,13 +4,12 @@ {% if cookiecutter.windows == 'y' -%} # Python-PostgreSQL Database Adapter # If using Win for dev, this assumes Unix in test/prod -psycopg2==2.6.1 +psycopg2==2.6.2 {%- endif %} -coverage==4.0.3 -django_coverage_plugin==1.3 -flake8==2.5.4 -django-test-plus==1.0.12 +coverage==4.2 +flake8==3.0.4 # pyup: != 2.6.0 +django-test-plus==1.0.15 factory_boy==2.7.0 # pytest diff --git a/{{cookiecutter.project_slug}}/runtime.txt b/{{cookiecutter.project_slug}}/runtime.txt index 84c90354c..941591788 100644 --- a/{{cookiecutter.project_slug}}/runtime.txt +++ b/{{cookiecutter.project_slug}}/runtime.txt @@ -1,5 +1 @@ -{% if cookiecutter.use_python2 == 'n' -%} -python-3.5.1 -{% else %} -python-2.7.10 -{%- endif %} +{% if cookiecutter.use_python3 == 'y' -%}python-3.5.1{% else %}python-2.7.10{%- endif %} diff --git a/{{cookiecutter.project_slug}}/utility/install_os_dependencies.sh b/{{cookiecutter.project_slug}}/utility/install_os_dependencies.sh index cc1fb2f07..ec9372fd8 100755 --- a/{{cookiecutter.project_slug}}/utility/install_os_dependencies.sh +++ b/{{cookiecutter.project_slug}}/utility/install_os_dependencies.sh @@ -1,61 +1,72 @@ #!/bin/bash WORK_DIR="$(dirname "$0")" -OS_REQUIREMENTS_FILENAME="$WORK_DIR/requirements.apt" +DISTRO_NAME=$(lsb_release -sc) +OS_REQUIREMENTS_FILENAME="requirements-$DISTRO_NAME.apt" -VER=$(lsb_release -sr) -if [ "$VER" == "16.04" ]; then - OS_REQUIREMENTS_FILENAME="requirements.apt.xenial" -else - OS_REQUIREMENTS_FILENAME="requirements.apt" +cd $WORK_DIR + +# Check if a requirements file exist for the current distribution. +if [ ! -r "$OS_REQUIREMENTS_FILENAME" ]; then + cat <<-EOF >&2 + There is no requirements file for your distribution. + You can see one of the files listed below to help search the equivalent package in your system: + $(find ./ -name "requirements-*.apt" -printf " - %f\n") + EOF + exit 1; fi + # Handle call with wrong command function wrong_command() { - echo "${0##*/} - unknown command: '${1}'" - usage_message + echo "${0##*/} - unknown command: '${1}'" >&2 + usage_message } # Print help / script usage function usage_message() { - echo "usage: ./${0##*/} " - echo "available commands are:" - echo -e "\tlist\t\tPrint a list of all packages defined on ${OS_REQUIREMENTS_FILENAME} file" - echo -e "\thelp\t\tPrint this help" - echo -e "\n\tCommands that require superuser permission:" - echo -e "\tinstall\t\tInstall packages defined on ${OS_REQUIREMENTS_FILENAME} file. Note: This\n\t\t\t does not upgrade the packages already installed for new\n\t\t\t versions, even if new version is available in the repository." - echo -e "\tupgrade\t\tSame that install, but upgrate the already installed packages,\n\t\t\t if new version is available." + cat <<-EOF + Usage: $WORK_DIR/${0##*/} + Available commands are: + list Print a list of all packages defined on ${OS_REQUIREMENTS_FILENAME} file + help Print this help + Commands that require superuser permission: + install Install packages defined on ${OS_REQUIREMENTS_FILENAME} file. Note: This + does not upgrade the packages already installed for new versions, even if + new version is available in the repository. + upgrade Same that install, but upgrade the already installed packages, if new + version is available. + EOF } # Read the requirements.apt file, and remove comments and blank lines function list_packages(){ - grep -v "#" ${OS_REQUIREMENTS_FILENAME} | grep -v "^$"; + grep -v "#" "${OS_REQUIREMENTS_FILENAME}" | grep -v "^$"; } -function install() +function install_packages() { list_packages | xargs apt-get --no-upgrade install -y; } -function upgrade() +function upgrade_packages() { list_packages | xargs apt-get install -y; } - function install_or_upgrade() { P=${1} PARAN=${P:-"install"} if [[ $EUID -ne 0 ]]; then - echo -e "\nYou must run this with root privilege" 2>&1 - echo -e "Please do:\n" 2>&1 - echo "sudo ./${0##*/} $PARAN" 2>&1 - echo -e "\n" 2>&1 - + cat <<-EOF >&2 + You must run this script with root privilege + Please do: + sudo $WORK_DIR/${0##*/} $PARAN + EOF exit 1 else @@ -63,9 +74,9 @@ function install_or_upgrade() # Install the basic compilation dependencies and other required libraries of this project if [ "$PARAN" == "install" ]; then - install; + install_packages; else - upgrade; + upgrade_packages; fi # cleaning downloaded packages from apt-get cache @@ -73,16 +84,13 @@ function install_or_upgrade() exit 0 fi - - } - # Handle command argument case "$1" in install) install_or_upgrade;; upgrade) install_or_upgrade "upgrade";; list) list_packages;; - help) usage_message;; - *) wrong_command $1;; + help|"") usage_message;; + *) wrong_command "$1";; esac diff --git a/{{cookiecutter.project_slug}}/utility/install_python_dependencies.sh b/{{cookiecutter.project_slug}}/utility/install_python_dependencies.sh index d23fcf9e9..074bc192a 100755 --- a/{{cookiecutter.project_slug}}/utility/install_python_dependencies.sh +++ b/{{cookiecutter.project_slug}}/utility/install_python_dependencies.sh @@ -6,7 +6,7 @@ PROJECT_DIR="$(dirname "$WORK_DIR")" pip --version >/dev/null 2>&1 || { echo >&2 -e "\npip is required but it's not installed." echo >&2 -e "You can install it by running the following command:\n" -{% if cookiecutter.use_python2 == 'n' -%} +{% if cookiecutter.use_python3 == 'y' -%} echo >&2 "wget https://bootstrap.pypa.io/get-pip.py --output-document=get-pip.py; chmod +x get-pip.py; sudo -H python3 get-pip.py" {% else %} echo >&2 "wget https://bootstrap.pypa.io/get-pip.py --output-document=get-pip.py; chmod +x get-pip.py; sudo -H python2 get-pip.py" @@ -19,7 +19,7 @@ pip --version >/dev/null 2>&1 || { virtualenv --version >/dev/null 2>&1 || { echo >&2 -e "\nvirtualenv is required but it's not installed." echo >&2 -e "You can install it by running the following command:\n" -{% if cookiecutter.use_python2 == 'n' -%} +{% if cookiecutter.use_python3 == 'y' -%} echo >&2 "sudo -H pip3 install virtualenv" {% else %} echo >&2 "sudo -H pip2 install virtualenv" @@ -32,7 +32,7 @@ virtualenv --version >/dev/null 2>&1 || { if [ -z "$VIRTUAL_ENV" ]; then echo >&2 -e "\nYou need activate a virtualenv first" echo >&2 -e 'If you do not have a virtualenv created, run the following command to create and automatically activate a new virtualenv named "venv" on current folder:\n' -{% if cookiecutter.use_python2 == 'n' -%} +{% if cookiecutter.use_python3 == 'y' -%} echo >&2 -e "virtualenv venv --python=\`which python3\`" {% else %} echo >&2 -e "virtualenv venv --python=\`which python2\`" diff --git a/{{cookiecutter.project_slug}}/utility/requirements-jessie.apt b/{{cookiecutter.project_slug}}/utility/requirements-jessie.apt new file mode 100644 index 000000000..ba7efc3f2 --- /dev/null +++ b/{{cookiecutter.project_slug}}/utility/requirements-jessie.apt @@ -0,0 +1,27 @@ +##basic build dependencies of various Django apps for Debian Jessie 8.x +#build-essential metapackage install: make, gcc, g++, +build-essential +#required to translate +gettext +{% if cookiecutter.use_python3 == 'y' -%} +python3-dev +{% else %} +python-dev +{%- endif %} + +##shared dependencies of: +##Pillow, pylibmc +zlib1g-dev + +##Postgresql and psycopg2 dependencies +libpq-dev + +##Pillow dependencies +libtiff5-dev +libjpeg62-turbo-dev +libfreetype6-dev +liblcms2-dev +libwebp-dev + +##django-extensions +graphviz-dev diff --git a/{{cookiecutter.project_slug}}/utility/requirements.apt b/{{cookiecutter.project_slug}}/utility/requirements-trusty.apt similarity index 76% rename from {{cookiecutter.project_slug}}/utility/requirements.apt rename to {{cookiecutter.project_slug}}/utility/requirements-trusty.apt index 9a18d50d4..966e9576f 100644 --- a/{{cookiecutter.project_slug}}/utility/requirements.apt +++ b/{{cookiecutter.project_slug}}/utility/requirements-trusty.apt @@ -1,9 +1,9 @@ -##basic build dependencies of various Django apps for Ubuntu 14.04 +##basic build dependencies of various Django apps for Ubuntu Trusty 14.04 #build-essential metapackage install: make, gcc, g++, build-essential #required to translate gettext -{% if cookiecutter.use_python2 == 'n' -%} +{% if cookiecutter.use_python3 == 'y' -%} python3-dev {% else %} python-dev @@ -25,3 +25,4 @@ libwebp-dev ##django-extensions graphviz-dev + diff --git a/{{cookiecutter.project_slug}}/utility/requirements-xenial.apt b/{{cookiecutter.project_slug}}/utility/requirements-xenial.apt new file mode 100644 index 000000000..157bdf209 --- /dev/null +++ b/{{cookiecutter.project_slug}}/utility/requirements-xenial.apt @@ -0,0 +1,28 @@ +##basic build dependencies of various Django apps for Ubuntu Xenial 16.04 +#build-essential metapackage install: make, gcc, g++, +build-essential +#required to translate +gettext +{% if cookiecutter.use_python3 == 'y' -%} +python3-dev +{% else %} +python-dev +{%- endif %} + +##shared dependencies of: +##Pillow, pylibmc +zlib1g-dev + +##Postgresql and psycopg2 dependencies +libpq-dev + +##Pillow dependencies +libtiff5-dev +libjpeg8-dev +libfreetype6-dev +liblcms2-dev +libwebp-dev + +##django-extensions +graphviz-dev + diff --git a/{{cookiecutter.project_slug}}/utility/requirements.apt.xenial b/{{cookiecutter.project_slug}}/utility/requirements.apt.xenial deleted file mode 100644 index f29f6b400..000000000 --- a/{{cookiecutter.project_slug}}/utility/requirements.apt.xenial +++ /dev/null @@ -1,44 +0,0 @@ -##basic build dependencies of various Django apps for Ubuntu 14.04 -#build-essential metapackage install: make, gcc, g++, -build-essential -#required to translate -gettext -python-dev - -##shared dependencies of: -##Pillow, pylibmc -zlib1g-dev - -##Postgresql and psycopg2 dependencies -libpq-dev - -##Pillow dependencies -libtiff5-dev -libjpeg8-dev -libfreetype6-dev -liblcms2-dev -libwebp-dev - - -##django-extensions -graphviz-dev - -##hitch -python-setuptools -python3-dev -python-virtualenv -python-pip -firefox -automake -libtool -libreadline6 -libreadline6-dev -libreadline-dev -libsqlite3-dev -libxml2 -libxml2-dev -libssl-dev -libbz2-dev -wget -curl -llvm diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/static/js/project.js b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/static/js/project.js index d26d23b9b..91ab9e2da 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/static/js/project.js +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/static/js/project.js @@ -1 +1,21 @@ /* Project specific Javascript goes here. */ + +/* +Formatting hack to get around crispy-forms unfortunate hardcoding +in helpers.FormHelper: + + if template_pack == 'bootstrap4': + grid_colum_matcher = re.compile('\w*col-(xs|sm|md|lg|xl)-\d+\w*') + using_grid_layout = (grid_colum_matcher.match(self.label_class) or + grid_colum_matcher.match(self.field_class)) + if using_grid_layout: + items['using_grid_layout'] = True + +Issues with the above approach: + +1. Fragile: Assumes Bootstrap 4's API doesn't change (it does) +2. Unforgiving: Doesn't allow for any variation in template design +3. Really Unforgiving: No way to override this behavior +4. Undocumented: No mention in the documentation, or it's too hard for me to find +*/ +$('.form-group').removeClass('row'); diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/static/sass/project.scss b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/static/sass/project.scss index e737d593f..54632b2d6 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/static/sass/project.scss +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/static/sass/project.scss @@ -1,5 +1,10 @@ + // project specific CSS goes here +//////////////////////////////// + //Variables// +//////////////////////////////// + // Alert colors $white: #fff; @@ -9,6 +14,10 @@ $pink: #f2dede; $dark-pink: #eed3d7; $red: #b94a48; +//////////////////////////////// + //Alerts// +//////////////////////////////// + // bootstrap alert CSS, translated to the django-standard levels of // debug, info, success, warning, error @@ -24,8 +33,16 @@ $red: #b94a48; color: $red; } +//////////////////////////////// + //Navbar// +//////////////////////////////// + // This is a fix for the bootstrap4 alpha release +.navbar { + border-radius: 0px; +} + @media (max-width: 47.9em) { .navbar-nav .nav-item { display: inline-block; @@ -42,6 +59,10 @@ $red: #b94a48; } } +//////////////////////////////// + //Django Toolbar// +//////////////////////////////// + // Display django-debug-toolbar. // See https://github.com/django-debug-toolbar/django-debug-toolbar/issues/742 // and https://github.com/pydanny/cookiecutter-django/issues/317 diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/taskapp/celery.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/taskapp/celery.py index 44c57f7c1..8346f837d 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/taskapp/celery.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/taskapp/celery.py @@ -2,7 +2,7 @@ from __future__ import absolute_import import os from celery import Celery -from django.apps import AppConfig +from django.apps import apps, AppConfig from django.conf import settings @@ -22,9 +22,10 @@ class CeleryConfig(AppConfig): # Using a string here means the worker will not have to # pickle the object when using Windows. app.config_from_object('django.conf:settings') - app.autodiscover_tasks(lambda: settings.INSTALLED_APPS, force=True) + installed_apps = [app_config.name for app_config in apps.get_app_configs()] + app.autodiscover_tasks(lambda: installed_apps, force=True) - {% if cookiecutter.use_sentry == 'y' -%} + {% if cookiecutter.use_sentry_for_error_reporting == 'y' -%} if hasattr(settings, 'RAVEN_CONFIG'): # Celery signal registration from raven import Client as RavenClient diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/account_inactive.html b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/account_inactive.html new file mode 100644 index 000000000..fe9b68078 --- /dev/null +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/account_inactive.html @@ -0,0 +1,12 @@ +{% raw %}{% extends "account/base.html" %} + +{% load i18n %} + +{% block head_title %}{% trans "Account Inactive" %}{% endblock %} + +{% block inner %} +

{% trans "Account Inactive" %}

+ +

{% trans "This account is inactive." %}

+{% endblock %} +{% endraw %} diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/base.html b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/base.html index 6703bb8b0..cd07bbabf 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/base.html +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/base.html @@ -1,3 +1,11 @@ {% raw %}{% extends "base.html" %} {% block title %}{% block head_title %}{% endblock head_title %}{% endblock title %} + +{% block content %} +
+
+ {% block inner %}{% endblock %} +
+
+{% endblock %} {% endraw %} \ No newline at end of file diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/email.html b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/email.html index e757f21f3..78d997365 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/email.html +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/email.html @@ -1,68 +1,66 @@ -{% raw %}{% extends "account/base.html" %} +{% raw %} +{% extends "account/base.html" %} {% load i18n %} {% load crispy_forms_tags %} {% block head_title %}{% trans "Account" %}{% endblock %} -{% block content %} -
-
-
-

{% trans "E-mail Addresses" %}

- {% if user.emailaddress_set.all %} -

{% trans 'The following e-mail addresses are associated with your account:' %}

+{% block inner %} +

{% trans "E-mail Addresses" %}

-
+ {{ emailaddress.email }} + {% if emailaddress.verified %} + {% trans "Verified" %} + {% else %} + {% trans "Unverified" %} + {% endif %} + {% if emailaddress.primary %}{% trans "Primary" %}{% endif %} +
+ {% endfor %} + +
+ + + +
+ + + + +{% else %} +

{% trans 'Warning:'%} {% trans "You currently do not have any e-mail address set up. You should really add an e-mail address so you can receive notifications, reset your password, etc." %}

+ +{% endif %} + + +

{% trans "Add E-mail Address" %}

+ +
+ {% csrf_token %} + {{ form|crispy }} + +
+ {% endblock %} -{% block extra_body %} +{% block javascript %} +{{ block.super }} {% endblock %} {% endraw %} diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/email_confirm.html b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/email_confirm.html index d7886239a..eb45cf600 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/email_confirm.html +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/email_confirm.html @@ -6,32 +6,27 @@ {% block head_title %}{% trans "Confirm E-mail Address" %}{% endblock %} -{% block content %} -
-
-
-

{% trans "Confirm E-mail Address" %}

+{% block inner %} +

{% trans "Confirm E-mail Address" %}

- {% if confirmation %} +{% if confirmation %} - {% user_display confirmation.email_address.user as user_display %} +{% user_display confirmation.email_address.user as user_display %} -

{% blocktrans with confirmation.email_address.email as email %}Please confirm that {{ email }} is an e-mail address for user {{ user_display }}.{% endblocktrans %}

+

{% blocktrans with confirmation.email_address.email as email %}Please confirm that {{ email }} is an e-mail address for user {{ user_display }}.{% endblocktrans %}

-
- {% csrf_token %} - -
+
+{% csrf_token %} + +
- {% else %} +{% else %} - {% url 'account_email' as email_url %} +{% url 'account_email' as email_url %} -

{% blocktrans %}This e-mail confirmation link expired or is invalid. Please issue a new e-mail confirmation request.{% endblocktrans %}

+

{% blocktrans %}This e-mail confirmation link expired or is invalid. Please issue a new e-mail confirmation request.{% endblocktrans %}

+ +{% endif %} - {% endif %} -
-
-
{% endblock %} {% endraw %} diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/email_confirmed.html b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/email_confirmed.html deleted file mode 100644 index 97f2a82c0..000000000 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/email_confirmed.html +++ /dev/null @@ -1,22 +0,0 @@ -{% raw %}{% extends "account/base.html" %} - -{% load i18n %} -{% load account %} - -{% block head_title %}{% trans "Confirm E-mail Address" %}{% endblock %} - - -{% block content %} -
-
-
-

{% trans "Confirm E-mail Address" %}

- - {% user_display email_address.user as user_display %} - -

{% blocktrans with email_address.email as email %}You have confirmed that {{ email }} is an e-mail address for user {{ user_display }}.{% endblocktrans %}

-
-
-
-{% endblock %} -{% endraw %} \ No newline at end of file diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/login.html b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/login.html index acbc50c21..a71932225 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/login.html +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/login.html @@ -1,48 +1,48 @@ {% raw %}{% extends "account/base.html" %} {% load i18n %} -{% load account %} -{% load socialaccount %} +{% load account socialaccount %} {% load crispy_forms_tags %} {% block head_title %}{% trans "Sign In" %}{% endblock %} -{% block content %} -
-
-
-

{% trans "Sign In" %}

- {% get_providers as socialaccount_providers %} - {% if socialaccount_providers %} -

{% blocktrans with site.name as site_name %}Please sign in with one - of your existing third party accounts. Or, sign up - for a {{ site_name }} account and sign in below:{% endblocktrans %}

+{% block inner %} -
+

{% trans "Sign In" %}

-
    - {% include "socialaccount/snippets/provider_list.html" with process="login" %} -
+{% get_providers as socialaccount_providers %} - +{% if socialaccount_providers %} +

{% blocktrans with site.name as site_name %}Please sign in with one +of your existing third party accounts. Or, sign up +for a {{ site_name }} account and sign in below:{% endblocktrans %}

-
+
- {% include "socialaccount/snippets/login_extra.html" %} +
    + {% include "socialaccount/snippets/provider_list.html" with process="login" %} +
- {% endif %} + - -
-
+ +{% include "socialaccount/snippets/login_extra.html" %} + +{% else %} +

{% blocktrans %}If you have not created an account yet, then please +sign up first.{% endblocktrans %}

+{% endif %} + + + {% endblock %} {% endraw %} diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/logout.html b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/logout.html index 039dc7be9..baa8183c9 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/logout.html +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/logout.html @@ -4,25 +4,19 @@ {% block head_title %}{% trans "Sign Out" %}{% endblock %} -{% block content %} -
-
-
+{% block inner %} +

{% trans "Sign Out" %}

-

{% trans "Sign Out" %}

+

{% trans 'Are you sure you want to sign out?' %}

-

{% trans 'Are you sure you want to sign out?' %}

+
+ {% csrf_token %} + {% if redirect_field_value %} + + {% endif %} + +
-
- {% csrf_token %} - {% if redirect_field_value %} - - {% endif %} - -
-
-
-
{% endblock %} {% endraw %} diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/password_change.html b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/password_change.html index 9855c0f5a..62bbbc138 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/password_change.html +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/password_change.html @@ -2,21 +2,16 @@ {% load i18n %} {% load crispy_forms_tags %} + {% block head_title %}{% trans "Change Password" %}{% endblock %} -{% block content %} -
-
-
-

{% trans "Change Password" %}

+{% block inner %} +

{% trans "Change Password" %}

-
- {% csrf_token %} - {{ form|crispy }} - -
-
-
-
+
+ {% csrf_token %} + {{ form|crispy }} + +
{% endblock %} {% endraw %} diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/password_reset.html b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/password_reset.html index 2e6c5a6fc..7478c419b 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/password_reset.html +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/password_reset.html @@ -6,34 +6,21 @@ {% block head_title %}{% trans "Password Reset" %}{% endblock %} -{% block content %} -
-
-
+{% block inner %} -

{% trans "Password Reset" %}

- {% if user.is_authenticated %} - {% include "account/snippets/already_logged_in.html" %} - {% endif %} +

{% trans "Password Reset" %}

+ {% if user.is_authenticated %} + {% include "account/snippets/already_logged_in.html" %} + {% endif %} -

{% trans "Forgotten your password? Enter your e-mail address below, and we'll send you an e-mail allowing you to reset it." %}

+

{% trans "Forgotten your password? Enter your e-mail address below, and we'll send you an e-mail allowing you to reset it." %}

-
- {% csrf_token %} - {{ form|crispy }} - -
+
+ {% csrf_token %} + {{ form|crispy }} + +
-

{% blocktrans %}Please contact us if you have any trouble resetting your password.{% endblocktrans %}

-
-
-
+

{% blocktrans %}Please contact us if you have any trouble resetting your password.{% endblocktrans %}

{% endblock %} - -{% block javascript %} - {{ block.super }} - -{% endblock javascript %} {% endraw %} diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/password_reset_done.html b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/password_reset_done.html index e954abc61..cf2129b1e 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/password_reset_done.html +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/password_reset_done.html @@ -5,19 +5,13 @@ {% block head_title %}{% trans "Password Reset" %}{% endblock %} -{% block content %} -
-
-
-

{% trans "Password Reset" %}

- - {% if user.is_authenticated %} - {% include "account/snippets/already_logged_in.html" %} - {% endif %} - -

{% blocktrans %}We have sent you an e-mail. Please contact us if you do not receive it within a few minutes.{% endblocktrans %}

-
-
-
+{% block inner %} +

{% trans "Password Reset" %}

+ + {% if user.is_authenticated %} + {% include "account/snippets/already_logged_in.html" %} + {% endif %} + +

{% blocktrans %}We have sent you an e-mail. Please contact us if you do not receive it within a few minutes.{% endblocktrans %}

{% endblock %} -{% endraw %} \ No newline at end of file +{% endraw %} diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/password_reset_from_key.html b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/password_reset_from_key.html index 8e1b39e26..2171144d8 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/password_reset_from_key.html +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/password_reset_from_key.html @@ -2,31 +2,24 @@ {% load i18n %} {% load crispy_forms_tags %} - {% block head_title %}{% trans "Change Password" %}{% endblock %} -{% block content %} -
-
-
-

{% if token_fail %}{% trans "Bad Token" %}{% else %}{% trans "Change Password" %}{% endif %}

+{% block inner %} +

{% if token_fail %}{% trans "Bad Token" %}{% else %}{% trans "Change Password" %}{% endif %}

{% if token_fail %} {% url 'account_reset_password' as passwd_reset_url %}

{% blocktrans %}The password reset link was invalid, possibly because it has already been used. Please request a new password reset.{% endblocktrans %}

{% else %} {% if form %} -
+ {% csrf_token %} {{ form|crispy }} - +
{% else %}

{% trans 'Your password is now changed.' %}

{% endif %} {% endif %} -
-
-
{% endblock %} {% endraw %} diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/password_reset_from_key_done.html b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/password_reset_from_key_done.html index 015028e4a..925b7aa23 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/password_reset_from_key_done.html +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/password_reset_from_key_done.html @@ -3,14 +3,8 @@ {% load i18n %} {% block head_title %}{% trans "Change Password" %}{% endblock %} -{% block content %} -
-
-
-

{% trans "Change Password" %}

-

{% trans 'Your password is now changed.' %}

-
-
-
+{% block inner %} +

{% trans "Change Password" %}

+

{% trans 'Your password is now changed.' %}

{% endblock %} {% endraw %} diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/password_set.html b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/password_set.html index 7e2967e37..c98277157 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/password_set.html +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/password_set.html @@ -1,23 +1,17 @@ -{% raw %} -{% extends "account/base.html" %} +{% raw %}{% extends "account/base.html" %} -{% load i18n crispy_forms_tags %} +{% load i18n %} +{% load crispy_forms_tags %} {% block head_title %}{% trans "Set Password" %}{% endblock %} -{% block content %} -
-
-
-

{% trans "Set Password" %}

+{% block inner %} +

{% trans "Set Password" %}

-
- {% csrf_token %} - {{ form|crispy }} - -
-
-
-
+
+ {% csrf_token %} + {{ form|crispy }} + +
{% endblock %} {% endraw %} diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/signup.html b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/signup.html index 63e57a5fc..80490a2e1 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/signup.html +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/signup.html @@ -3,31 +3,21 @@ {% load i18n %} {% load crispy_forms_tags %} -{% block title %}{% trans "Signup" %}{% endblock title %} +{% block head_title %}{% trans "Signup" %}{% endblock %} -{% block content %} +{% block inner %} +

{% trans "Sign Up" %}

-
-
-
-

{% trans "Sign Up" %}

- -

{% blocktrans %}Already have an account? Then please sign in.{% endblocktrans %}

- - -
-
-
- - -{% endblock content %} +

{% blocktrans %}Already have an account? Then please sign in.{% endblocktrans %}

+ +{% endblock %} {% endraw %} diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/signup_closed.html b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/signup_closed.html index f5976dad5..eca9b1568 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/signup_closed.html +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/signup_closed.html @@ -4,15 +4,9 @@ {% block head_title %}{% trans "Sign Up Closed" %}{% endblock %} -{% block content %} -
-
-
-

{% trans "Sign Up Closed" %}

+{% block inner %} +

{% trans "Sign Up Closed" %}

-

{% trans "We are sorry, but the sign up is currently closed." %}

-
-
-
+

{% trans "We are sorry, but the sign up is currently closed." %}

{% endblock %} {% endraw %} diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/verification_sent.html b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/verification_sent.html index 0c082288c..ccc8d9a1f 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/verification_sent.html +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/verification_sent.html @@ -4,16 +4,10 @@ {% block head_title %}{% trans "Verify Your E-mail Address" %}{% endblock %} -{% block content %} -
-
-
-

{% trans "Verify Your E-mail Address" %}

- -

{% blocktrans %}We have sent an e-mail to {{ email }} for verification. Follow the link provided to finalize the signup process. Please contact us if you do not receive it within a few minutes.{% endblocktrans %}

-
-
-
+{% block inner %} +

{% trans "Verify Your E-mail Address" %}

+ +

{% blocktrans %}We have sent an e-mail to you for verification. Follow the link provided to finalize the signup process. Please contact us if you do not receive it within a few minutes.{% endblocktrans %}

{% endblock %} -{% endraw %} \ No newline at end of file +{% endraw %} diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/verified_email_required.html b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/verified_email_required.html index 7d071c6a6..f3078b68e 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/verified_email_required.html +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/verified_email_required.html @@ -4,25 +4,21 @@ {% block head_title %}{% trans "Verify Your E-mail Address" %}{% endblock %} -{% block content %} -
-
-
-

{% trans "Verify Your E-mail Address" %}

+{% block inner %} +

{% trans "Verify Your E-mail Address" %}

- {% url 'account_email' as email_url %} +{% url 'account_email' as email_url %} -

{% blocktrans %}This part of the site requires us to verify that - you are who you claim to be. For this purpose, we require that you - verify ownership of your e-mail address. {% endblocktrans %}

+

{% blocktrans %}This part of the site requires us to verify that +you are who you claim to be. For this purpose, we require that you +verify ownership of your e-mail address. {% endblocktrans %}

+ +

{% blocktrans %}We have sent an e-mail to you for +verification. Please click on the link inside this e-mail. Please +contact us if you do not receive it within a few minutes.{% endblocktrans %}

+ +

{% blocktrans %}Note: you can still change your e-mail address.{% endblocktrans %}

-

{% blocktrans %}We have sent an e-mail to you for - verification. Please click on the link inside this e-mail. Please - contact us if you do not receive it within a few minutes.{% endblocktrans %}

-

{% blocktrans %}Note: you can still change your e-mail address.{% endblocktrans %}

-
-
-
{% endblock %} {% endraw %} diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/base.html b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/base.html index b54692228..64ddaa418 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/base.html +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/base.html @@ -1,5 +1,5 @@ -{% raw %}{% load staticfiles i18n %} - +{% raw %}{% load staticfiles i18n {% endraw %}{% if cookiecutter.use_compressor == "y" %}compress{% endif %}{% raw %}%} + @@ -14,24 +14,21 @@ {% block css %} - - + + - - - + + {% endraw %}{% if cookiecutter.use_compressor == "y" %}{% raw %}{% compress css %}{% endraw %}{% endif %}{% raw %} + + {% endraw %}{% if cookiecutter.use_compressor == "y" %}{% raw %}{% endcompress %}{% endraw %}{% endif %}{% raw %} {% endblock %} - {% endraw %}{% if cookiecutter.use_angular == "y" %}{% raw %}{% block angular %} - - {% endblock %}{% endraw %}{% endif %}{% raw %} - -
+