From e1d76ea25ee164a1241cb66ee6d862b7eb6f8ef1 Mon Sep 17 00:00:00 2001 From: Adam Dobrawy Date: Sun, 18 Oct 2015 13:58:41 +0200 Subject: [PATCH 01/14] Add factories for users --- .../users/tests/factories.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/tests/factories.py diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/tests/factories.py b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/tests/factories.py new file mode 100644 index 00000000..aa35d3b7 --- /dev/null +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/tests/factories.py @@ -0,0 +1,10 @@ +from feder.users import models +import factory + + +class UserFactory(factory.django.DjangoModelFactory): + username = factory.Sequence(lambda n: 'user-{0}'.format(n)) + email = factory.Sequence(lambda n: 'user-{0}@example.com'.format(n)) + + class Meta: + model = models.User From 88c6a1775b04bee1d2a95aa09d2411a4211169a5 Mon Sep 17 00:00:00 2001 From: Adam Dobrawy Date: Thu, 12 Nov 2015 05:51:15 +0100 Subject: [PATCH 02/14] Added default password to UserFactory --- .../{{cookiecutter.repo_name}}/users/tests/factories.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/tests/factories.py b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/tests/factories.py index aa35d3b7..aa5a04a7 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/tests/factories.py +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/tests/factories.py @@ -5,6 +5,8 @@ import factory class UserFactory(factory.django.DjangoModelFactory): username = factory.Sequence(lambda n: 'user-{0}'.format(n)) email = factory.Sequence(lambda n: 'user-{0}@example.com'.format(n)) + password = factory.PosteGnerationMethodCall('set_password', 'password') class Meta: - model = models.User + model = 'users.User' + django_get_or_create = ('username', ) From 794c9f1ce78f7e74e916675f7f388fa93df445a5 Mon Sep 17 00:00:00 2001 From: Adam Dobrawy Date: Thu, 12 Nov 2015 05:54:38 +0100 Subject: [PATCH 03/14] Fix flake erros in UserFactory --- .../{{cookiecutter.repo_name}}/users/tests/factories.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/tests/factories.py b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/tests/factories.py index aa5a04a7..e36ba8f7 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/tests/factories.py +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/tests/factories.py @@ -8,5 +8,5 @@ class UserFactory(factory.django.DjangoModelFactory): password = factory.PosteGnerationMethodCall('set_password', 'password') class Meta: - model = 'users.User' + model = models.User django_get_or_create = ('username', ) From c86d5c928cdefd09aca102b2a5c37f662e1426a6 Mon Sep 17 00:00:00 2001 From: Adam Dobrawy Date: Sat, 14 Nov 2015 14:15:00 +0100 Subject: [PATCH 04/14] Fix typo & import in UserFactory --- .../{{cookiecutter.repo_name}}/users/tests/factories.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/tests/factories.py b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/tests/factories.py index e36ba8f7..e2c967de 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/tests/factories.py +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/tests/factories.py @@ -1,12 +1,11 @@ -from feder.users import models import factory class UserFactory(factory.django.DjangoModelFactory): username = factory.Sequence(lambda n: 'user-{0}'.format(n)) email = factory.Sequence(lambda n: 'user-{0}@example.com'.format(n)) - password = factory.PosteGnerationMethodCall('set_password', 'password') + password = factory.PostGenerationMethodCall('set_password', 'password') class Meta: - model = models.User + model = 'users.User' django_get_or_create = ('username', ) From 9920c6d5b9559536e407abadd392443dff75962e Mon Sep 17 00:00:00 2001 From: Burhan Khalid Date: Mon, 16 Nov 2015 14:20:19 +0300 Subject: [PATCH 05/14] upstream merge --- README.rst | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/README.rst b/README.rst index 3a607447..a6153068 100644 --- a/README.rst +++ b/README.rst @@ -32,14 +32,20 @@ Features * Grunt build for compass and livereload * Basic e-mail configurations for sending emails via Mailgun_ * Media storage using Amazon S3 -* Serve static files from Amazon S3 or Whitenoise_ (optional) -* Pre configured Celery_ (optional) -* Integration with Maildump_ for local email testing (optional) -* Integration with Sentry_ for error logging (optional) -* Integration with NewRelic_ for performance monitoring (optional) -* Docker support using docker-compose_ for dev and prod +* Docker support using docker-compose_ for development and production * Procfile_ for deploying to Heroku +Optional Integrations +--------------------- + +*These features can be enabled during initial project setup.* + +* Serve static files from Amazon S3 or Whitenoise_ +* Configuration for Celery_ +* Integration with Maildump_ for local email testing +* Integration with Sentry_ for error logging +* Integration with NewRelic_ for performance monitoring + .. _alpha: http://blog.getbootstrap.com/2015/08/19/bootstrap-4-alpha/ .. _Hitch: https://github.com/hitchtest/hitchtest .. _Bootstrap: https://github.com/twbs/bootstrap From 9c28c8e0df4a3e7d35cda2d72b1b04673297c96a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20C=2E=20Barrionuevo=20da=20Luz?= Date: Mon, 16 Nov 2015 08:36:51 -0300 Subject: [PATCH 06/14] Update CHANGELOG.md --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bfe913a9..ce362886 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ All enhancements and patches to cookiecutter-django will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [2015-11-16] +### Changed +- Cleanup of main README (@burhan) + +## [2015-11-15] +### Added +- Added `UserFactory` for users.User tests (@ad-m) + ## [2015-11-12] ### Changed - Update version of django-allauth (@yunti) From 727281e99ada711d53639a9fdbb27312e0606027 Mon Sep 17 00:00:00 2001 From: Burhan Khalid Date: Mon, 16 Nov 2015 18:55:37 +0300 Subject: [PATCH 07/14] initial configuration to support opbeat --- README.rst | 3 +++ cookiecutter.json | 1 + docs/settings.rst | 3 +++ .../config/settings/production.py | 18 +++++++++++++++++- .../requirements/production.txt | 6 ++++++ 5 files changed, 30 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index a6153068..f44db093 100644 --- a/README.rst +++ b/README.rst @@ -45,6 +45,7 @@ Optional Integrations * Integration with Maildump_ 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/ .. _Hitch: https://github.com/hitchtest/hitchtest @@ -62,6 +63,7 @@ Optional Integrations .. _Sentry: https://getsentry.com .. _NewRelic: https://newrelic.com .. _docker-compose: https://www.github.com/docker/compose +.. _Opbeat: https://opbeat.com/ Constraints @@ -116,6 +118,7 @@ It prompts you for questions. Answer them:: use_maildump [n]: n use_sentry [n]: y use_newrelic [n]: y + use_obpeat [n]: y windows [n]: n use_python2 [n]: y diff --git a/cookiecutter.json b/cookiecutter.json index 213c1842..4367b8b1 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -14,6 +14,7 @@ "use_maildump": "n", "use_sentry": "n", "use_newrelic": "n", + "use_opbeat": "n", "windows": "n", "use_python2": "n" } diff --git a/docs/settings.rst b/docs/settings.rst index 08a95bf0..bdd2075f 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -41,4 +41,7 @@ DJANGO_SENTRY_LOG_LEVEL SENTRY_LOG_LEVEL n/a DJANGO_MAILGUN_API_KEY MAILGUN_ACCESS_KEY n/a raises error DJANGO_MAILGUN_SERVER_NAME MAILGUN_SERVER_NAME n/a raises error NEW_RELIC_LICENSE_KEY NEW_RELIC_LICENSE_KEY n/a raises error +DJANGO_OPBEAT_APP_ID OPBEAT['APP_ID'] n/a raises error +DJANGO_OPBEAT_SECRET_TOKEN OPBEAT['SECRET_TOKEN'] n/a raises error +DJANGO_OPBEAT_ORGANIZATION_ID OPBEAT['ORGANIZATION_ID'] n/a raises error ======================================= =========================== ============================================== ====================================================================== diff --git a/{{cookiecutter.repo_name}}/config/settings/production.py b/{{cookiecutter.repo_name}}/config/settings/production.py index 27ba946e..c065f6fc 100644 --- a/{{cookiecutter.repo_name}}/config/settings/production.py +++ b/{{cookiecutter.repo_name}}/config/settings/production.py @@ -9,6 +9,9 @@ Production Configurations {% if cookiecutter.use_sentry == "y" %} - Use sentry for error logging {% endif %} +{% if cookiecutter.use_opbeat == "y" %} +- Use opbeat for error reporting +{% endif %} ''' from __future__ import absolute_import, unicode_literals @@ -18,6 +21,7 @@ from django.utils import six import logging {% endif %} + from .common import * # noqa # SECRET CONFIGURATION @@ -52,7 +56,19 @@ MIDDLEWARE_CLASSES = SECURITY_MIDDLEWARE + \ MIDDLEWARE_CLASSES = SECURITY_MIDDLEWARE + MIDDLEWARE_CLASSES {%- endif %} - +{% if cookiecutter.use_opbeat == "y" -%} +# opbeat integration +# See https://opbeat.com/languages/django/ +INSTALLED_APPS += ('opbeat.contrib.django',) +OPBEAT = { + 'ORGANIZATION_ID': env('DJANGO_OPBEAT_ORGANIZATION_ID'), + 'APP_ID': env('DJANGO_OPBEAT_APP_ID'), + 'SECRET_TOKEN': env('DJANGO_OPBEAT_SECRET_TOKEN') +} +MIDDLEWARE_CLASSES += ( + 'opbeat.contrib.django.middleware.OpbeatAPMMiddleware', +) +{%- endif %} # 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( diff --git a/{{cookiecutter.repo_name}}/requirements/production.txt b/{{cookiecutter.repo_name}}/requirements/production.txt index 4a0939a0..b64f3dd7 100644 --- a/{{cookiecutter.repo_name}}/requirements/production.txt +++ b/{{cookiecutter.repo_name}}/requirements/production.txt @@ -37,3 +37,9 @@ raven # ----------------------------------------- newrelic {%- endif %} + +{% if cookiecutter.use_opbeat == "y" -%} +# Opbeat agent for performance monitoring +# ----------------------------------------- +opbeat +{%- endif %} From a68f256e5b23424a323e0ef78a0660cecf52e4de Mon Sep 17 00:00:00 2001 From: Burhan Khalid Date: Mon, 16 Nov 2015 19:04:07 +0300 Subject: [PATCH 08/14] fixing the middleware order --- {{cookiecutter.repo_name}}/config/settings/production.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/{{cookiecutter.repo_name}}/config/settings/production.py b/{{cookiecutter.repo_name}}/config/settings/production.py index c065f6fc..09d11ef3 100644 --- a/{{cookiecutter.repo_name}}/config/settings/production.py +++ b/{{cookiecutter.repo_name}}/config/settings/production.py @@ -65,9 +65,9 @@ OPBEAT = { 'APP_ID': env('DJANGO_OPBEAT_APP_ID'), 'SECRET_TOKEN': env('DJANGO_OPBEAT_SECRET_TOKEN') } -MIDDLEWARE_CLASSES += ( +MIDDLEWARE_CLASSES = ( 'opbeat.contrib.django.middleware.OpbeatAPMMiddleware', -) +) + MIDDLEWARE_CLASSES {%- endif %} # set this to 60 seconds and then to 518400 when you can prove it works SECURE_HSTS_SECONDS = 60 From 07ec413f98b14c055c05adcda5d283bd24ceeda8 Mon Sep 17 00:00:00 2001 From: Burhan Khalid Date: Mon, 16 Nov 2015 19:20:15 +0300 Subject: [PATCH 09/14] E303 too many blank lines fix --- {{cookiecutter.repo_name}}/config/settings/production.py | 1 - 1 file changed, 1 deletion(-) diff --git a/{{cookiecutter.repo_name}}/config/settings/production.py b/{{cookiecutter.repo_name}}/config/settings/production.py index 09d11ef3..be16818a 100644 --- a/{{cookiecutter.repo_name}}/config/settings/production.py +++ b/{{cookiecutter.repo_name}}/config/settings/production.py @@ -21,7 +21,6 @@ from django.utils import six import logging {% endif %} - from .common import * # noqa # SECRET CONFIGURATION From b78b2ddf7356d5a18ee0d4969b4b98adf5501719 Mon Sep 17 00:00:00 2001 From: Burhan Khalid Date: Mon, 16 Nov 2015 21:24:21 +0300 Subject: [PATCH 10/14] fixing error in settings --- docs/settings.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/settings.rst b/docs/settings.rst index 08a95bf0..78a4053a 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -24,7 +24,7 @@ DJANGO_SESSION_COOKIE_SECURE SESSION_COOKIE_SECURE n/a DJANGO_DEFAULT_FROM_EMAIL DEFAULT_FROM_EMAIL n/a "your_project_name " DJANGO_SERVER_EMAIL SERVER_EMAIL n/a "your_project_name " DJANGO_EMAIL_SUBJECT_PREFIX EMAIL_SUBJECT_PREFIX n/a "[your_project_name] " -DJANGO_ALLOWED_HOSTS ALLOWED_HOSTS ['*'] ['your_project_name}'] +DJANGO_ALLOWED_HOSTS ALLOWED_HOSTS ['*'] ['your_domain_name'] ======================================= =========================== ============================================== ====================================================================== The following table lists settings and their defaults for third-party applications, which may or may be part of your project: From 4c07b5dea68ab099cea68b8d04442d60b42f1c8f Mon Sep 17 00:00:00 2001 From: Burhan Khalid Date: Mon, 16 Nov 2015 18:55:37 +0300 Subject: [PATCH 11/14] initial configuration to support opbeat --- README.rst | 3 +++ cookiecutter.json | 1 + docs/settings.rst | 3 +++ .../config/settings/production.py | 18 +++++++++++++++++- .../requirements/production.txt | 6 ++++++ 5 files changed, 30 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index a6153068..f44db093 100644 --- a/README.rst +++ b/README.rst @@ -45,6 +45,7 @@ Optional Integrations * Integration with Maildump_ 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/ .. _Hitch: https://github.com/hitchtest/hitchtest @@ -62,6 +63,7 @@ Optional Integrations .. _Sentry: https://getsentry.com .. _NewRelic: https://newrelic.com .. _docker-compose: https://www.github.com/docker/compose +.. _Opbeat: https://opbeat.com/ Constraints @@ -116,6 +118,7 @@ It prompts you for questions. Answer them:: use_maildump [n]: n use_sentry [n]: y use_newrelic [n]: y + use_obpeat [n]: y windows [n]: n use_python2 [n]: y diff --git a/cookiecutter.json b/cookiecutter.json index 213c1842..4367b8b1 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -14,6 +14,7 @@ "use_maildump": "n", "use_sentry": "n", "use_newrelic": "n", + "use_opbeat": "n", "windows": "n", "use_python2": "n" } diff --git a/docs/settings.rst b/docs/settings.rst index 78a4053a..629e60f4 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -41,4 +41,7 @@ DJANGO_SENTRY_LOG_LEVEL SENTRY_LOG_LEVEL n/a DJANGO_MAILGUN_API_KEY MAILGUN_ACCESS_KEY n/a raises error DJANGO_MAILGUN_SERVER_NAME MAILGUN_SERVER_NAME n/a raises error NEW_RELIC_LICENSE_KEY NEW_RELIC_LICENSE_KEY n/a raises error +DJANGO_OPBEAT_APP_ID OPBEAT['APP_ID'] n/a raises error +DJANGO_OPBEAT_SECRET_TOKEN OPBEAT['SECRET_TOKEN'] n/a raises error +DJANGO_OPBEAT_ORGANIZATION_ID OPBEAT['ORGANIZATION_ID'] n/a raises error ======================================= =========================== ============================================== ====================================================================== diff --git a/{{cookiecutter.repo_name}}/config/settings/production.py b/{{cookiecutter.repo_name}}/config/settings/production.py index 27ba946e..c065f6fc 100644 --- a/{{cookiecutter.repo_name}}/config/settings/production.py +++ b/{{cookiecutter.repo_name}}/config/settings/production.py @@ -9,6 +9,9 @@ Production Configurations {% if cookiecutter.use_sentry == "y" %} - Use sentry for error logging {% endif %} +{% if cookiecutter.use_opbeat == "y" %} +- Use opbeat for error reporting +{% endif %} ''' from __future__ import absolute_import, unicode_literals @@ -18,6 +21,7 @@ from django.utils import six import logging {% endif %} + from .common import * # noqa # SECRET CONFIGURATION @@ -52,7 +56,19 @@ MIDDLEWARE_CLASSES = SECURITY_MIDDLEWARE + \ MIDDLEWARE_CLASSES = SECURITY_MIDDLEWARE + MIDDLEWARE_CLASSES {%- endif %} - +{% if cookiecutter.use_opbeat == "y" -%} +# opbeat integration +# See https://opbeat.com/languages/django/ +INSTALLED_APPS += ('opbeat.contrib.django',) +OPBEAT = { + 'ORGANIZATION_ID': env('DJANGO_OPBEAT_ORGANIZATION_ID'), + 'APP_ID': env('DJANGO_OPBEAT_APP_ID'), + 'SECRET_TOKEN': env('DJANGO_OPBEAT_SECRET_TOKEN') +} +MIDDLEWARE_CLASSES += ( + 'opbeat.contrib.django.middleware.OpbeatAPMMiddleware', +) +{%- endif %} # 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( diff --git a/{{cookiecutter.repo_name}}/requirements/production.txt b/{{cookiecutter.repo_name}}/requirements/production.txt index 4a0939a0..b64f3dd7 100644 --- a/{{cookiecutter.repo_name}}/requirements/production.txt +++ b/{{cookiecutter.repo_name}}/requirements/production.txt @@ -37,3 +37,9 @@ raven # ----------------------------------------- newrelic {%- endif %} + +{% if cookiecutter.use_opbeat == "y" -%} +# Opbeat agent for performance monitoring +# ----------------------------------------- +opbeat +{%- endif %} From f4a75e0d1070e12b2d7de01745da77244e776b61 Mon Sep 17 00:00:00 2001 From: Burhan Khalid Date: Mon, 16 Nov 2015 19:04:07 +0300 Subject: [PATCH 12/14] fixing the middleware order --- {{cookiecutter.repo_name}}/config/settings/production.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/{{cookiecutter.repo_name}}/config/settings/production.py b/{{cookiecutter.repo_name}}/config/settings/production.py index c065f6fc..09d11ef3 100644 --- a/{{cookiecutter.repo_name}}/config/settings/production.py +++ b/{{cookiecutter.repo_name}}/config/settings/production.py @@ -65,9 +65,9 @@ OPBEAT = { 'APP_ID': env('DJANGO_OPBEAT_APP_ID'), 'SECRET_TOKEN': env('DJANGO_OPBEAT_SECRET_TOKEN') } -MIDDLEWARE_CLASSES += ( +MIDDLEWARE_CLASSES = ( 'opbeat.contrib.django.middleware.OpbeatAPMMiddleware', -) +) + MIDDLEWARE_CLASSES {%- endif %} # set this to 60 seconds and then to 518400 when you can prove it works SECURE_HSTS_SECONDS = 60 From 03edea302172c84e806acc0b2cbea10edabedec2 Mon Sep 17 00:00:00 2001 From: Burhan Khalid Date: Mon, 16 Nov 2015 19:20:15 +0300 Subject: [PATCH 13/14] E303 too many blank lines fix --- {{cookiecutter.repo_name}}/config/settings/production.py | 1 - 1 file changed, 1 deletion(-) diff --git a/{{cookiecutter.repo_name}}/config/settings/production.py b/{{cookiecutter.repo_name}}/config/settings/production.py index 09d11ef3..be16818a 100644 --- a/{{cookiecutter.repo_name}}/config/settings/production.py +++ b/{{cookiecutter.repo_name}}/config/settings/production.py @@ -21,7 +21,6 @@ from django.utils import six import logging {% endif %} - from .common import * # noqa # SECRET CONFIGURATION From e2c700da5cb50d63ff6c969db3fb901b1d014758 Mon Sep 17 00:00:00 2001 From: Burhan Khalid Date: Tue, 17 Nov 2015 10:27:58 +0300 Subject: [PATCH 14/14] updating env.example --- {{cookiecutter.repo_name}}/env.example | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/{{cookiecutter.repo_name}}/env.example b/{{cookiecutter.repo_name}}/env.example index 3420db7c..edc5454b 100644 --- a/{{cookiecutter.repo_name}}/env.example +++ b/{{cookiecutter.repo_name}}/env.example @@ -18,3 +18,8 @@ DJANGO_SENTRY_DSN= {% if cookiecutter.use_newrelic == 'y' -%} NEW_RELIC_LICENSE_KEY {% endif %} +{% if cookiecutter.use_opbeat == 'y' -%} +DJANGO_OPBEAT_ORGANIZATION_ID +DJANGO_OPBEAT_APP_ID +DJANGO_OPBEAT_SECRET_TOKEN +{% endif %}