Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint & Upgrade to Django 5 #56

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
402 changes: 211 additions & 191 deletions base/templates/base.html

Large diffs are not rendered by default.

171 changes: 84 additions & 87 deletions dart/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,145 +21,142 @@
# Do NOT expose this application to an untrusted network.

import os

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

DART_VERSION_NUMBER = '2.1.1'
DART_VERSION_NUMBER = "2.1.1"

# SECURITY WARNING
# We are not randomizing this key for you.
SECRET_KEY = '5s9G+t##Trga48t594g1g8sret*(#*/rg-dfgs43wt)((dh/*d'
SECRET_KEY = "5s9G+t##Trga48t594g1g8sret*(#*/rg-dfgs43wt)((dh/*d"

ALLOWED_HOSTS = ['*']
ALLOWED_HOSTS = ["*"]

# Application definition

INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admindocs',
'bootstrap3',
'base',
'missions.apps.MissionsConfig',
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"django.contrib.admindocs",
"bootstrap3",
"base",
"missions.apps.MissionsConfig",
)

MIDDLEWARE = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
)

DEBUG=True
DEBUG = True

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
#Hard coding path for now. Try without this path or use Base_dir as described here; #https://stackoverflow.com/questions/3038459/django-template-path
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.contrib.auth.context_processors.auth',
'django.template.context_processors.debug',
'django.template.context_processors.i18n',
'django.template.context_processors.media',
'django.template.context_processors.static',
'django.template.context_processors.tz',
'django.contrib.messages.context_processors.messages',
'missions.contextprocessors.context_processors.version_number',
'django.template.context_processors.request'
"BACKEND": "django.template.backends.django.DjangoTemplates",
# Hard coding path for now. Try without this path or use Base_dir as described here; #https://stackoverflow.com/questions/3038459/django-template-path
"DIRS": [],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.contrib.auth.context_processors.auth",
"django.template.context_processors.debug",
"django.template.context_processors.i18n",
"django.template.context_processors.media",
"django.template.context_processors.static",
"django.template.context_processors.tz",
"django.contrib.messages.context_processors.messages",
"missions.contextprocessors.context_processors.version_number",
"django.template.context_processors.request",
],
# SECURITY WARNING
# We run in debug mode so that static files are automatically served
# out by the built-in django webserver for ease of setup. Since you're already running
# this on a trusted network (remember the security warning at the top of this file) you
# are probably okay doing the same.
'debug': DEBUG,
'libraries' : {
'staticfiles': 'django.templatetags.static',
}
# SECURITY WARNING
# We run in debug mode so that static files are automatically served
# out by the built-in django webserver for ease of setup. Since you're already running
# this on a trusted network (remember the security warning at the top of this file) you
# are probably okay doing the same.
"debug": DEBUG,
"libraries": {
"staticfiles": "django.templatetags.static",
},
},
},
]

ROOT_URLCONF = 'dart.urls'
ROOT_URLCONF = "dart.urls"

# WSGI_APPLICATION = 'dart.wsgi.application'

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'data/db.sqlite3'),
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(BASE_DIR, "data/db.sqlite3"),
}
}

LANGUAGE_CODE = 'en-us'
LANGUAGE_CODE = "en-us"

TIME_ZONE = 'America/New_York'
TIME_ZONE = "America/New_York"

USE_I18N = True

USE_L10N = True

USE_TZ = True

STATIC_URL = '/static/'
STATIC_URL = "/static/"

MEDIA_URL = '/data/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'supporting_data')
MEDIA_URL = "/data/"
MEDIA_ROOT = os.path.join(BASE_DIR, "supporting_data")

# Bootstrap Settings
BOOTSTRAP3 = {
'css_url': STATIC_URL + 'vendor/css/bootstrap.min.css',
'javascript_url': STATIC_URL + 'vendor/js/bootstrap.min.js',
'jquery_url': STATIC_URL + 'vendor/js/jquery.min.js',
'required_css_class': 'required',
"css_url": STATIC_URL + "vendor/css/bootstrap.min.css",
"javascript_url": STATIC_URL + "vendor/js/bootstrap.min.js",
"jquery_url": STATIC_URL + "vendor/js/jquery.min.js",
"required_css_class": "required",
}

LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'debug_file': {
'level': 'DEBUG',
'class': 'logging.handlers.RotatingFileHandler',
'filename': os.path.join(BASE_DIR, 'logs/debug.log'),
'maxBytes': 20000000, # 20MB
'backupCount': 10,
'formatter': 'verbose',
"version": 1,
"disable_existing_loggers": False,
"handlers": {
"debug_file": {
"level": "DEBUG",
"class": "logging.handlers.RotatingFileHandler",
"filename": os.path.join(BASE_DIR, "logs/debug.log"),
"maxBytes": 20000000, # 20MB
"backupCount": 10,
"formatter": "verbose",
},
'info_file': {
'level': 'INFO',
'class': 'logging.FileHandler',
'filename': os.path.join(BASE_DIR, 'logs/info.log'),
'formatter': 'verbose',
"info_file": {
"level": "INFO",
"class": "logging.FileHandler",
"filename": os.path.join(BASE_DIR, "logs/info.log"),
"formatter": "verbose",
},
},
'loggers': {
'missions': {
'handlers': ['debug_file', 'info_file'],
'level': 'DEBUG',
'propagate': True,
"loggers": {
"missions": {
"handlers": ["debug_file", "info_file"],
"level": "DEBUG",
"propagate": True,
},
},
'formatters': {
'verbose': {
'format': '%(levelname)s [%(asctime)s] %(name)s: %(message)s'
},
'simple': {
'format': '%(levelname)s %(message)s'
},
"formatters": {
"verbose": {"format": "%(levelname)s [%(asctime)s] %(name)s: %(message)s"},
"simple": {"format": "%(levelname)s %(message)s"},
},
}

REPORT_TEMPLATE_PATH = os.path.join(BASE_DIR, '2016_Template.docx')
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
REPORT_TEMPLATE_PATH = os.path.join(BASE_DIR, "2016_Template.docx")
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"

# Require an interstitial message to be displayed
#
Expand All @@ -168,4 +165,4 @@
# in hours as a positive integer or 0 to indicate it should be displayed once per application logon.
# Omitting this setting will bypass the interstitial.
#
#REQUIRED_INTERSTITIAL_DISPLAY_INTERVAL = 0 # In hours, or 0 for once per login
# REQUIRED_INTERSTITIAL_DISPLAY_INTERVAL = 0 # In hours, or 0 for once per login
128 changes: 83 additions & 45 deletions dart/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,61 +13,99 @@
# limitations under the License.
#

from django.conf.urls import include, url
from django.urls import include, re_path
from django.contrib import admin
from django.views.generic import RedirectView
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
import missions.views
from django.contrib.auth.decorators import login_required
from django.contrib.auth import logout, login
from django.views.static import serve
from django.conf import settings
from django.contrib.auth.views import LoginView, LogoutView

urlpatterns = [
url(r'^missions/', include('missions.urls')),

url(r'^$', RedirectView.as_view(url='/missions/', permanent=False)),

url(r'^admin/', admin.site.urls),

url(r'^accounts/logout/$', LogoutView.as_view(template_name='login.html'), name='logout'),
#url(r'^accounts/logout/$', logout, name='logout'),
#url(r'^accounts/login/$', login, {'template_name': 'login.html'}, name='login'),
url(r'^accounts/login/$', LoginView.as_view(template_name='login.html'), name='login'),
url(r'^accounts/$', RedirectView.as_view(url='/', permanent=False)),
url(r'^accounts/profile/$', RedirectView.as_view(url='/', permanent=False)),

url(r'^settings/$',
login_required(missions.views.UpdateDynamicSettingsView.as_view()), name='update-settings'),
url(r'^settings/business-areas/$',
login_required(missions.views.BusinessAreaListView.as_view()), name='list-business-areas'),
url(r'^settings/update-business-area(?:/(?P<pk>\d+))?/$',
login_required(missions.views.business_area_handler), name='update-business-area'),
url(r'^settings/classifications/$',
login_required(missions.views.ClassificationListView.as_view()), name='list-classifications'),
url(r'^settings/update-classification(?:/(?P<pk>\d+))?/$',
login_required(missions.views.classification_handler), name='update-classification'),
url(r'^settings/colors/$',
login_required(missions.views.ColorListView.as_view()), name='list-colors'),
url(r'^settings/update-color(?:/(?P<pk>\d+))?/$',
login_required(missions.views.color_handler), name='update-color'),
url(r'^settings/create-account/$',
missions.views.CreateAccountView.as_view(), name='create-account'),

url(r'^login-interstitial/$',
login_required(missions.views.LoginInterstitialView.as_view()), name='login-interstitial'),

url(r'^about/$',
login_required(missions.views.AboutTemplateView.as_view()), name='about'),

url(r'^hosts/(?P<host_id>\d+)/$',
login_required(missions.views.mission_host_handler), name='host-detail'),

url(r'^data/(?P<supportingdata>\d+)/$',
login_required(missions.views.DownloadSupportingDataView.as_view()), name='data-view'),
url(r'^data/(?P<path>.*)$',
serve,{'document_root': settings.MEDIA_ROOT, 'show_indexes': False}),
re_path(r"^missions/", include("missions.urls")),
re_path(r"^$", RedirectView.as_view(url="/missions/", permanent=False)),
re_path(r"^admin/", admin.site.urls),
re_path(
r"^accounts/logout/$",
LogoutView.as_view(template_name="login.html"),
name="logout",
),
# url(r'^accounts/logout/$', logout, name='logout'),
# url(r'^accounts/login/$', login, {'template_name': 'login.html'}, name='login'),
re_path(
r"^accounts/login/$",
LoginView.as_view(template_name="login.html"),
name="login",
),
re_path(r"^accounts/$", RedirectView.as_view(url="/", permanent=False)),
re_path(r"^accounts/profile/$", RedirectView.as_view(url="/", permanent=False)),
re_path(
r"^settings/$",
login_required(missions.views.UpdateDynamicSettingsView.as_view()),
name="update-settings",
),
re_path(
r"^settings/business-areas/$",
login_required(missions.views.BusinessAreaListView.as_view()),
name="list-business-areas",
),
re_path(
r"^settings/update-business-area(?:/(?P<pk>\d+))?/$",
login_required(missions.views.business_area_handler),
name="update-business-area",
),
re_path(
r"^settings/classifications/$",
login_required(missions.views.ClassificationListView.as_view()),
name="list-classifications",
),
re_path(
r"^settings/update-classification(?:/(?P<pk>\d+))?/$",
login_required(missions.views.classification_handler),
name="update-classification",
),
re_path(
r"^settings/colors/$",
login_required(missions.views.ColorListView.as_view()),
name="list-colors",
),
re_path(
r"^settings/update-color(?:/(?P<pk>\d+))?/$",
login_required(missions.views.color_handler),
name="update-color",
),
re_path(
r"^settings/create-account/$",
missions.views.CreateAccountView.as_view(),
name="create-account",
),
re_path(
r"^login-interstitial/$",
login_required(missions.views.LoginInterstitialView.as_view()),
name="login-interstitial",
),
re_path(
r"^about/$",
login_required(missions.views.AboutTemplateView.as_view()),
name="about",
),
re_path(
r"^hosts/(?P<host_id>\d+)/$",
login_required(missions.views.mission_host_handler),
name="host-detail",
),
re_path(
r"^data/(?P<supportingdata>\d+)/$",
login_required(missions.views.DownloadSupportingDataView.as_view()),
name="data-view",
),
re_path(
r"^data/(?P<path>.*)$",
serve,
{"document_root": settings.MEDIA_ROOT, "show_indexes": False},
),
]

urlpatterns += staticfiles_urlpatterns()
2 changes: 2 additions & 0 deletions dart/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
"""

import os

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dart.settings")

from django.core.wsgi import get_wsgi_application

application = get_wsgi_application()
Loading