diff --git a/HTTP_200/settings.py b/HTTP_200/settings.py index 4b365c1..eaef48b 100644 --- a/HTTP_200/settings.py +++ b/HTTP_200/settings.py @@ -12,7 +12,7 @@ import sys import HTTP_200.config_keys as config_keys import config as config -from django.core.urlresolvers import reverse_lazy +from django.urls import reverse_lazy BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) APPS_DIR = os.path.join(BASE_DIR, 'apps') @@ -26,11 +26,9 @@ # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True -TEMPLATE_DEBUG = DEBUG - ALLOWED_HOSTS = ["*"] -INTERNAL_IPS = '127.0.0.1' +INTERNAL_IPS = ['127.0.0.1', ] APPEND_SLASH = True # Application definition @@ -51,30 +49,26 @@ 'allauth.account', 'profiles', 'notices', - 'autofixture', 'ckeditor', 'django_spaghetti', 'debug_toolbar', 'import_export', 'wifi', - 'rest_framework_docs', 'rest_framework.authtoken', 'notifications', ) -MIDDLEWARE_CLASSES = ( +MIDDLEWARE = ( 'corsheaders.middleware.CorsMiddleware', - 'django.middleware.common.CommonMiddleware', + 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'debug_toolbar.middleware.DebugToolbarMiddleware', # 'HTTP_200.middlewares.SetLastVisitMiddleware', - # 'django.middleware.security.SecurityMiddleware', ) ROOT_URLCONF = 'HTTP_200.urls' @@ -96,13 +90,12 @@ 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', - 'django.core.context_processors.static', - 'django.core.context_processors.request', ], 'loaders': [ 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader' - ] + ], + 'debug': DEBUG }, }, ] @@ -113,11 +106,11 @@ # Database # https://docs.djangoproject.com/en/1.8/ref/settings/#databases # DATABASES = { -# 'default': { -# 'ENGINE': 'django.db.backends.sqlite3', -# 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), -# } -# } +# 'default': { +# 'ENGINE': 'django.db.backends.sqlite3', +# 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), +# } +# } DATABASES = { 'default': { @@ -262,6 +255,7 @@ } ] +MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(TEMPLATE_DIR, 'media') SPAGHETTI_SAUCE = { diff --git a/HTTP_200/urls.py b/HTTP_200/urls.py index 9c46d45..9fce037 100644 --- a/HTTP_200/urls.py +++ b/HTTP_200/urls.py @@ -1,20 +1,22 @@ # django imports from django.contrib import admin -from django.conf.urls import url, include, patterns - +from django.conf.urls import url, include +from django.conf import settings +from django.conf.urls.static import static # allauth imports from allauth.account.views import login, logout +import debug_toolbar + # local file imports from profiles.views import (Home, FaqDisplayView, about, Contact, BulkUser, - SingleUser) - + SingleUser, + password_change) -import settings admin.site.site_header = "JSS InfoConnect Admin Interface" @@ -22,11 +24,11 @@ # Web urls url(r'^$', Home.as_view(), name="home"), url(r'^notices/', include('notices.urls')), - url(r'^accounts/password/change/$', 'profiles.views.password_change', name='password_change'), + url(r'^accounts/password/change/$', password_change, name='password_change'), url(r'^login/$', login, name="account_login"), url(r'^logout/$', logout, name="account_logout"), url(r'^accounts/', include('allauth.urls')), - url(r'^admin/', include(admin.site.urls)), + url(r'^admin/', admin.site.urls), url(r'^user/', include('profiles.urls')), url(r'^faq/$', FaqDisplayView.as_view(), name="faq"), url(r'^about/$', about, name='about'), @@ -38,19 +40,17 @@ url(r'wifi/', include('wifi.urls')), # api urls - url(r'^api/profiles/', include("profiles.api.urls", namespace='profiles_api')), - url(r'^api/notices/', include("notices.api.urls", namespace='notices_api')), - url(r'^api/notifications/', include("notifications.api.urls", namespace='notifications_api')), - + url(r'^api/profiles/', include("profiles.api.urls")), + url(r'^api/notices/', include("notices.api.urls")), + url(r'^api/notifications/', include("notifications.api.urls")), ] # For development environment +debug_urlpatterns = [ + *static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT), + url(r'^dbschema/', include('django_spaghetti.urls')), + url(r'^__debug__/', include(debug_toolbar.urls)), +] + if settings.DEBUG: - import debug_toolbar - urlpatterns += patterns('', - (r'^media/(?P.*)$', 'django.views.static.serve', { - 'document_root': settings.MEDIA_ROOT}), - url(r'^dbschema/', include('django_spaghetti.urls')), - url(r'^__debug__/', include(debug_toolbar.urls)), - url(r'^api/docs/', include('rest_framework_docs.urls')), - ) + urlpatterns += debug_urlpatterns diff --git a/requirements/common.txt b/requirements/common.txt index 3ee081f..10a8dea 100644 --- a/requirements/common.txt +++ b/requirements/common.txt @@ -9,7 +9,7 @@ django-allauth==0.42.0 django-filter==2.3.0 PyJWT==1.7.1 django-braces==1.14.0 -django-ckeditor==5.9.2 +django-ckeditor==5.9.0 django-spaghetti-and-meatballs==0.2.2 django-debug-toolbar==2.2 coverage==5.2.1