Unverified Commit 8d64c384 authored by David Haynes's avatar David Haynes 🙆
Browse files

refactor: Settings cleaned up a bit



- remove commented out items
Signed-off-by: David Haynes's avatarDavid Haynes <dhaynes3@gmu.edu>
parent b7dd94fa
...@@ -55,25 +55,8 @@ class OpenTimeViewSet(viewsets.ModelViewSet): ...@@ -55,25 +55,8 @@ class OpenTimeViewSet(viewsets.ModelViewSet):
queryset = OpenTime.objects.all() queryset = OpenTime.objects.all()
serializer_class = OpenTimeSerializer serializer_class = OpenTimeSerializer
#def facility_grid(request):
# """Display the facilities in a grid. Main page."""
# if 'sort' in request.GET:
# if request.GET['sort'] == 'location':
# # Display the grid by location (instead of listing alphabetically)
# pass # Not implemented yet
# return render_to_response('facility_grid.html',
# context_instance=RequestContext(request))
def gen_etag(request): def gen_etag(request):
return hashlib.sha1(str(OpenTime.objects.all())).hexdigest() return hashlib.sha1(str(OpenTime.objects.all())).hexdigest()
def gen_last_modified(request): def gen_last_modified(request):
return TimeStampedModel.objects.all().order_by('-last_modified')[0].last_modified return TimeStampedModel.objects.all().order_by('-last_modified')[0].last_modified
#@condition(etag_func=gen_etag, last_modified_func=gen_last_modified)
#def ajax_schedule_data(request):
# # Wrapping up in an object to avoid possible CSRF attack on top-level
# # arrays in JSON objects
# return HttpResponse(json.dumps({'data': export_data()}, indent=4),
# content_type="application/json")
""""Base Django settings for whats_open.""" """"Base Django settings for whats_open."""
import os import os
import sys
from os.path import abspath, basename, dirname, join, normpath from os.path import abspath, basename, dirname, join, normpath
from sys import path from sys import path
...@@ -19,16 +20,6 @@ SITE_NAME = basename(DJANGO_ROOT) ...@@ -19,16 +20,6 @@ SITE_NAME = basename(DJANGO_ROOT)
path.append(DJANGO_ROOT) path.append(DJANGO_ROOT)
########## END PATH CONFIGURATION ########## END PATH CONFIGURATION
########## DEBUG CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#debug
DEBUG = False
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-debug
TEMPLATE_DEBUG = DEBUG
########## END DEBUG CONFIGURATION
########## MANAGER CONFIGURATION ########## MANAGER CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#admins # See: https://docs.djangoproject.com/en/dev/ref/settings/#admins
# Insert a ('Name', 'Email') inside ADMINS tuple # Insert a ('Name', 'Email') inside ADMINS tuple
...@@ -124,7 +115,6 @@ ADMIN_MEDIA_PREFIX = '/static/admin/' ...@@ -124,7 +115,6 @@ ADMIN_MEDIA_PREFIX = '/static/admin/'
STATICFILES_FINDERS = ( STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
) )
########## END STATIC FILE CONFIGURATION ########## END STATIC FILE CONFIGURATION
...@@ -178,8 +168,6 @@ TEMPLATES = [ ...@@ -178,8 +168,6 @@ TEMPLATES = [
'django.template.loaders.filesystem.Loader', 'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader', 'django.template.loaders.app_directories.Loader',
], ],
# https://docs.djangoproject.com/en/dev/ref/settings/#template-debug
'debug': DEBUG
} }
} }
] ]
...@@ -227,7 +215,7 @@ CACHE_MIDDLEWARE_KEY_PREFIX = '' ...@@ -227,7 +215,7 @@ CACHE_MIDDLEWARE_KEY_PREFIX = ''
########## APP CONFIGURATION ########## APP CONFIGURATION
DJANGO_APPS = ( INSTALLED_APPS = (
# Default Django apps: # Default Django apps:
'django.contrib.auth', 'django.contrib.auth',
'django.contrib.contenttypes', 'django.contrib.contenttypes',
...@@ -236,24 +224,15 @@ DJANGO_APPS = ( ...@@ -236,24 +224,15 @@ DJANGO_APPS = (
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
# Useful template tags:
# 'django.contrib.humanize',
# Admin panel and documentation: # Admin panel and documentation:
'django.contrib.admin', 'django.contrib.admin',
'django.contrib.admindocs', 'django.contrib.admindocs',
)
# Apps specific for this project go here. # Apps specific for this project go here.
LOCAL_APPS = (
'website', 'website',
#'guardian',
'rest_framework', 'rest_framework',
) )
# See: https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
INSTALLED_APPS = DJANGO_APPS + LOCAL_APPS
########## END APP CONFIGURATION ########## END APP CONFIGURATION
...@@ -294,7 +273,12 @@ LOGGING = { ...@@ -294,7 +273,12 @@ LOGGING = {
'level': 'ERROR', 'level': 'ERROR',
'filters': ['require_debug_false'], 'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler' 'class': 'django.utils.log.AdminEmailHandler'
} },
'console': {
'level': 'INFO',
'class': 'logging.StreamHandler',
'stream': sys.stdout
},
}, },
'loggers': { 'loggers': {
'django.request': { 'django.request': {
...@@ -302,19 +286,12 @@ LOGGING = { ...@@ -302,19 +286,12 @@ LOGGING = {
'level': 'ERROR', 'level': 'ERROR',
'propagate': True, 'propagate': True,
}, },
'django': {
'handlers': ['console'],
'level': 'INFO',
'propogate': True
},
} }
} }
########## END LOGGING CONFIGURATION
########## MANAGEMENT CONFIGURATION ########## END LOGGING CONFIGURATION
#CAS_GATEWAY=True
#ANONYMOUS_USER_ID = -1
#AUTHENTICATION_BACKENDS = (
# 'django.contrib.auth.backends.ModelBackend', # this is default
# 'cas.middleware.CASMiddleware',
# #'guardian.backends.ObjectPermissionBackend',
#)
#
#LOGIN_URL='/management/login/'
#LOGIN_REDIRECT='/management/'
########## END MANAGEMENT CONFIGURATION
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
from __future__ import absolute_import from __future__ import absolute_import
from os.path import join, normpath
from .base import * from .base import *
...@@ -12,28 +10,6 @@ from .base import * ...@@ -12,28 +10,6 @@ from .base import *
DEBUG = True DEBUG = True
########## END DEBUG CONFIGURATION ########## END DEBUG CONFIGURATION
########## EMAIL CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
########## END EMAIL CONFIGURATION
########## DATABASE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': normpath(join(DJANGO_ROOT, 'database/database.db')),
'USER': '',
'PASSWORD': '',
'HOST': '',
'PORT': '',
}
}
########## END DATABASE CONFIGURATION
########## CACHE CONFIGURATION ########## CACHE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#caches # See: https://docs.djangoproject.com/en/dev/ref/settings/#caches
CACHES = { CACHES = {
......
"""Production settings and globals.""" """Production settings and globals."""
from __future__ import absolute_import # Future Imports
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from os import environ from os import environ
...@@ -24,45 +26,10 @@ def get_env_setting(setting): ...@@ -24,45 +26,10 @@ def get_env_setting(setting):
ALLOWED_HOSTS = ['*'] ALLOWED_HOSTS = ['*']
########## END HOST CONFIGURATION ########## END HOST CONFIGURATION
########## EMAIL CONFIGURATION ########## DEBUG CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#email-backend # See: https://docs.djangoproject.com/en/dev/ref/settings/#debug
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' DEBUG = False
########## END DEBUG CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host
EMAIL_HOST = environ.get('EMAIL_HOST', 'smtp.gmail.com')
# See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host-password
EMAIL_HOST_PASSWORD = environ.get('EMAIL_HOST_PASSWORD', '')
# See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host-user
EMAIL_HOST_USER = environ.get('EMAIL_HOST_USER', 'your_email@example.com')
# See: https://docs.djangoproject.com/en/dev/ref/settings/#email-port
EMAIL_PORT = environ.get('EMAIL_PORT', 587)
# See: https://docs.djangoproject.com/en/dev/ref/settings/#email-subject-prefix
EMAIL_SUBJECT_PREFIX = '[%s] ' % SITE_NAME
# See: https://docs.djangoproject.com/en/dev/ref/settings/#email-use-tls
EMAIL_USE_TLS = True
# See: https://docs.djangoproject.com/en/dev/ref/settings/#server-email
SERVER_EMAIL = EMAIL_HOST_USER
########## END EMAIL CONFIGURATION
########## DATABASE CONFIGURATION
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': normpath(join(DJANGO_ROOT, 'database.db')),
'USER': '',
'PASSWORD': '',
'HOST': '',
'PORT': '',
}
}
########## END DATABASE CONFIGURATION
########## CACHE CONFIGURATION ########## CACHE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#caches # See: https://docs.djangoproject.com/en/dev/ref/settings/#caches
...@@ -73,7 +40,6 @@ CACHES = { ...@@ -73,7 +40,6 @@ CACHES = {
} }
########## END CACHE CONFIGURATION ########## END CACHE CONFIGURATION
########## SECRET CONFIGURATION ########## SECRET CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key # See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
SECRET_KEY = get_env_setting('SECRET_KEY') SECRET_KEY = get_env_setting('SECRET_KEY')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment