mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-14 05:36:58 +03:00
Quote consistency
This commit is contained in:
parent
f2ffd5ad5e
commit
a300f1190d
18
docs/conf.py
18
docs/conf.py
|
@ -10,6 +10,8 @@
|
||||||
# All configuration values have a default; values that are commented out
|
# All configuration values have a default; values that are commented out
|
||||||
# serve to show the default.
|
# serve to show the default.
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
@ -43,8 +45,8 @@ source_suffix = '.rst'
|
||||||
master_doc = 'index'
|
master_doc = 'index'
|
||||||
|
|
||||||
# General information about the project.
|
# General information about the project.
|
||||||
project = u'cookiecutter-django'
|
project = 'cookiecutter-django'
|
||||||
copyright = u"2013-{}, Daniel Roy Greenfeld".format(now.year)
|
copyright = '2013-{}, Daniel Roy Greenfeld'.format(now.year)
|
||||||
|
|
||||||
# The version info for the project you're documenting, acts as replacement for
|
# The version info for the project you're documenting, acts as replacement for
|
||||||
# |version| and |release|, also used in various other places throughout the
|
# |version| and |release|, also used in various other places throughout the
|
||||||
|
@ -188,8 +190,8 @@ latex_elements = {
|
||||||
latex_documents = [
|
latex_documents = [
|
||||||
('index',
|
('index',
|
||||||
'cookiecutter-django.tex',
|
'cookiecutter-django.tex',
|
||||||
u'cookiecutter-django Documentation',
|
'cookiecutter-django Documentation',
|
||||||
u"cookiecutter-django", 'manual'),
|
'cookiecutter-django', 'manual'),
|
||||||
]
|
]
|
||||||
|
|
||||||
# The name of an image file (relative to this directory) to place at the top of
|
# The name of an image file (relative to this directory) to place at the top of
|
||||||
|
@ -218,8 +220,8 @@ latex_documents = [
|
||||||
# One entry per manual page. List of tuples
|
# One entry per manual page. List of tuples
|
||||||
# (source start file, name, description, authors, manual section).
|
# (source start file, name, description, authors, manual section).
|
||||||
man_pages = [
|
man_pages = [
|
||||||
('index', 'cookiecutter-django', u'cookiecutter-django documentation',
|
('index', 'cookiecutter-django', 'cookiecutter-django documentation',
|
||||||
[u"Daniel Roy Greenfeld"], 1)
|
['Daniel Roy Greenfeld'], 1)
|
||||||
]
|
]
|
||||||
|
|
||||||
# If true, show URL addresses after external links.
|
# If true, show URL addresses after external links.
|
||||||
|
@ -232,8 +234,8 @@ man_pages = [
|
||||||
# (source start file, target name, title, author,
|
# (source start file, target name, title, author,
|
||||||
# dir menu entry, description, category)
|
# dir menu entry, description, category)
|
||||||
texinfo_documents = [
|
texinfo_documents = [
|
||||||
('index', 'cookiecutter-django', u'cookiecutter-django documentation',
|
('index', 'cookiecutter-django', 'cookiecutter-django documentation',
|
||||||
u"Daniel Roy Greenfeld", 'cookiecutter-django',
|
'Daniel Roy Greenfeld', 'cookiecutter-django',
|
||||||
'A Cookiecutter template for creating production-ready Django projects quickly.', 'Miscellaneous'),
|
'A Cookiecutter template for creating production-ready Django projects quickly.', 'Miscellaneous'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
7
setup.py
7
setup.py
|
@ -1,7 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import platform
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -11,11 +10,11 @@ except ImportError:
|
||||||
|
|
||||||
# Our version ALWAYS matches the version of Django we support
|
# 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.
|
# If Django has a new release, we branch, tag, then update this setting after the tag.
|
||||||
version = "1.9.4"
|
version = '1.9.4'
|
||||||
|
|
||||||
if sys.argv[-1] == 'tag':
|
if sys.argv[-1] == 'tag':
|
||||||
os.system("git tag -a %s -m 'version %s'" % (version, version))
|
os.system('git tag -a %s -m "version %s"' % (version, version))
|
||||||
os.system("git push --tags")
|
os.system('git push --tags')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
with open('README.rst') as readme_file:
|
with open('README.rst') as readme_file:
|
||||||
|
|
|
@ -7,23 +7,23 @@ import sh
|
||||||
import pytest
|
import pytest
|
||||||
from binaryornot.check import is_binary
|
from binaryornot.check import is_binary
|
||||||
|
|
||||||
PATTERN = "{{(\s?cookiecutter)[.](.*?)}}"
|
PATTERN = '{{(\s?cookiecutter)[.](.*?)}}'
|
||||||
RE_OBJ = re.compile(PATTERN)
|
RE_OBJ = re.compile(PATTERN)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def context():
|
def context():
|
||||||
return {
|
return {
|
||||||
"project_name": "My Test Project",
|
'project_name': 'My Test Project',
|
||||||
"repo_name": "my_test_project",
|
'repo_name': 'my_test_project',
|
||||||
"author_name": "Test Author",
|
'author_name': 'Test Author',
|
||||||
"email": "test@example.com",
|
'email': 'test@example.com',
|
||||||
"description": "A short description of the project.",
|
'description': 'A short description of the project.',
|
||||||
"domain_name": "example.com",
|
'domain_name': 'example.com',
|
||||||
"version": "0.1.0",
|
'version': '0.1.0',
|
||||||
"timezone": "UTC",
|
'timezone': 'UTC',
|
||||||
"now": "2015/01/13",
|
'now': '2015/01/13',
|
||||||
"year": "2015"
|
'year': '2015'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ def check_paths(paths):
|
||||||
continue
|
continue
|
||||||
for line in open(path, 'r'):
|
for line in open(path, 'r'):
|
||||||
match = RE_OBJ.search(line)
|
match = RE_OBJ.search(line)
|
||||||
msg = "cookiecutter variable not replaced in {}"
|
msg = 'cookiecutter variable not replaced in {}'
|
||||||
assert match is None, msg.format(path)
|
assert match is None, msg.format(path)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ MIGRATION_MODULES = {
|
||||||
# DEBUG
|
# DEBUG
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#debug
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#debug
|
||||||
DEBUG = env.bool("DJANGO_DEBUG", False)
|
DEBUG = env.bool('DJANGO_DEBUG', False)
|
||||||
|
|
||||||
# FIXTURE CONFIGURATION
|
# FIXTURE CONFIGURATION
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
@ -99,7 +99,7 @@ MANAGERS = ADMINS
|
||||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#databases
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#databases
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
# Raises ImproperlyConfigured exception if DATABASE_URL not in os.environ
|
# Raises ImproperlyConfigured exception if DATABASE_URL not in os.environ
|
||||||
'default': env.db("DATABASE_URL", default="postgres://{% if cookiecutter.windows == 'y' %}localhost{% endif %}/{{cookiecutter.repo_name}}"),
|
'default': env.db('DATABASE_URL', default='postgres://{% if cookiecutter.windows == 'y' %}localhost{% endif %}/{{cookiecutter.repo_name}}'),
|
||||||
}
|
}
|
||||||
DATABASES['default']['ATOMIC_REQUESTS'] = True
|
DATABASES['default']['ATOMIC_REQUESTS'] = True
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ ACCOUNT_AUTHENTICATION_METHOD = 'username'
|
||||||
ACCOUNT_EMAIL_REQUIRED = True
|
ACCOUNT_EMAIL_REQUIRED = True
|
||||||
ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
|
ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
|
||||||
|
|
||||||
ACCOUNT_ALLOW_REGISTRATION = env.bool("DJANGO_ACCOUNT_ALLOW_REGISTRATION", True)
|
ACCOUNT_ALLOW_REGISTRATION = env.bool('DJANGO_ACCOUNT_ALLOW_REGISTRATION', True)
|
||||||
ACCOUNT_ADAPTER = '{{cookiecutter.repo_name}}.users.adapters.AccountAdapter'
|
ACCOUNT_ADAPTER = '{{cookiecutter.repo_name}}.users.adapters.AccountAdapter'
|
||||||
SOCIALACCOUNT_ADAPTER = '{{cookiecutter.repo_name}}.users.adapters.SocialAccountAdapter'
|
SOCIALACCOUNT_ADAPTER = '{{cookiecutter.repo_name}}.users.adapters.SocialAccountAdapter'
|
||||||
|
|
||||||
|
@ -224,12 +224,12 @@ LOGIN_URL = 'account_login'
|
||||||
|
|
||||||
# SLUGLIFIER
|
# SLUGLIFIER
|
||||||
AUTOSLUG_SLUGIFY_FUNCTION = 'slugify.slugify'
|
AUTOSLUG_SLUGIFY_FUNCTION = 'slugify.slugify'
|
||||||
{% if cookiecutter.use_celery == "y" %}
|
{% if cookiecutter.use_celery == 'y' %}
|
||||||
########## CELERY
|
########## CELERY
|
||||||
INSTALLED_APPS += ('{{cookiecutter.repo_name}}.taskapp.celery.CeleryConfig',)
|
INSTALLED_APPS += ('{{cookiecutter.repo_name}}.taskapp.celery.CeleryConfig',)
|
||||||
# if you are not using the django database broker (e.g. rabbitmq, redis, memcached), you can remove the next line.
|
# 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',)
|
INSTALLED_APPS += ('kombu.transport.django',)
|
||||||
BROKER_URL = env("CELERY_BROKER_URL", default='django://')
|
BROKER_URL = env('CELERY_BROKER_URL', default='django://')
|
||||||
########## END CELERY
|
########## END CELERY
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
'''
|
"""
|
||||||
Local settings
|
Local settings
|
||||||
|
|
||||||
- Run in Debug mode
|
- Run in Debug mode
|
||||||
- Use console backend for emails
|
- Use console backend for emails
|
||||||
- Add Django Debug Toolbar
|
- Add Django Debug Toolbar
|
||||||
- Add django-extensions as app
|
- Add django-extensions as app
|
||||||
'''
|
"""
|
||||||
|
|
||||||
from .common import * # noqa
|
from .common import * # noqa
|
||||||
|
|
||||||
|
@ -19,13 +19,13 @@ TEMPLATES[0]['OPTIONS']['debug'] = DEBUG
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
|
||||||
# Note: This key only used for development and testing.
|
# Note: This key only used for development and testing.
|
||||||
SECRET_KEY = env("DJANGO_SECRET_KEY", default='CHANGEME!!!')
|
SECRET_KEY = env('DJANGO_SECRET_KEY', default='CHANGEME!!!')
|
||||||
|
|
||||||
# Mail settings
|
# Mail settings
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
EMAIL_HOST = 'localhost'
|
EMAIL_HOST = 'localhost'
|
||||||
EMAIL_PORT = 1025
|
EMAIL_PORT = 1025
|
||||||
{%if cookiecutter.use_mailhog == "n" -%}
|
{%if cookiecutter.use_mailhog == 'n' -%}
|
||||||
EMAIL_BACKEND = env('DJANGO_EMAIL_BACKEND',
|
EMAIL_BACKEND = env('DJANGO_EMAIL_BACKEND',
|
||||||
default='django.core.mail.backends.console.EmailBackend')
|
default='django.core.mail.backends.console.EmailBackend')
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
@ -60,7 +60,7 @@ INSTALLED_APPS += ('django_extensions', )
|
||||||
# TESTING
|
# TESTING
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
TEST_RUNNER = 'django.test.runner.DiscoverRunner'
|
TEST_RUNNER = 'django.test.runner.DiscoverRunner'
|
||||||
{% if cookiecutter.use_celery == "y" %}
|
{% if cookiecutter.use_celery == 'y' %}
|
||||||
########## CELERY
|
########## CELERY
|
||||||
# In development, all tasks will be executed locally by blocking until the task returns
|
# In development, all tasks will be executed locally by blocking until the task returns
|
||||||
CELERY_ALWAYS_EAGER = True
|
CELERY_ALWAYS_EAGER = True
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
'''
|
"""
|
||||||
Production Configurations
|
Production Configurations
|
||||||
|
|
||||||
- Use djangosecure
|
- Use djangosecure
|
||||||
- Use Amazon's S3 for storing static files and uploaded media
|
- Use Amazon's S3 for storing static files and uploaded media
|
||||||
- Use mailgun to send emails
|
- Use mailgun to send emails
|
||||||
- Use Redis on Heroku
|
- Use Redis on Heroku
|
||||||
{% if cookiecutter.use_sentry == "y" %}
|
{% if cookiecutter.use_sentry == 'y' %}
|
||||||
- Use sentry for error logging
|
- Use sentry for error logging
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if cookiecutter.use_opbeat == "y" %}
|
{% if cookiecutter.use_opbeat == 'y' %}
|
||||||
- Use opbeat for error reporting
|
- Use opbeat for error reporting
|
||||||
{% endif %}
|
{% endif %}
|
||||||
'''
|
"""
|
||||||
from __future__ import absolute_import, unicode_literals
|
from __future__ import absolute_import, unicode_literals
|
||||||
|
|
||||||
from boto.s3.connection import OrdinaryCallingFormat
|
from boto.s3.connection import OrdinaryCallingFormat
|
||||||
from django.utils import six
|
from django.utils import six
|
||||||
{% if cookiecutter.use_sentry == "y" %}
|
{% if cookiecutter.use_sentry == 'y' %}
|
||||||
import logging
|
import logging
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ from .common import * # noqa
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
|
||||||
# Raises ImproperlyConfigured exception if DJANGO_SECRET_KEY not in os.environ
|
# Raises ImproperlyConfigured exception if DJANGO_SECRET_KEY not in os.environ
|
||||||
SECRET_KEY = env("DJANGO_SECRET_KEY")
|
SECRET_KEY = env('DJANGO_SECRET_KEY')
|
||||||
|
|
||||||
# This ensures that Django will be able to detect a secure connection
|
# This ensures that Django will be able to detect a secure connection
|
||||||
# properly on Heroku.
|
# properly on Heroku.
|
||||||
|
@ -35,8 +35,8 @@ SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
||||||
|
|
||||||
# django-secure
|
# django-secure
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
INSTALLED_APPS += ("djangosecure", )
|
INSTALLED_APPS += ('djangosecure', )
|
||||||
{% if cookiecutter.use_sentry == "y" -%}
|
{% if cookiecutter.use_sentry == 'y' -%}
|
||||||
# raven sentry client
|
# raven sentry client
|
||||||
# See https://docs.getsentry.com/hosted/clients/python/integrations/django/
|
# See https://docs.getsentry.com/hosted/clients/python/integrations/django/
|
||||||
INSTALLED_APPS += ('raven.contrib.django.raven_compat', )
|
INSTALLED_APPS += ('raven.contrib.django.raven_compat', )
|
||||||
|
@ -44,7 +44,7 @@ INSTALLED_APPS += ('raven.contrib.django.raven_compat', )
|
||||||
SECURITY_MIDDLEWARE = (
|
SECURITY_MIDDLEWARE = (
|
||||||
'djangosecure.middleware.SecurityMiddleware',
|
'djangosecure.middleware.SecurityMiddleware',
|
||||||
)
|
)
|
||||||
{% if cookiecutter.use_sentry == "y" -%}
|
{% if cookiecutter.use_sentry == 'y' -%}
|
||||||
RAVEN_MIDDLEWARE = ('raven.contrib.django.raven_compat.middleware.Sentry404CatchMiddleware',
|
RAVEN_MIDDLEWARE = ('raven.contrib.django.raven_compat.middleware.Sentry404CatchMiddleware',
|
||||||
'raven.contrib.django.raven_compat.middleware.SentryResponseErrorIdMiddleware',)
|
'raven.contrib.django.raven_compat.middleware.SentryResponseErrorIdMiddleware',)
|
||||||
MIDDLEWARE_CLASSES = SECURITY_MIDDLEWARE + \
|
MIDDLEWARE_CLASSES = SECURITY_MIDDLEWARE + \
|
||||||
|
@ -55,7 +55,7 @@ MIDDLEWARE_CLASSES = SECURITY_MIDDLEWARE + \
|
||||||
MIDDLEWARE_CLASSES = SECURITY_MIDDLEWARE + MIDDLEWARE_CLASSES
|
MIDDLEWARE_CLASSES = SECURITY_MIDDLEWARE + MIDDLEWARE_CLASSES
|
||||||
|
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{% if cookiecutter.use_opbeat == "y" -%}
|
{% if cookiecutter.use_opbeat == 'y' -%}
|
||||||
# opbeat integration
|
# opbeat integration
|
||||||
# See https://opbeat.com/languages/django/
|
# See https://opbeat.com/languages/django/
|
||||||
INSTALLED_APPS += ('opbeat.contrib.django',)
|
INSTALLED_APPS += ('opbeat.contrib.django',)
|
||||||
|
@ -71,14 +71,14 @@ MIDDLEWARE_CLASSES = (
|
||||||
# set this to 60 seconds and then to 518400 when you can prove it works
|
# set this to 60 seconds and then to 518400 when you can prove it works
|
||||||
SECURE_HSTS_SECONDS = 60
|
SECURE_HSTS_SECONDS = 60
|
||||||
SECURE_HSTS_INCLUDE_SUBDOMAINS = env.bool(
|
SECURE_HSTS_INCLUDE_SUBDOMAINS = env.bool(
|
||||||
"DJANGO_SECURE_HSTS_INCLUDE_SUBDOMAINS", default=True)
|
'DJANGO_SECURE_HSTS_INCLUDE_SUBDOMAINS', default=True)
|
||||||
SECURE_FRAME_DENY = env.bool("DJANGO_SECURE_FRAME_DENY", default=True)
|
SECURE_FRAME_DENY = env.bool('DJANGO_SECURE_FRAME_DENY', default=True)
|
||||||
SECURE_CONTENT_TYPE_NOSNIFF = env.bool(
|
SECURE_CONTENT_TYPE_NOSNIFF = env.bool(
|
||||||
"DJANGO_SECURE_CONTENT_TYPE_NOSNIFF", default=True)
|
'DJANGO_SECURE_CONTENT_TYPE_NOSNIFF', default=True)
|
||||||
SECURE_BROWSER_XSS_FILTER = True
|
SECURE_BROWSER_XSS_FILTER = True
|
||||||
SESSION_COOKIE_SECURE = False
|
SESSION_COOKIE_SECURE = False
|
||||||
SESSION_COOKIE_HTTPONLY = True
|
SESSION_COOKIE_HTTPONLY = True
|
||||||
SECURE_SSL_REDIRECT = env.bool("DJANGO_SECURE_SSL_REDIRECT", default=True)
|
SECURE_SSL_REDIRECT = env.bool('DJANGO_SECURE_SSL_REDIRECT', default=True)
|
||||||
|
|
||||||
# SITE CONFIGURATION
|
# SITE CONFIGURATION
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
@ -87,7 +87,7 @@ SECURE_SSL_REDIRECT = env.bool("DJANGO_SECURE_SSL_REDIRECT", default=True)
|
||||||
ALLOWED_HOSTS = env.list('DJANGO_ALLOWED_HOSTS', default=['{{cookiecutter.domain_name}}'])
|
ALLOWED_HOSTS = env.list('DJANGO_ALLOWED_HOSTS', default=['{{cookiecutter.domain_name}}'])
|
||||||
# END SITE CONFIGURATION
|
# END SITE CONFIGURATION
|
||||||
|
|
||||||
INSTALLED_APPS += ("gunicorn", )
|
INSTALLED_APPS += ('gunicorn', )
|
||||||
|
|
||||||
# STORAGE CONFIGURATION
|
# STORAGE CONFIGURATION
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
@ -152,7 +152,7 @@ DEFAULT_FROM_EMAIL = env('DJANGO_DEFAULT_FROM_EMAIL',
|
||||||
EMAIL_BACKEND = 'django_mailgun.MailgunBackend'
|
EMAIL_BACKEND = 'django_mailgun.MailgunBackend'
|
||||||
MAILGUN_ACCESS_KEY = env('DJANGO_MAILGUN_API_KEY')
|
MAILGUN_ACCESS_KEY = env('DJANGO_MAILGUN_API_KEY')
|
||||||
MAILGUN_SERVER_NAME = env('DJANGO_MAILGUN_SERVER_NAME')
|
MAILGUN_SERVER_NAME = env('DJANGO_MAILGUN_SERVER_NAME')
|
||||||
EMAIL_SUBJECT_PREFIX = env("DJANGO_EMAIL_SUBJECT_PREFIX", default='[{{cookiecutter.project_name}}] ')
|
EMAIL_SUBJECT_PREFIX = env('DJANGO_EMAIL_SUBJECT_PREFIX', default='[{{cookiecutter.project_name}}] ')
|
||||||
SERVER_EMAIL = env('DJANGO_SERVER_EMAIL', default=DEFAULT_FROM_EMAIL)
|
SERVER_EMAIL = env('DJANGO_SERVER_EMAIL', default=DEFAULT_FROM_EMAIL)
|
||||||
{% if cookiecutter.use_newrelic == 'y'-%}
|
{% if cookiecutter.use_newrelic == 'y'-%}
|
||||||
NEW_RELIC_LICENSE_KEY = env('NEW_RELIC_LICENSE_KEY')
|
NEW_RELIC_LICENSE_KEY = env('NEW_RELIC_LICENSE_KEY')
|
||||||
|
@ -171,24 +171,24 @@ TEMPLATES[0]['OPTIONS']['loaders'] = [
|
||||||
# DATABASE CONFIGURATION
|
# DATABASE CONFIGURATION
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Raises ImproperlyConfigured exception if DATABASE_URL not in os.environ
|
# Raises ImproperlyConfigured exception if DATABASE_URL not in os.environ
|
||||||
DATABASES['default'] = env.db("DATABASE_URL")
|
DATABASES['default'] = env.db('DATABASE_URL')
|
||||||
|
|
||||||
# CACHING
|
# CACHING
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Heroku URL does not pass the DB number, so we parse it in
|
# Heroku URL does not pass the DB number, so we parse it in
|
||||||
CACHES = {
|
CACHES = {
|
||||||
"default": {
|
'default': {
|
||||||
"BACKEND": "django_redis.cache.RedisCache",
|
'BACKEND': 'django_redis.cache.RedisCache',
|
||||||
"LOCATION": "{0}/{1}".format(env('REDIS_URL', default="redis://127.0.0.1:6379"), 0),
|
'LOCATION': '{0}/{1}'.format(env('REDIS_URL', default='redis://127.0.0.1:6379'), 0),
|
||||||
"OPTIONS": {
|
'OPTIONS': {
|
||||||
"CLIENT_CLASS": "django_redis.client.DefaultClient",
|
'CLIENT_CLASS': 'django_redis.client.DefaultClient',
|
||||||
"IGNORE_EXCEPTIONS": True, # mimics memcache behavior.
|
'IGNORE_EXCEPTIONS': True, # mimics memcache behavior.
|
||||||
# http://niwinz.github.io/django-redis/latest/#_memcached_exceptions_behavior
|
# http://niwinz.github.io/django-redis/latest/#_memcached_exceptions_behavior
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{% if cookiecutter.use_sentry == "y" %}
|
{% if cookiecutter.use_sentry == 'y' %}
|
||||||
# Sentry Configuration
|
# Sentry Configuration
|
||||||
SENTRY_DSN = env('DJANGO_SENTRY_DSN')
|
SENTRY_DSN = env('DJANGO_SENTRY_DSN')
|
||||||
SENTRY_CLIENT = env('DJANGO_SENTRY_CLIENT', default='raven.contrib.django.raven_compat.DjangoClient')
|
SENTRY_CLIENT = env('DJANGO_SENTRY_CLIENT', default='raven.contrib.django.raven_compat.DjangoClient')
|
||||||
|
@ -244,7 +244,7 @@ RAVEN_CONFIG = {
|
||||||
'CELERY_LOGLEVEL': env.int('DJANGO_SENTRY_LOG_LEVEL', logging.INFO),
|
'CELERY_LOGLEVEL': env.int('DJANGO_SENTRY_LOG_LEVEL', logging.INFO),
|
||||||
'DSN': SENTRY_DSN
|
'DSN': SENTRY_DSN
|
||||||
}
|
}
|
||||||
{% elif cookiecutter.use_sentry == "n" %}
|
{% elif cookiecutter.use_sentry == 'n' %}
|
||||||
# LOGGING CONFIGURATION
|
# LOGGING CONFIGURATION
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#logging
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#logging
|
||||||
|
|
|
@ -9,14 +9,14 @@ from django.views.generic import TemplateView
|
||||||
from django.views import defaults as default_views
|
from django.views import defaults as default_views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^$', TemplateView.as_view(template_name='pages/home.html'), name="home"),
|
url(r'^$', TemplateView.as_view(template_name='pages/home.html'), name='home'),
|
||||||
url(r'^about/$', TemplateView.as_view(template_name='pages/about.html'), name="about"),
|
url(r'^about/$', TemplateView.as_view(template_name='pages/about.html'), name='about'),
|
||||||
|
|
||||||
# Django Admin, use {% raw %}{% url 'admin:index' %}{% endraw %}
|
# Django Admin, use {% raw %}{% url 'admin:index' %}{% endraw %}
|
||||||
url(settings.ADMIN_URL, include(admin.site.urls)),
|
url(settings.ADMIN_URL, include(admin.site.urls)),
|
||||||
|
|
||||||
# User management
|
# User management
|
||||||
url(r'^users/', include("{{ cookiecutter.repo_name }}.users.urls", namespace="users")),
|
url(r'^users/', include('{{ cookiecutter.repo_name }}.users.urls', namespace='users')),
|
||||||
url(r'^accounts/', include('allauth.urls')),
|
url(r'^accounts/', include('allauth.urls')),
|
||||||
|
|
||||||
# Your stuff: custom urls includes go here
|
# Your stuff: custom urls includes go here
|
||||||
|
@ -28,8 +28,8 @@ if settings.DEBUG:
|
||||||
# This allows the error pages to be debugged during development, just visit
|
# This allows the error pages to be debugged during development, just visit
|
||||||
# these url in browser to see how these error pages look like.
|
# these url in browser to see how these error pages look like.
|
||||||
urlpatterns += [
|
urlpatterns += [
|
||||||
url(r'^400/$', default_views.bad_request, kwargs={'exception': Exception("Bad Request!")}),
|
url(r'^400/$', default_views.bad_request, kwargs={'exception': Exception('Bad Request!')}),
|
||||||
url(r'^403/$', default_views.permission_denied, kwargs={'exception': Exception("Permission Denied")}),
|
url(r'^403/$', default_views.permission_denied, kwargs={'exception': Exception('Permission Denied')}),
|
||||||
url(r'^404/$', default_views.page_not_found, kwargs={'exception': Exception("Page not Found")}),
|
url(r'^404/$', default_views.page_not_found, kwargs={'exception': Exception('Page not Found')}),
|
||||||
url(r'^500/$', default_views.server_error),
|
url(r'^500/$', default_views.server_error),
|
||||||
]
|
]
|
||||||
|
|
|
@ -15,8 +15,8 @@ framework.
|
||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
|
|
||||||
{% if cookiecutter.use_newrelic == "y" -%}
|
{% if cookiecutter.use_newrelic == 'y' -%}
|
||||||
if os.environ.get("DJANGO_SETTINGS_MODULE") == "config.settings.production":
|
if os.environ.get('DJANGO_SETTINGS_MODULE') == 'config.settings.production':
|
||||||
import newrelic.agent
|
import newrelic.agent
|
||||||
newrelic.agent.initialize()
|
newrelic.agent.initialize()
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
@ -24,8 +24,8 @@ from django.core.wsgi import get_wsgi_application
|
||||||
{% if cookiecutter.use_whitenoise == 'y' -%}
|
{% if cookiecutter.use_whitenoise == 'y' -%}
|
||||||
from whitenoise.django import DjangoWhiteNoise
|
from whitenoise.django import DjangoWhiteNoise
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{% if cookiecutter.use_sentry == "y" -%}
|
{% if cookiecutter.use_sentry == 'y' -%}
|
||||||
if os.environ.get("DJANGO_SETTINGS_MODULE") == "config.settings.production":
|
if os.environ.get('DJANGO_SETTINGS_MODULE') == 'config.settings.production':
|
||||||
from raven.contrib.django.raven_compat.middleware.wsgi import Sentry
|
from raven.contrib.django.raven_compat.middleware.wsgi import Sentry
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
|
@ -45,12 +45,12 @@ application = get_wsgi_application()
|
||||||
# See: https://whitenoise.readthedocs.org/
|
# See: https://whitenoise.readthedocs.org/
|
||||||
application = DjangoWhiteNoise(application)
|
application = DjangoWhiteNoise(application)
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{% if cookiecutter.use_sentry == "y" -%}
|
{% if cookiecutter.use_sentry == 'y' -%}
|
||||||
if os.environ.get("DJANGO_SETTINGS_MODULE") == "config.settings.production":
|
if os.environ.get('DJANGO_SETTINGS_MODULE') == 'config.settings.production':
|
||||||
application = Sentry(application)
|
application = Sentry(application)
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{% if cookiecutter.use_newrelic == "y" -%}
|
{% if cookiecutter.use_newrelic == 'y' -%}
|
||||||
if os.environ.get("DJANGO_SETTINGS_MODULE") == "config.settings.production":
|
if os.environ.get('DJANGO_SETTINGS_MODULE') == 'config.settings.production':
|
||||||
application = newrelic.agent.WSGIApplicationWrapper(application)
|
application = newrelic.agent.WSGIApplicationWrapper(application)
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
# Apply WSGI middleware here.
|
# Apply WSGI middleware here.
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
# All configuration values have a default; values that are commented out
|
# All configuration values have a default; values that are commented out
|
||||||
# serve to show the default.
|
# serve to show the default.
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -41,8 +43,8 @@ source_suffix = '.rst'
|
||||||
master_doc = 'index'
|
master_doc = 'index'
|
||||||
|
|
||||||
# General information about the project.
|
# General information about the project.
|
||||||
project = u'{{ cookiecutter.project_name }}'
|
project = '{{ cookiecutter.project_name }}'
|
||||||
copyright = u"{{ cookiecutter.year }}, {{ cookiecutter.author_name }}"
|
copyright = """{{ cookiecutter.year }}, {{ cookiecutter.author_name }}"""
|
||||||
|
|
||||||
# The version info for the project you're documenting, acts as replacement for
|
# The version info for the project you're documenting, acts as replacement for
|
||||||
# |version| and |release|, also used in various other places throughout the
|
# |version| and |release|, also used in various other places throughout the
|
||||||
|
@ -186,8 +188,8 @@ latex_elements = {
|
||||||
latex_documents = [
|
latex_documents = [
|
||||||
('index',
|
('index',
|
||||||
'{{ cookiecutter.repo_name }}.tex',
|
'{{ cookiecutter.repo_name }}.tex',
|
||||||
u'{{ cookiecutter.project_name }} Documentation',
|
'{{ cookiecutter.project_name }} Documentation',
|
||||||
u"{{ cookiecutter.author_name }}", 'manual'),
|
"""{{ cookiecutter.author_name }}""", 'manual'),
|
||||||
]
|
]
|
||||||
|
|
||||||
# The name of an image file (relative to this directory) to place at the top of
|
# The name of an image file (relative to this directory) to place at the top of
|
||||||
|
@ -216,8 +218,8 @@ latex_documents = [
|
||||||
# One entry per manual page. List of tuples
|
# One entry per manual page. List of tuples
|
||||||
# (source start file, name, description, authors, manual section).
|
# (source start file, name, description, authors, manual section).
|
||||||
man_pages = [
|
man_pages = [
|
||||||
('index', '{{ cookiecutter.repo_name }}', u'{{ cookiecutter.project_name }} Documentation',
|
('index', '{{ cookiecutter.repo_name }}', '{{ cookiecutter.project_name }} Documentation',
|
||||||
[u"{{ cookiecutter.author_name }}"], 1)
|
["""{{ cookiecutter.author_name }}"""], 1)
|
||||||
]
|
]
|
||||||
|
|
||||||
# If true, show URL addresses after external links.
|
# If true, show URL addresses after external links.
|
||||||
|
@ -230,9 +232,9 @@ man_pages = [
|
||||||
# (source start file, target name, title, author,
|
# (source start file, target name, title, author,
|
||||||
# dir menu entry, description, category)
|
# dir menu entry, description, category)
|
||||||
texinfo_documents = [
|
texinfo_documents = [
|
||||||
('index', '{{ cookiecutter.repo_name }}', u'{{ cookiecutter.project_name }} Documentation',
|
('index', '{{ cookiecutter.repo_name }}', '{{ cookiecutter.project_name }} Documentation',
|
||||||
u"{{ cookiecutter.author_name }}", '{{ cookiecutter.project_name }}',
|
"""{{ cookiecutter.author_name }}""", '{{ cookiecutter.project_name }}',
|
||||||
'{{ cookiecutter.description }}', 'Miscellaneous'),
|
"""{{ cookiecutter.description }}""", 'Miscellaneous'),
|
||||||
]
|
]
|
||||||
|
|
||||||
# Documents to append as an appendix to all manuals.
|
# Documents to append as an appendix to all manuals.
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == '__main__':
|
||||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.local")
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings.local')
|
||||||
|
|
||||||
from django.core.management import execute_from_command_line
|
from django.core.management import execute_from_command_line
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,8 @@ class ExecutionEngine(hitchtest.ExecutionEngine):
|
||||||
python_package.build()
|
python_package.build()
|
||||||
|
|
||||||
call([
|
call([
|
||||||
python_package.pip, "install", "-r",
|
python_package.pip, 'install', '-r',
|
||||||
path.join(PROJECT_DIRECTORY, "requirements/local.txt")
|
path.join(PROJECT_DIRECTORY, 'requirements/local.txt')
|
||||||
])
|
])
|
||||||
|
|
||||||
postgres_package = hitchpostgres.PostgresPackage()
|
postgres_package = hitchpostgres.PostgresPackage()
|
||||||
|
@ -36,16 +36,16 @@ class ExecutionEngine(hitchtest.ExecutionEngine):
|
||||||
|
|
||||||
self.services = hitchserve.ServiceBundle(
|
self.services = hitchserve.ServiceBundle(
|
||||||
project_directory=PROJECT_DIRECTORY,
|
project_directory=PROJECT_DIRECTORY,
|
||||||
startup_timeout=float(self.settings["startup_timeout"]),
|
startup_timeout=float(self.settings['startup_timeout']),
|
||||||
shutdown_timeout=float(self.settings["shutdown_timeout"]),
|
shutdown_timeout=float(self.settings['shutdown_timeout']),
|
||||||
)
|
)
|
||||||
|
|
||||||
postgres_user = hitchpostgres.PostgresUser("{{cookiecutter.repo_name}}", "password")
|
postgres_user = hitchpostgres.PostgresUser('{{cookiecutter.repo_name}}', 'password')
|
||||||
|
|
||||||
self.services['Postgres'] = hitchpostgres.PostgresService(
|
self.services['Postgres'] = hitchpostgres.PostgresService(
|
||||||
postgres_package=postgres_package,
|
postgres_package=postgres_package,
|
||||||
users=[postgres_user, ],
|
users=[postgres_user, ],
|
||||||
databases=[hitchpostgres.PostgresDatabase("{{cookiecutter.repo_name}}", postgres_user), ]
|
databases=[hitchpostgres.PostgresDatabase('{{cookiecutter.repo_name}}', postgres_user), ]
|
||||||
)
|
)
|
||||||
|
|
||||||
self.services['HitchSMTP'] = hitchsmtp.HitchSMTPService(port=1025)
|
self.services['HitchSMTP'] = hitchsmtp.HitchSMTPService(port=1025)
|
||||||
|
@ -53,7 +53,7 @@ class ExecutionEngine(hitchtest.ExecutionEngine):
|
||||||
self.services['Django'] = hitchpython.DjangoService(
|
self.services['Django'] = hitchpython.DjangoService(
|
||||||
python=python_package.python,
|
python=python_package.python,
|
||||||
port=8000,
|
port=8000,
|
||||||
settings="config.settings.local",
|
settings='config.settings.local',
|
||||||
needs=[self.services['Postgres'], ],
|
needs=[self.services['Postgres'], ],
|
||||||
env_vars=self.settings['environment_variables'],
|
env_vars=self.settings['environment_variables'],
|
||||||
)
|
)
|
||||||
|
@ -62,10 +62,10 @@ class ExecutionEngine(hitchtest.ExecutionEngine):
|
||||||
redis_package=redis_package,
|
redis_package=redis_package,
|
||||||
port=16379,
|
port=16379,
|
||||||
)
|
)
|
||||||
{% if cookiecutter.use_celery == "y" %}
|
{% if cookiecutter.use_celery == 'y' %}
|
||||||
self.services['Celery'] = hitchpython.CeleryService(
|
self.services['Celery'] = hitchpython.CeleryService(
|
||||||
python=python_package.python,
|
python=python_package.python,
|
||||||
app="{{cookiecutter.repo_name}}.taskapp", loglevel="INFO",
|
app='{{cookiecutter.repo_name}}.taskapp', loglevel='INFO',
|
||||||
needs=[
|
needs=[
|
||||||
self.services['Redis'], self.services['Django'],
|
self.services['Redis'], self.services['Django'],
|
||||||
],
|
],
|
||||||
|
@ -73,7 +73,7 @@ class ExecutionEngine(hitchtest.ExecutionEngine):
|
||||||
)
|
)
|
||||||
{% endif %}
|
{% endif %}
|
||||||
self.services['Firefox'] = hitchselenium.SeleniumService(
|
self.services['Firefox'] = hitchselenium.SeleniumService(
|
||||||
xvfb=self.settings.get("xvfb", False),
|
xvfb=self.settings.get('xvfb', False),
|
||||||
no_libfaketime=True,
|
no_libfaketime=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ class ExecutionEngine(hitchtest.ExecutionEngine):
|
||||||
def load_website(self):
|
def load_website(self):
|
||||||
"""Navigate to website in Firefox."""
|
"""Navigate to website in Firefox."""
|
||||||
self.driver.get(self.services['Django'].url())
|
self.driver.get(self.services['Django'].url())
|
||||||
self.click("djHideToolBarButton")
|
self.click('djHideToolBarButton')
|
||||||
|
|
||||||
def fill_form(self, **kwargs):
|
def fill_form(self, **kwargs):
|
||||||
"""Fill in a form with id=value."""
|
"""Fill in a form with id=value."""
|
||||||
|
@ -150,13 +150,13 @@ class ExecutionEngine(hitchtest.ExecutionEngine):
|
||||||
def on_failure(self):
|
def on_failure(self):
|
||||||
"""Stop and IPython."""
|
"""Stop and IPython."""
|
||||||
if not self.settings['quiet']:
|
if not self.settings['quiet']:
|
||||||
if self.settings.get("pause_on_failure", False):
|
if self.settings.get('pause_on_failure', False):
|
||||||
self.pause(message=self.stacktrace.to_template())
|
self.pause(message=self.stacktrace.to_template())
|
||||||
|
|
||||||
def on_success(self):
|
def on_success(self):
|
||||||
"""Pause on success if enabled."""
|
"""Pause on success if enabled."""
|
||||||
if self.settings.get("pause_on_success", False):
|
if self.settings.get('pause_on_success', False):
|
||||||
self.pause(message="SUCCESS")
|
self.pause(message='SUCCESS')
|
||||||
|
|
||||||
def tear_down(self):
|
def tear_down(self):
|
||||||
"""Shut down services required to run your test."""
|
"""Shut down services required to run your test."""
|
||||||
|
|
|
@ -13,24 +13,24 @@ from django.db import migrations
|
||||||
|
|
||||||
def update_site_forward(apps, schema_editor):
|
def update_site_forward(apps, schema_editor):
|
||||||
"""Set site domain and name."""
|
"""Set site domain and name."""
|
||||||
Site = apps.get_model("sites", "Site")
|
Site = apps.get_model('sites', 'Site')
|
||||||
Site.objects.update_or_create(
|
Site.objects.update_or_create(
|
||||||
id=settings.SITE_ID,
|
id=settings.SITE_ID,
|
||||||
defaults={
|
defaults={
|
||||||
"domain": "{{cookiecutter.domain_name}}",
|
'domain': '{{cookiecutter.domain_name}}',
|
||||||
"name": "{{cookiecutter.project_name}}"
|
'name': '{{cookiecutter.project_name}}'
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def update_site_backward(apps, schema_editor):
|
def update_site_backward(apps, schema_editor):
|
||||||
"""Revert site domain and name to default."""
|
"""Revert site domain and name to default."""
|
||||||
Site = apps.get_model("sites", "Site")
|
Site = apps.get_model('sites', 'Site')
|
||||||
Site.objects.update_or_create(
|
Site.objects.update_or_create(
|
||||||
id=settings.SITE_ID,
|
id=settings.SITE_ID,
|
||||||
defaults={
|
defaults={
|
||||||
"domain": "example.com",
|
'domain': 'example.com',
|
||||||
"name": "example.com"
|
'name': 'example.com'
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% if cookiecutter.use_celery == "y" %}
|
{% if cookiecutter.use_celery == 'y' %}
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
import os
|
import os
|
||||||
from celery import Celery
|
from celery import Celery
|
||||||
|
@ -8,7 +8,7 @@ from django.conf import settings
|
||||||
|
|
||||||
if not settings.configured:
|
if not settings.configured:
|
||||||
# set the default Django settings module for the 'celery' program.
|
# set the default Django settings module for the 'celery' program.
|
||||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.local") # pragma: no cover
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings.local') # pragma: no cover
|
||||||
|
|
||||||
|
|
||||||
app = Celery('{{cookiecutter.repo_name}}')
|
app = Celery('{{cookiecutter.repo_name}}')
|
||||||
|
@ -24,7 +24,7 @@ class CeleryConfig(AppConfig):
|
||||||
app.config_from_object('django.conf:settings')
|
app.config_from_object('django.conf:settings')
|
||||||
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS, force=True)
|
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS, force=True)
|
||||||
|
|
||||||
{% if cookiecutter.use_sentry == "y" -%}
|
{% if cookiecutter.use_sentry == 'y' -%}
|
||||||
if hasattr(settings, 'RAVEN_CONFIG'):
|
if hasattr(settings, 'RAVEN_CONFIG'):
|
||||||
# Celery signal registration
|
# Celery signal registration
|
||||||
from raven import Client as RavenClient
|
from raven import Client as RavenClient
|
||||||
|
@ -36,7 +36,7 @@ class CeleryConfig(AppConfig):
|
||||||
raven_register_signal(raven_client)
|
raven_register_signal(raven_client)
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
{% if cookiecutter.use_opbeat == "y" -%}
|
{% if cookiecutter.use_opbeat == 'y' -%}
|
||||||
if hasattr(settings, 'OPBEAT'):
|
if hasattr(settings, 'OPBEAT'):
|
||||||
from opbeat.contrib.django.models import client as opbeat_client
|
from opbeat.contrib.django.models import client as opbeat_client
|
||||||
from opbeat.contrib.django.models import logger as opbeat_logger
|
from opbeat.contrib.django.models import logger as opbeat_logger
|
||||||
|
|
|
@ -24,7 +24,7 @@ class MyUserCreationForm(UserCreationForm):
|
||||||
model = User
|
model = User
|
||||||
|
|
||||||
def clean_username(self):
|
def clean_username(self):
|
||||||
username = self.cleaned_data["username"]
|
username = self.cleaned_data['username']
|
||||||
try:
|
try:
|
||||||
User.objects.get(username=username)
|
User.objects.get(username=username)
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
|
|
|
@ -13,7 +13,7 @@ class User(AbstractUser):
|
||||||
|
|
||||||
# First Name and Last Name do not cover name patterns
|
# First Name and Last Name do not cover name patterns
|
||||||
# around the globe.
|
# around the globe.
|
||||||
name = models.CharField(_("Name of User"), blank=True, max_length=255)
|
name = models.CharField(_('Name of User'), blank=True, max_length=255)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.username
|
return self.username
|
||||||
|
|
|
@ -9,7 +9,7 @@ class TestUser(TestCase):
|
||||||
def test__str__(self):
|
def test__str__(self):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.user.__str__(),
|
self.user.__str__(),
|
||||||
"testuser" # This is the default username for self.make_user()
|
'testuser' # This is the default username for self.make_user()
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_get_absolute_url(self):
|
def test_get_absolute_url(self):
|
||||||
|
|
|
@ -12,16 +12,16 @@ from .models import User
|
||||||
class UserDetailView(LoginRequiredMixin, DetailView):
|
class UserDetailView(LoginRequiredMixin, DetailView):
|
||||||
model = User
|
model = User
|
||||||
# These next two lines tell the view to index lookups by username
|
# These next two lines tell the view to index lookups by username
|
||||||
slug_field = "username"
|
slug_field = 'username'
|
||||||
slug_url_kwarg = "username"
|
slug_url_kwarg = 'username'
|
||||||
|
|
||||||
|
|
||||||
class UserRedirectView(LoginRequiredMixin, RedirectView):
|
class UserRedirectView(LoginRequiredMixin, RedirectView):
|
||||||
permanent = False
|
permanent = False
|
||||||
|
|
||||||
def get_redirect_url(self):
|
def get_redirect_url(self):
|
||||||
return reverse("users:detail",
|
return reverse('users:detail',
|
||||||
kwargs={"username": self.request.user.username})
|
kwargs={'username': self.request.user.username})
|
||||||
|
|
||||||
|
|
||||||
class UserUpdateView(LoginRequiredMixin, UpdateView):
|
class UserUpdateView(LoginRequiredMixin, UpdateView):
|
||||||
|
@ -33,8 +33,8 @@ class UserUpdateView(LoginRequiredMixin, UpdateView):
|
||||||
|
|
||||||
# send the user back to their own page after a successful update
|
# send the user back to their own page after a successful update
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
return reverse("users:detail",
|
return reverse('users:detail',
|
||||||
kwargs={"username": self.request.user.username})
|
kwargs={'username': self.request.user.username})
|
||||||
|
|
||||||
def get_object(self):
|
def get_object(self):
|
||||||
# Only get the User record for the user making the request
|
# Only get the User record for the user making the request
|
||||||
|
@ -44,5 +44,5 @@ class UserUpdateView(LoginRequiredMixin, UpdateView):
|
||||||
class UserListView(LoginRequiredMixin, ListView):
|
class UserListView(LoginRequiredMixin, ListView):
|
||||||
model = User
|
model = User
|
||||||
# These next two lines tell the view to index lookups by username
|
# These next two lines tell the view to index lookups by username
|
||||||
slug_field = "username"
|
slug_field = 'username'
|
||||||
slug_url_kwarg = "username"
|
slug_url_kwarg = 'username'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user