-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
224 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
ASGI config for eligibility project. | ||
It exposes the ASGI callable as a module-level variable named ``application``. | ||
For more information on this file, see | ||
https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/ | ||
""" | ||
|
||
import os | ||
|
||
from django.core.asgi import get_asgi_application | ||
|
||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'base_app.settings') | ||
|
||
application = get_asgi_application() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,15 @@ | ||
from __future__ import absolute_import | ||
|
||
import os | ||
|
||
from celery import Celery | ||
|
||
from celery import Celery, signals | ||
from django.conf import settings | ||
|
||
# set the default Django settings module for the 'celery' program. | ||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'base_app.settings') | ||
|
||
app = Celery('base_app') | ||
app.config_from_object(settings, namespace='CELERY') | ||
app.autodiscover_tasks() | ||
|
||
|
||
# Using a string here means the worker will not have to | ||
# pickle the object when using Windows. | ||
app.config_from_object(settings) | ||
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS) | ||
@signals.setup_logging.connect | ||
def disable_celery_logging_override(**kwargs): # pragma: no cover | ||
# let Celery use logging configured by Django rather then set up it's own | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,196 @@ | ||
import logging | ||
import os | ||
BASE_DIR = os.path.dirname(os.path.dirname(__file__)) | ||
|
||
SECRET_KEY = '' | ||
import environ | ||
|
||
DEBUG = False | ||
TEMPLATE_DEBUG = False | ||
BASE_DIR = (environ.Path(__file__) - 2)() | ||
env = environ.Env() | ||
env.read_env(os.path.join(BASE_DIR, '.env')) | ||
|
||
ALLOWED_HOSTS = [] | ||
BASE_URL = env.str('BASE_URL', default='localhost') | ||
TESTING = env.bool('TESTING', default=False) | ||
|
||
INSTALLED_APPS = ( | ||
######### | ||
# DJANGO SETTINGS | ||
######### | ||
DEBUG = env.bool('DEBUG', default=False) | ||
|
||
# SITE | ||
WSGI_APPLICATION = 'base_app.wsgi.application' | ||
ROOT_URLCONF = 'base_app.urls' | ||
SECRET_KEY = env.str('SECRET_KEY', default='keepitsecret') | ||
ALLOWED_HOSTS = env.list('ALLOWED_HOSTS', default=[BASE_URL]) | ||
|
||
# Databases | ||
DATABASES = { | ||
'default': env.db('DATABASE_URL', default="sqlite://:memory:"), | ||
} | ||
|
||
CACHES = { | ||
'default': env.cache('CACHE_URL', default='dummycache://'), | ||
} | ||
|
||
# LOCALE | ||
LANGUAGE_CODE = 'en-us' | ||
TIME_ZONE = 'UTC' | ||
USE_I18N = True | ||
USE_L10N = True | ||
USE_TZ = True | ||
|
||
# APPS | ||
INSTALLED_APPS = [ | ||
# Django | ||
'django.contrib.admin', | ||
'django.contrib.auth', | ||
'django.contrib.contenttypes', | ||
'django.contrib.sessions', | ||
'django.contrib.messages', | ||
'django.contrib.staticfiles', | ||
) | ||
|
||
MIDDLEWARE_CLASSES = ( | ||
# Third-party | ||
'django_celery_beat', | ||
'django_extensions', | ||
'django_filters', | ||
'health_check', | ||
'health_check.db', | ||
'health_check.cache', | ||
'health_check.storage', | ||
'health_check.contrib.celery', | ||
'rest_framework', | ||
'rest_framework.authtoken', | ||
|
||
# Local | ||
] | ||
|
||
MIDDLEWARE = [ | ||
'django.middleware.security.SecurityMiddleware', | ||
'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', | ||
) | ||
] | ||
|
||
ROOT_URLCONF = 'base_app.urls' | ||
TEMPLATES = [ | ||
{ | ||
'BACKEND': 'django.template.backends.django.DjangoTemplates', | ||
'DIRS': ['templates'], | ||
'APP_DIRS': True, | ||
'OPTIONS': { | ||
'context_processors': [ | ||
'django.template.context_processors.debug', | ||
'django.template.context_processors.request', | ||
'django.contrib.auth.context_processors.auth', | ||
'django.contrib.messages.context_processors.messages', | ||
], | ||
}, | ||
}, | ||
] | ||
|
||
WSGI_APPLICATION = 'base_app.wsgi.application' | ||
# AUTH | ||
AUTH_PASSWORD_VALIDATORS = [ | ||
{ | ||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', | ||
}, | ||
{ | ||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', | ||
}, | ||
{ | ||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', | ||
}, | ||
{ | ||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', | ||
}, | ||
] | ||
|
||
DATABASES = { | ||
'default': { | ||
'ENGINE': 'django.db.backends.sqlite3', | ||
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), | ||
} | ||
# LOGGING | ||
log_level = env.str('LOG_LEVEL', default='INFO') | ||
log_formatter = env.str('LOG_FORMATTER', default='plain') | ||
log_format = env.str('LOG_FORMAT', default=( | ||
'%(asctime)s %(levelname)s %(process)s %(thread)s [%(name)s] ' | ||
'[%(pathname)s:%(lineno)d:%(funcName)s] - %(message)s' | ||
)) | ||
LOGGING = { | ||
'version': 1, | ||
'disable_existing_loggers': False, | ||
'formatters': { | ||
'plain': { | ||
'format': log_format, | ||
}, | ||
}, | ||
'handlers': { | ||
'console': { | ||
'class': 'logging.StreamHandler', | ||
'formatter': log_formatter, | ||
'level': log_level, | ||
}, | ||
}, | ||
'root': { | ||
'handlers': ['console'], | ||
'level': log_level, | ||
}, | ||
'loggers': { | ||
'celery': { | ||
'level': 'INFO', | ||
'handlers': ['console'], | ||
'propagate': False, | ||
}, | ||
'django': { | ||
'level': 'INFO', | ||
'handlers': ['console'], | ||
'propagate': False, | ||
}, | ||
'django.request': { | ||
'level': 'INFO', | ||
'handlers': ['console'], | ||
'propagate': False, | ||
}, | ||
'gunicorn': { | ||
'level': 'INFO', | ||
'handlers': ['console'], | ||
'propagate': False, | ||
}, | ||
'uvicorn': { | ||
'level': 'INFO', | ||
'handlers': ['console'], | ||
'propagate': False, | ||
}, | ||
}, | ||
} | ||
|
||
STATICFILES_FINDERS = ( | ||
"django.contrib.staticfiles.finders.FileSystemFinder", | ||
"django.contrib.staticfiles.finders.AppDirectoriesFinder", | ||
'django.contrib.staticfiles.finders.DefaultStorageFinder', | ||
) | ||
######### | ||
# REST FRAMEWORK | ||
######### | ||
|
||
LANGUAGE_CODE = 'en-us' | ||
TIME_ZONE = 'UTC' | ||
USE_I18N = True | ||
USE_L10N = True | ||
USE_TZ = True | ||
REST_FRAMEWORK = { | ||
'DEFAULT_AUTHENTICATION_CLASSES': [ | ||
'rest_framework.authentication.SessionAuthentication', | ||
'rest_framework.authentication.TokenAuthentication', | ||
], | ||
} | ||
|
||
STATIC_URL = '/static/' | ||
|
||
try: | ||
from settings_override import * | ||
except ImportError: | ||
pass | ||
######### | ||
# CELERY | ||
######### | ||
|
||
CELERY_BEAT_SCHEDULER = 'django_celery_beat.schedulers:DatabaseScheduler' | ||
CELERY_BROKER_TRANSPORT_OPTIONS = { | ||
'fanout_prefix': True, | ||
'fanout_patterns': True, | ||
} | ||
CELERY_BROKER_URL = env.str('CELERY_BROKER_URL', default='dummycache://') | ||
CELERY_RESULT_BACKEND = env.str('CELERY_RESULT_BACKEND', default='dummycache://') | ||
CELERY_TASK_TRACK_STARTED = True | ||
CELERY_TASK_ACKS_LATE = True | ||
CELERY_TIMEZONE = TIME_ZONE | ||
CELERY_WORKER_PREFETCH_MULTIPLIER = 1 | ||
|
||
|
||
try: | ||
INSTALLED_APPS += LOCAL_INSTALLED_APPS | ||
except NameError: | ||
pass | ||
######### | ||
# TESTS | ||
######### | ||
if TESTING: | ||
CELERY_TASK_ALWAYS_EAGER = True | ||
CELERY_TASK_EAGER_PROPAGATES = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,11 @@ | ||
from django.conf import settings | ||
from django.conf.urls import patterns, include, url | ||
|
||
from django.contrib import admin | ||
admin.autodiscover() | ||
|
||
urlpatterns = patterns('', | ||
url(r'^admin/', include(admin.site.urls)), | ||
) | ||
from django.urls import include, path | ||
|
||
try: | ||
from local_urls import urlpatterns as local_urls | ||
except ImportError: | ||
pass | ||
else: | ||
urlpatterns += local_urls | ||
urlpatterns = [ | ||
path('admin/', admin.site.urls), | ||
] | ||
|
||
if settings.DEBUG: | ||
from django.contrib.staticfiles.urls import staticfiles_urlpatterns | ||
if settings.DEBUG: # pragma: no cover | ||
from django.contrib.staticfiles.urls import staticfiles_urlpatterns # pylint: disable=ungrouped-imports | ||
urlpatterns += staticfiles_urlpatterns() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,21 @@ | ||
#!/usr/bin/env python | ||
"""Django's command-line utility for administrative tasks.""" | ||
import os | ||
import sys | ||
|
||
if __name__ == "__main__": | ||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "base_app.settings") | ||
|
||
from django.core.management import execute_from_command_line | ||
|
||
def main(): | ||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'base_app.settings') | ||
try: | ||
from django.core.management import execute_from_command_line # pylint: disable=import-outside-toplevel | ||
except ImportError as exc: | ||
raise ImportError( | ||
"Couldn't import Django. Are you sure it's installed and " | ||
"available on your PYTHONPATH environment variable? Did you " | ||
"forget to activate a virtual environment?" # noqa: C812 | ||
) from exc | ||
execute_from_command_line(sys.argv) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,10 @@ | ||
Django | ||
Django>=3.1 | ||
celery>=4.4 | ||
django-celery-beat | ||
django-environ | ||
django-extensionsdjango-filter | ||
django-health-check | ||
django-redis | ||
django-storages | ||
djangorestframework>=3.11 | ||
python-json-logger |