forked from rc/aircox
		
	- !88 pytest on existing tests - !89 reorganise settings (! see notes for deployment) Co-authored-by: bkfox <thomas bkfox net> Reviewed-on: rc/aircox#92
This commit is contained in:
		
							
								
								
									
										0
									
								
								instance/settings/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								instance/settings/__init__.py
									
									
									
									
									
										Normal file
									
								
							@ -1,15 +1,3 @@
 | 
			
		||||
"""Django and Aircox instance settings. This file should be saved as
 | 
			
		||||
`settings.py` in the same directory as this one.
 | 
			
		||||
 | 
			
		||||
User MUST define the following values: `SECRET_KEY`, `ALLOWED_HOSTS`, `DATABASES`
 | 
			
		||||
 | 
			
		||||
The following environment variables are used in settings:
 | 
			
		||||
    * `AIRCOX_DEBUG` (`DEBUG`): enable/disable debugging
 | 
			
		||||
 | 
			
		||||
For Django settings see:
 | 
			
		||||
    https://docs.djangoproject.com/en/3.1/topics/settings/
 | 
			
		||||
    https://docs.djangoproject.com/en/3.1/ref/settings/
 | 
			
		||||
"""
 | 
			
		||||
import os
 | 
			
		||||
import sys
 | 
			
		||||
 | 
			
		||||
@ -19,7 +7,8 @@ from django.utils import timezone
 | 
			
		||||
sys.path.insert(1, os.path.dirname(os.path.realpath(__file__)))
 | 
			
		||||
 | 
			
		||||
# Project root directory
 | 
			
		||||
PROJECT_ROOT = os.path.dirname(os.path.dirname(__file__))
 | 
			
		||||
PROJECT_ROOT = os.path.abspath(__file__ + "/../../../")
 | 
			
		||||
 | 
			
		||||
# DEBUG mode
 | 
			
		||||
