From 0745af67a6535bbfae3bde49c69a5e9a042e75e2 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Sun, 14 Aug 2016 20:12:12 -0700 Subject: [PATCH] ENH: Upgrade versions (django 1.10) (#8) --- ccdb/utils/middleware.py | 10 ++++++++++ config/settings/base.py | 25 ++++++++----------------- config/settings/local.py | 4 ++-- config/settings/production.py | 14 ++++++++++---- config/urls.py | 6 ++++-- requirements/base.txt | 19 ++++++++----------- requirements/local.txt | 8 ++++---- 7 files changed, 46 insertions(+), 40 deletions(-) create mode 100644 ccdb/utils/middleware.py diff --git a/ccdb/utils/middleware.py b/ccdb/utils/middleware.py new file mode 100644 index 0000000..b197965 --- /dev/null +++ b/ccdb/utils/middleware.py @@ -0,0 +1,10 @@ +from django.utils.deprecation import MiddlewareMixin +from django.conf import settings + + +if settings.DEBUG: + from debug_toolbar.middleware import DebugToolbarMiddleware + + class PatchedDebugToolbarMiddleware(MiddlewareMixin, + DebugToolbarMiddleware): + pass diff --git a/config/settings/base.py b/config/settings/base.py index ccfa8e0..f8bcaff 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -1,7 +1,6 @@ """ Django settings for CCDB """ -from django.utils.translation import ugettext_lazy as _ import environ @@ -46,7 +45,7 @@ INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS # MIDDLEWARE CONFIGURATION # ------------------------------------------------------------------------------ -MIDDLEWARE_CLASSES = ( +MIDDLEWARE = ( # Make sure djangosecure.middleware.SecurityMiddleware is listed first 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', @@ -64,14 +63,15 @@ DEBUG = env.bool("DJANGO_DEBUG", False) # FIXTURE CONFIGURATION # ------------------------------------------------------------------------------ -# See: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-FIXTURE_DIRS +# https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-FIXTURE_DIRS FIXTURE_DIRS = ( str(APPS_DIR.path('fixtures')), ) # EMAIL CONFIGURATION # ------------------------------------------------------------------------------ -EMAIL_BACKEND = env('DJANGO_EMAIL_BACKEND', default='django.core.mail.backends.smtp.EmailBackend') +EMAIL_BACKEND = env('DJANGO_EMAIL_BACKEND', + default='django.core.mail.backends.smtp.EmailBackend') # MANAGER CONFIGURATION # ------------------------------------------------------------------------------ @@ -109,22 +109,16 @@ USE_TZ = True # See: https://docs.djangoproject.com/en/dev/ref/settings/#templates TEMPLATES = [ { - # See: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-TEMPLATES-BACKEND 'BACKEND': 'django.template.backends.django.DjangoTemplates', - # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs 'DIRS': [ str(APPS_DIR.path('templates')), ], 'OPTIONS': { - # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-debug 'debug': DEBUG, - # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-loaders - # https://docs.djangoproject.com/en/dev/ref/templates/api/#loader-types 'loaders': [ 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', ], - # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-context-processors 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', @@ -141,9 +135,6 @@ TEMPLATES = [ }, ] -# See: http://django-crispy-forms.readthedocs.org/en/latest/install.html#template-packs -CRISPY_TEMPLATE_PACK = 'bootstrap3' - # STATIC FILE CONFIGURATION # ------------------------------------------------------------------------------ # See: https://docs.djangoproject.com/en/dev/ref/settings/#static-root @@ -152,12 +143,10 @@ STATIC_ROOT = str(ROOT_DIR('staticfiles')) # See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url STATIC_URL = '/static/' -# See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:setting-STATICFILES_DIRS STATICFILES_DIRS = ( str(APPS_DIR.path('static')), ) -# See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#staticfiles-finders STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', @@ -207,8 +196,10 @@ REST_FRAMEWORK = { 'rest_framework.authentication.TokenAuthentication', 'rest_framework.authentication.SessionAuthentication', ], - 'DEFAULT_VERSIONING_CLASS': 'rest_framework.versioning.NamespaceVersioning', - 'DEFAULT_PAGINATION_CLASS': 'drf_ember_pagination.EmberPageNumberPagination', + 'DEFAULT_VERSIONING_CLASS': + 'rest_framework.versioning.NamespaceVersioning', + 'DEFAULT_PAGINATION_CLASS': + 'drf_ember_pagination.EmberPageNumberPagination', 'PAGE_SIZE': 100, } diff --git a/config/settings/local.py b/config/settings/local.py index ec6dbe5..9959ff5 100644 --- a/config/settings/local.py +++ b/config/settings/local.py @@ -41,12 +41,12 @@ EMAIL_BACKEND = env('DJANGO_EMAIL_BACKEND', # django-debug-toolbar # ------------------------------------------------------------------------------ -MIDDLEWARE_CLASSES += ('debug_toolbar.middleware.DebugToolbarMiddleware',) +MIDDLEWARE += ('ccdb.utils.middleware.PatchedDebugToolbarMiddleware',) INSTALLED_APPS += ('debug_toolbar', ) # Testing # ------------------------------------------------------------------------------ -INSTALLED_APPS += ('django_extensions', 'test_without_migrations') +INSTALLED_APPS += ('django_extensions',) INTERNAL_IPS = ('127.0.0.1', ) diff --git a/config/settings/production.py b/config/settings/production.py index dc791ee..ed0b8ed 100644 --- a/config/settings/production.py +++ b/config/settings/production.py @@ -31,7 +31,7 @@ SECURITY_MIDDLEWARE = ( ) # Make sure djangosecure.middleware.SecurityMiddleware is listed first -MIDDLEWARE_CLASSES = SECURITY_MIDDLEWARE + MIDDLEWARE_CLASSES +MIDDLEWARE = SECURITY_MIDDLEWARE + MIDDLEWARE # set this to 60 seconds and then to 518400 when you can prove it works SECURE_HSTS_SECONDS = 60 @@ -107,8 +107,13 @@ SERVER_EMAIL = env('DJANGO_SERVER_EMAIL', default=DEFAULT_FROM_EMAIL) # See: # https://docs.djangoproject.com/en/dev/ref/templates/api/#django.template.loaders.cached.Loader TEMPLATES[0]['OPTIONS']['loaders'] = [ - ('django.template.loaders.cached.Loader', [ - 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', ]), + ( + 'django.template.loaders.cached.Loader', + [ + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader' + ] + ), ] # DATABASE CONFIGURATION @@ -174,5 +179,6 @@ CORS_ORIGIN_WHITELIST = env.tuple('CORS_ORIGIN_WHITELIST', None) DJOSER = { 'SITE_NAME': 'CCDB', 'DOMAIN': 'https://ccdb.info', - 'PASSWORD_RESET_CONFIRM_URL': 'https://ccdb.info/password-reset?uid={uid}&token={token}', + 'PASSWORD_RESET_CONFIRM_URL': 'https://ccdb.info/password-reset?' + 'uid={uid}&token={token}', } diff --git a/config/urls.py b/config/urls.py index 6ddbdfd..caebbaa 100644 --- a/config/urls.py +++ b/config/urls.py @@ -8,9 +8,11 @@ from django.core.urlresolvers import reverse_lazy urlpatterns = [ url(settings.ADMIN_URL, include(admin.site.urls)), - url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')), + url(r'^api-auth/', include('rest_framework.urls', + namespace='rest_framework')), url(r'^api/', include('ccdb.api.urls', namespace='api')), - url(r'^$', RedirectView.as_view(url=reverse_lazy('admin:index'), permanent=True)), + url(r'^$', RedirectView.as_view(url=reverse_lazy('admin:index'), + permanent=True)), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) if settings.DEBUG: diff --git a/requirements/base.txt b/requirements/base.txt index 944824f..6619ebc 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -1,28 +1,25 @@ -django==1.8.13 +django==1.10 # Configuration django-environ==0.4.0 django-secure==1.0.1 -whitenoise==3.2 - -# Views -django-extra-views==0.7.1 +whitenoise==3.2.1 # DB -psycopg2==2.6.1 +psycopg2==2.6.2 # Time zones support -pytz==2016.4 +pytz==2016.6.1 # Date/time strings python-dateutil==2.5.3 # HTTP -requests==2.10.0 +requests==2.11.0 # REST -djangorestframework==3.3.3 +djangorestframework==3.4.4 django-cors-headers==1.1.0 -django-filter==0.13.0 -djoser==0.4.3 +django-filter==0.14.0 +djoser==0.5.0 git+git://github.com/thermokarst/drf_ember_pagination.git diff --git a/requirements/local.txt b/requirements/local.txt index 130c874..cfc0f6e 100644 --- a/requirements/local.txt +++ b/requirements/local.txt @@ -1,9 +1,9 @@ -r base.txt Werkzeug==0.11.10 -django-debug-toolbar==1.4 -django-extensions==1.6.7 -flake8==2.5.4 +django-debug-toolbar==1.5 +django-extensions==1.7.1 +flake8==3.0.4 pygraphviz==1.3.1 -ipython==4.2.0 +ipython==5.1.0 factory-boy==2.7.0