Merge remote-tracking branch 'inventree/master'

This commit is contained in:
Oliver Walters 2019-07-12 00:20:54 +10:00
commit 7d2d6a79e4
134 changed files with 219 additions and 59 deletions

4
.gitignore vendored
View File

@ -31,8 +31,9 @@ local_settings.py
# Sphinx files # Sphinx files
docs/_build 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/media
InvenTree/static
# Key file # Key file
secret_key.txt secret_key.txt
@ -40,6 +41,7 @@ secret_key.txt
# IDE / development files # IDE / development files
.idea/ .idea/
*.code-workspace *.code-workspace
.vscode/
# Coverage reports # Coverage reports
.coverage .coverage

View File

@ -1,42 +1,60 @@
""" """
Django settings for InvenTree project. 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 This allows implementation configuration to be hidden from source control,
https://docs.djangoproject.com/en/1.10/topics/settings/ 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 os
import logging import logging
import tempfile import tempfile
import yaml
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 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 if not os.path.exists(cfg_filename):
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/ 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') key_file = open(os.path.join(BASE_DIR, 'secret_key.txt'), 'r')
SECRET_KEY = key_file.read().strip() 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! # 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: # Only allow CORS access to API
print("Warning: DEBUG mode is enabled, CORS requests are allowed for any domain") CORS_URLS_REGEX = r'^/api/.*$'
CORS_ORIGIN_ALLOW_ALL = True
# 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: if DEBUG:
# will output to your console # will output to your console
@ -85,17 +103,8 @@ LOGGING = {
'class': 'logging.StreamHandler', 'class': 'logging.StreamHandler',
}, },
}, },
# 'loggers': {
# 'ddjango.db.backends': {
# 'level': 'DEBUG',
# 'handlers': ['console',],
# 'propagate': True
# },
# },
} }
MIDDLEWARE = [ MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware', 'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware',
@ -108,7 +117,7 @@ MIDDLEWARE = [
'InvenTree.middleware.AuthRequiredMiddleware', 'InvenTree.middleware.AuthRequiredMiddleware',
] ]
if DEBUG: if CONFIG.get('log_queries', False):
MIDDLEWARE.append('InvenTree.middleware.QueryCountMiddleware') MIDDLEWARE.append('InvenTree.middleware.QueryCountMiddleware')
ROOT_URLCONF = 'InvenTree.urls' ROOT_URLCONF = 'InvenTree.urls'
@ -137,31 +146,20 @@ REST_FRAMEWORK = {
'rest_framework.authentication.SessionAuthentication', 'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.TokenAuthentication', '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' WSGI_APPLICATION = 'InvenTree.wsgi.application'
DATABASES = {}
# Database # Database backend selection
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases if 'database' in CONFIG:
DATABASES['default'] = CONFIG['database']
DATABASES = { else:
'default': { print("Warning: Database backend not specified - using default (sqlite)")
DATABASES['default'] = {
'ENGINE': 'django.db.backends.sqlite3', 'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'inventree_db.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 = { CACHES = {
@ -177,7 +175,6 @@ CACHES = {
QR_CODE_CACHE_ALIAS = 'qr-code' QR_CODE_CACHE_ALIAS = 'qr-code'
# Password validation # Password validation
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators # https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
@ -216,13 +213,15 @@ USE_TZ = True
STATIC_URL = '/static/' STATIC_URL = '/static/'
STATIC_ROOT = CONFIG.get('static_root', os.path.join(BASE_DIR, 'static'))
STATICFILES_DIRS = [ STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static'), os.path.join(BASE_DIR, 'InvenTree', 'static'),
] ]
MEDIA_URL = '/media/' 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 forms use the bootstrap templates
CRISPY_TEMPLATE_PACK = 'bootstrap' 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