DEBUG = (
 | 
			
		||||
    (os.environ["AIRCOX_DEBUG"].lower() in ("true", 1))
 | 
			
		||||
@ -38,12 +27,6 @@ LC_LOCALE = "en_US.UTF-8"
 | 
			
		||||
TIME_ZONE = os.environ.get("TZ") or "UTC"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
########################################################################
 | 
			
		||||
#
 | 
			
		||||
# You MUST configure those values
 | 
			
		||||
#
 | 
			
		||||
########################################################################
 | 
			
		||||
 | 
			
		||||
# Secret key: you MUST put a consistent secret key. You can generate one
 | 
			
		||||
# at https://djecrety.ir/
 | 
			
		||||
SECRET_KEY = ""
 | 
			
		||||
@ -56,15 +39,11 @@ DATABASES = {
 | 
			
		||||
        "TIMEZONE": TIME_ZONE,
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
 | 
			
		||||
 | 
			
		||||
# Allowed host for HTTP requests
 | 
			
		||||
ALLOWED_HOSTS = ("127.0.0.1",)
 | 
			
		||||
 | 
			
		||||
########################################################################
 | 
			
		||||
#
 | 
			
		||||
# You CAN configure starting from here
 | 
			
		||||
#
 | 
			
		||||
########################################################################
 | 
			
		||||
 | 
			
		||||
# Assets and medias:
 | 
			
		||||
# In production, user MUST configure webserver in order to serve static
 | 
			
		||||
@ -81,26 +60,6 @@ STATIC_ROOT = os.path.join(PROJECT_ROOT, "static")
 | 
			
		||||
# Path to media directory (by default in static's directory)
 | 
			
		||||
MEDIA_ROOT = os.path.join(STATIC_ROOT, "media")
 | 
			
		||||
 | 
			
		||||
# Include specific configuration depending of DEBUG
 | 
			
		||||
if DEBUG:
 | 
			
		||||
    from .dev import *
 | 
			
		||||
else:
 | 
			
		||||
    from .prod import *
 | 
			
		||||
 | 
			
		||||
    # Enable caching using memcache
 | 
			
		||||
    CACHES = {
 | 
			
		||||
        "default": {
 | 
			
		||||
            "BACKEND": "django.core.cache.backends.memcached.MemcachedCache",
 | 
			
		||||
            "LOCATION": "127.0.0.1:11211",
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
########################################################################
 | 
			
		||||
#
 | 
			
		||||
# You don't really need to configure what is happening below
 | 
			
		||||
#
 | 
			
		||||
########################################################################
 | 
			
		||||
# Enables internationalization and timezone
 | 
			
		||||
USE_I18N = True
 | 
			
		||||
USE_L10N = True
 | 
			
		||||
@ -112,7 +71,7 @@ try:
 | 
			
		||||
    import locale
 | 
			
		||||
 | 
			
		||||
    locale.setlocale(locale.LC_ALL, LC_LOCALE)
 | 
			
		||||
except:
 | 
			
		||||
except Exception:
 | 
			
		||||
    print(
 | 
			
		||||
        "Can not set locale {LC}. Is it available on you system? Hint: "
 | 
			
		||||
        "Check /etc/locale.gen and rerun locale-gen as sudo if needed.".format(
 | 
			
		||||
@ -1,5 +1,13 @@
 | 
			
		||||
import os
 | 
			
		||||
 | 
			
		||||
from .base import *
 | 
			
		||||
 | 
			
		||||
try:
 | 
			
		||||
    from .settings import *
 | 
			
		||||
except ImportError:
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
LOCALE_PATHS = ["aircox/locale", "aircox_streamer/locale"]
 | 
			
		||||
 | 
			
		||||
LOGGING = {
 | 
			
		||||
@ -1,5 +1,10 @@
 | 
			
		||||
import os
 | 
			
		||||
 | 
			
		||||
try:
 | 
			
		||||
    from .settings import *
 | 
			
		||||
except ImportError:
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
LOGGING = {
 | 
			
		||||
    "version": 1,
 | 
			
		||||
    "disable_existing_loggers": False,
 | 
			
		||||
@ -30,3 +35,12 @@ LOGGING = {
 | 
			
		||||
        },
 | 
			
		||||
    },
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# Enable caching using memcache
 | 
			
		||||
CACHES = {
 | 
			
		||||
    "default": {
 | 
			
		||||
        "BACKEND": "django.core.cache.backends.memcached.MemcachedCache",
 | 
			
		||||
        "LOCATION": "127.0.0.1:11211",
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										43
									
								
								instance/settings/sample.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								instance/settings/sample.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,43 @@
 | 
			
		||||
"""Django and Aircox instance settings. This file should be saved as
 | 
			
		||||
`settings.py` in the same directory as this one.
 | 
			
		||||
 | 
			
		||||
User MUST define the following values: `SECRET_KEY`, `ALLOWED_HOSTS`, `DATABASES`
 | 
			
		||||
 | 
			
		||||
The following environment variables are used in settings:
 | 
			
		||||
    * `AIRCOX_DEBUG` (`DEBUG`): enable/disable debugging
 | 
			
		||||
 | 
			
		||||
For Django settings see:
 | 
			
		||||
    https://docs.djangoproject.com/en/3.1/topics/settings/
 | 
			
		||||
    https://docs.djangoproject.com/en/3.1/ref/settings/
 | 
			
		||||
"""
 | 
			
		||||
 | 
			
		||||
# Debug mode: set to True for dev
 | 
			
		||||
# DEBUG = False
 | 
			
		||||
LANGUAGE_CODE = "fr-BE"
 | 
			
		||||
LC_LOCALE = "fr_BE.UTF-8"
 | 
			
		||||
 | 
			
		||||
# Secret key: you MUST put a consistent secret key. You can generate one
 | 
			
		||||
# at https://djecrety.ir/
 | 
			
		||||
SECRET_KEY = ""
 | 
			
		||||
 | 
			
		||||
# Database configuration: defaults to db.sqlite3
 | 
			
		||||
# DATABASES
 | 
			
		||||
 | 
			
		||||
# Allowed host for HTTP requests
 | 
			
		||||
# ALLOWED_HOSTS = ('127.0.0.1',)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# When LC_LOCALE is set here, this code activates it.
 | 
			
		||||
# Otherwise it can be removed
 | 
			
		||||
try:
 | 
			
		||||
    import locale
 | 
			
		||||
 | 
			
		||||
    locale.setlocale(locale.LC_ALL, LC_LOCALE)
 | 
			
		||||
except Exception:
 | 
			
		||||
    print(
 | 
			
		||||
        "Can not set locale {LC}. Is it available on you system? Hint: "
 | 
			
		||||
        "Check /etc/locale.gen and rerun locale-gen as sudo if needed.".format(
 | 
			
		||||
            LC=LANGUAGE_CODE
 | 
			
		||||
        )
 | 
			
		||||
    )
 | 
			
		||||
    pass
 | 
			
		||||
		Reference in New Issue
	
	Block a user