Merge pull request #424 from SchrodingersGat/dev

Working towards deployment
This commit is contained in:
Oliver 2019-07-12 00:20:11 +10:00 committed by GitHub
commit 20037a6edb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
134 changed files with 219 additions and 59 deletions

4
.gitignore vendored
View File

@ -31,8 +31,9 @@ local_settings.py
# Sphinx files
docs/_build
# Local media storage (only when running in development mode)
# Local static and media file storage (only when running in development mode)
InvenTree/media
InvenTree/static
# Key file
secret_key.txt
@ -40,6 +41,7 @@ secret_key.txt
# IDE / development files
.idea/
*.code-workspace
.vscode/
# Coverage reports
.coverage

View File

@ -1,42 +1,60 @@
"""
Django settings for InvenTree project.
Generated by 'django-admin startproject' using Django 1.10.6.
In practice the settings in this file should not be adjusted,
instead settings can be configured in the config.yaml file
located in the top level project directory.
For more information on this file, see
https://docs.djangoproject.com/en/1.10/topics/settings/
This allows implementation configuration to be hidden from source control,
as well as separate configuration parameters from the more complex
database setup in this file.
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.10/ref/settings/
"""
import os
import logging
import tempfile
import yaml
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
cfg_filename = os.path.join(BASE_DIR, 'config.yaml')
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/
if not os.path.exists(cfg_filename):
CONFIG = {}
print("Warning: config.yaml not found - using default settings")
else:
with open(cfg_filename, 'r') as cfg:
CONFIG = yaml.safe_load(cfg)
# SECURITY WARNING: keep the secret key used in production secret!
# Read the autogenerated key-file
key_file = open(os.path.join(BASE_DIR, 'secret_key.txt'), 'r')
SECRET_KEY = key_file.read().strip()
# Default action is to run the system in Debug mode
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
DEBUG = CONFIG.get('debug', True)
ALLOWED_HOSTS = ['*']
# List of allowed hosts (default = allow all)
ALLOWED_HOSTS = CONFIG.get('allowed_hosts', ['*'])
CORS_ORIGIN_WHITELIST = [
]
# Cross Origin Resource Sharing (CORS) options
if DEBUG:
print("Warning: DEBUG mode is enabled, CORS requests are allowed for any domain")
CORS_ORIGIN_ALLOW_ALL = True
# Only allow CORS access to API
CORS_URLS_REGEX = r'^/api/.*$'
# Extract CORS options from configuration file
cors_opt = CONFIG.get('cors', None)
if cors_opt:
CORS_ORIGIN_ALLOW_ALL = cors_opt.get('allow_all', False)
if CORS_ORIGIN_ALLOW_ALL:
print("Warning: CORS requests are allowed for any domain!")
else:
CORS_ORIGIN_WHITELIST = cors_opt.get('whitelist', [])
if DEBUG:
# will output to your console
@ -85,17 +103,8 @@ LOGGING = {
'class': 'logging.StreamHandler',
},
},
# 'loggers': {
# 'ddjango.db.backends': {
# 'level': 'DEBUG',
# 'handlers': ['console',],
# 'propagate': True
# },
# },
}
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
@ -108,7 +117,7 @@ MIDDLEWARE = [
'InvenTree.middleware.AuthRequiredMiddleware',
]
if DEBUG:
if CONFIG.get('log_queries', False):
MIDDLEWARE.append('InvenTree.middleware.QueryCountMiddleware')
ROOT_URLCONF = 'InvenTree.urls'
@ -137,32 +146,21 @@ REST_FRAMEWORK = {
'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.TokenAuthentication',
)
# 'EXCEPTION_HANDLER': 'InvenTree.utils.api_exception_handler',
# 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
# 'PAGE_SIZE': 50,
}
WSGI_APPLICATION = 'InvenTree.wsgi.application'
DATABASES = {}
# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
DATABASES = {
'default': {
# Database backend selection
if 'database' in CONFIG:
DATABASES['default'] = CONFIG['database']
else:
print("Warning: Database backend not specified - using default (sqlite)")
DATABASES['default'] = {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'inventree_db.sqlite3'),
},
# TODO - Uncomment this when postgresql support is re-integrated
# 'postgresql': {
# 'ENGINE': 'django.db.backends.postgresql',
# 'NAME': 'inventree',
# 'USER': 'inventreeuser',
# 'PASSWORD': 'inventree',
# 'HOST': 'localhost',
# 'PORT': '',
# }
}
}
CACHES = {
'default': {
@ -177,7 +175,6 @@ CACHES = {
QR_CODE_CACHE_ALIAS = 'qr-code'
# Password validation
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
@ -216,13 +213,15 @@ USE_TZ = True
STATIC_URL = '/static/'
STATIC_ROOT = CONFIG.get('static_root', os.path.join(BASE_DIR, 'static'))
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static'),
os.path.join(BASE_DIR, 'InvenTree', 'static'),
]
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_ROOT = CONFIG.get('media_root', os.path.join(BASE_DIR, 'media'))
# crispy forms use the bootstrap templates
CRISPY_TEMPLATE_PACK = 'bootstrap'

View File

Before

Width:  |  Height:  |  Size: 106 KiB

After

Width:  |  Height:  |  Size: 106 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

View File

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

View File

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

Before

Width:  |  Height:  |  Size: 98 KiB

After

Width:  |  Height:  |  Size: 98 KiB

Some files were not shown because too many files have changed in this diff Show More