Skip to content
Draft
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
3 changes: 1 addition & 2 deletions .github/workflows/ci-django-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,5 @@ jobs:
- name: Run Tests
run: |
cd agate
mv core/local_settings.test.py core/local_settings.py
coverage run manage.py test
coverage run manage.py test --settings="core.local_settings_test"
coverage report
36 changes: 11 additions & 25 deletions agate/core/settings.py → agate/core/base_settings.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import os
import sys

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
TEMPLATE_DIR = os.path.join(BASE_DIR, 'core/templates')


# Application definition

INSTALLED_APPS = [
# Django default apps
'django.contrib.admin',
Expand Down Expand Up @@ -110,18 +107,6 @@
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'


# Import local_settings.py
SECRET_KEY = None
try:
from .local_settings import * # NOQA
except ImportError:
sys.exit('Unable to import local_settings.py (refer to local_settings.example.py for help)')

# Ensure the SECRET_KEY is supplied in local_settings.py - and trust that the other settings are there too.
if not SECRET_KEY: # NOQA
sys.exit('Missing SECRET_KEY in local_settings.py')


# Storages

# Default STORAGES from Django documentation
Expand All @@ -131,13 +116,7 @@
"staticfiles": {"BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage"},
}

# Use ManifestStaticFilesStorage when not in debug mode
if not DEBUG: # NOQA
STORAGES['staticfiles'] = {"BACKEND": "django.contrib.staticfiles.storage.ManifestStaticFilesStorage"}


# Logging

LOGGING = {
'version': 1,
'disable_existing_loggers': False,
Expand All @@ -160,9 +139,16 @@
},
},
'handlers': {
'stream': {
'stream_debug': {
'class': 'logging.StreamHandler',
'filters': ['require_debug_true'],
'level': 'DEBUG', # NOQA
'formatter': 'verbose',
},
'stream_prod': {
'class': 'logging.StreamHandler',
'level': 'DEBUG' if DEBUG else 'INFO', # NOQA
'filters': ['require_debug_false'],
'level': os.getenv("DJANGO_LOG_LEVEL", "INFO"), # NOQA
'formatter': 'verbose',
},
'file': {
Expand All @@ -181,8 +167,8 @@
},
'loggers': {
'django': {
'handlers': ['stream', 'file', 'mail_admins'],
'level': 'DEBUG' if DEBUG else 'INFO', # NOQA
'handlers': ['stream_debug', 'stream_prod', 'file', 'mail_admins'],
'level': 'DEBUG', # NOQA
'propagate': 'True',
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@
import os
from empty_message_retrieval import EmptyMessageRetrieval

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
from .base_settings import * # noqa: F403
from .base_settings import BASE_DIR, STORAGES

SECRET_KEY = 'u6n(9&8g-3=6d1#jyp^#))you-h&y^-5y7*&hu)cpxzeu_7#j+'

DEBUG = True

ALLOWED_HOSTS = ['*']

ADMIN_EMAIL = 'bear-rsg@contacts.bham.ac.uk'
# ADMIN_EMAIL = 'bear-rsg@contacts.bham.ac.uk'

DATABASES = {
'default': {
Expand All @@ -33,3 +34,7 @@
MESSAGE_RETRIEVAL = EmptyMessageRetrieval()

LIMITED_PROJECT_LIST = ["synthscape"]

# Use ManifestStaticFilesStorage when not in debug mode
if not DEBUG: # NOQA
STORAGES['staticfiles'] = {"BACKEND": "django.contrib.staticfiles.storage.ManifestStaticFilesStorage"}
2 changes: 1 addition & 1 deletion agate/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys

if __name__ == '__main__':
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.local_settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
Expand Down
Loading