bifurqué depuis cliss21/betg
feat: mets à jour l'environnement avec le cookicutter
Parent
84d1082c33
révision
8a0f96463e
|
@ -0,0 +1,26 @@
|
|||
# http://editorconfig.org
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.{py,rst,ini}]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
[*.py]
|
||||
line_length = 80
|
||||
|
||||
[*.{html,css,scss,js,json,yml}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[Makefile]
|
||||
indent_style = tab
|
125
Makefile
125
Makefile
|
@ -2,49 +2,61 @@
|
|||
## Définition des variables
|
||||
# Le nom de l'exécutable Python à utiliser ou son chemin absolu
|
||||
# (ex. : python ou python3).
|
||||
PYTHON_EXE := "python3"
|
||||
# S'il faut utiliser un environnement virtuel (yes ou no).
|
||||
USE_VENV := "yes"
|
||||
PYTHON_EXE := python3
|
||||
# S'il faut utiliser un environnement virtuel (y ou n).
|
||||
USE_VENV := y
|
||||
# Configuration de l'environnement virtuel.
|
||||
VENV_DIR := venv
|
||||
VENV_OPT := "--system-site-packages"
|
||||
VENV_OPT := --system-site-packages
|
||||
|
||||
# Définis les chemins et options des exécutables.
|
||||
PYTHON_EXE_BASENAME := $(shell basename $(PYTHON_EXE))
|
||||
VENV_PYTHON := "--python=$(PYTHON_EXE_BASENAME)"
|
||||
ifeq ($(USE_VENV), "yes")
|
||||
VENV_PYTHON := --python=$(PYTHON_EXE_BASENAME)
|
||||
ifeq ($(USE_VENV), y)
|
||||
PYTHON := $(VENV_DIR)/bin/$(PYTHON_EXE_BASENAME)
|
||||
PIP := $(VENV_DIR)/bin/pip
|
||||
PIP := $(VENV_DIR)/bin/pip
|
||||
else
|
||||
PYTHON := $(shell which $(PYTHON_EXE))
|
||||
PIP := $(shell which pip)
|
||||
endif
|
||||
|
||||
# Charge la configuration du 'config.env' s'il existe
|
||||
ifneq ("$(wildcard config.env)", "")
|
||||
include config.env
|
||||
# Détermine l'environnement à utiliser.
|
||||
ifndef ENV
|
||||
ifdef DJANGO_SETTINGS_MODULE
|
||||
ENV = $(shell echo $(DJANGO_SETTINGS_MODULE) | cut -d. -f3)
|
||||
else
|
||||
DEFAULT_ENV := production
|
||||
ENV = $(shell \
|
||||
sed -n '/^ENV/s/[^=]*=\(.*\)/\1/p' config.env 2> /dev/null \
|
||||
| tail -n 1 | grep -Ee '^..*' || echo "$(DEFAULT_ENV)")
|
||||
endif
|
||||
endif
|
||||
# ... et définis l'environnement à utiliser.
|
||||
ifdef DJANGO_SETTINGS_MODULE
|
||||
ENV = "$(shell echo $(DJANGO_SETTINGS_MODULE) | cut -d. -f3)"
|
||||
else
|
||||
ENV = "production"
|
||||
|
||||
# Définis EDITOR pour l'édition interactive.
|
||||
ifndef EDITOR
|
||||
ifdef VISUAL
|
||||
EDITOR := $(VISUAL)
|
||||
else
|
||||
EDITOR := vi
|
||||
endif
|
||||
endif
|
||||
|
||||
# Définition des cibles -------------------------------------------------------
|
||||
|
||||
.PHONY: clean-pyc clean-build clear-venv help
|
||||
.PHONY: clean-pyc clean-build clean-static clear-venv help check check-config
|
||||
.DEFAULT_GOAL := help
|
||||
|
||||
# commentaire d'une cible : #-> interne ##-> aide production+dev ###-> aide dev
|
||||
# Commentaire d'une cible : #-> interne ##-> aide production+dev ###-> aide dev
|
||||
help: ## affiche cette aide
|
||||
ifeq ($(ENV), "production")
|
||||
@perl -nle'print $& if m{^[a-zA-Z_-]+:[^#]*?## .*$$}' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
|
||||
ifeq ($(ENV), production)
|
||||
@perl -nle'print $& if m{^[a-zA-Z_-]+:[^#]*?## .*$$}' $(MAKEFILE_LIST) \
|
||||
| sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
|
||||
else
|
||||
@perl -nle'print $& if m{^[a-zA-Z_-]+:[^#]*?###? .*$$}' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?###? "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
|
||||
@perl -nle'print $& if m{^[a-zA-Z_-]+:[^#]*?###? .*$$}' $(MAKEFILE_LIST) \
|
||||
| sort | awk 'BEGIN {FS = ":.*?###? "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
|
||||
endif
|
||||
|
||||
clean: clean-build clean-pyc clean-cron ## nettoie tous les fichiers temporaires
|
||||
clean: clean-build clean-pyc clean-cron clean-static ## nettoie tous les fichiers temporaires
|
||||
|
||||
clean-build: ### nettoie les fichiers de construction du paquet
|
||||
rm -rf build/
|
||||
|
@ -52,47 +64,57 @@ clean-build: ### nettoie les fichiers de construction du paquet
|
|||
rm -rf *.egg-info
|
||||
|
||||
clean-pyc: ### nettoie les fichiers temporaires python
|
||||
find . -name '*.pyc' -exec rm -f {} +
|
||||
find . -name '*.pyo' -exec rm -f {} +
|
||||
find . -name '*~' -exec rm -f {} +
|
||||
find betg/ \
|
||||
\( -name '*.pyc' -o -name '*.pyo' -o -name '*~' \) -exec rm -f {} +
|
||||
|
||||
clean-cron: ## supprime la crontab de l'application
|
||||
$(PYTHON) manage.py crontab remove > /dev/null 2>&1
|
||||
|
||||
init: create-venv config.env update ## initialise l'environnement et l'application
|
||||
clean-static: ### nettoie les fichiers "static" collectés
|
||||
rm -rf var/static
|
||||
|
||||
config.env: # TODO: lancer une commande interactive
|
||||
init: create-venv config.env ## initialise l'environnement et l'application
|
||||
@$(MAKE) --no-print-directory update
|
||||
|
||||
config.env:
|
||||
cp config.env.example config.env
|
||||
chmod go-rwx config.env
|
||||
$(EDITOR) config.env
|
||||
|
||||
update: install-deps migrate static ## mets à jour l'application et ses dépendances
|
||||
update: check-config install-deps migrate static ## mets à jour l'application et ses dépendances
|
||||
touch betg/wsgi.py
|
||||
|
||||
check: check-config ## vérifie la configuration de l'instance
|
||||
$(PYTHON) manage.py check
|
||||
|
||||
check-config:
|
||||
@find . -maxdepth 1 -name config.env -perm /o+rwx -exec false {} + || \
|
||||
{ echo "\033[31mErreur :\033[0m les permissions de config.env ne sont pas bonnes, \
|
||||
vous devriez au moins faire : chmod o-rwx config.env"; false; }
|
||||
|
||||
install-deps: ## installe les dépendances de l'application
|
||||
$(PIP) install -r requirements/$(ENV).txt
|
||||
$(PIP) install --upgrade --requirement requirements/$(ENV).txt
|
||||
|
||||
migrate: ## mets à jour le schéma de la base de données
|
||||
$(PYTHON) manage.py migrate
|
||||
|
||||
update-cron: ## met a jour la crontab de l'application
|
||||
update-cron: ## mets a jour la crontab de l'application
|
||||
-@$(PYTHON) manage.py crontab remove > /dev/null 2>&1
|
||||
@$(PYTHON) manage.py crontab add > /dev/null 2>&1
|
||||
@$(PYTHON) manage.py crontab show
|
||||
|
||||
static: ## collecte les fichiers statiques
|
||||
ifeq ($(ENV), "production") # on evite de faire du bruit en dev
|
||||
ifeq ($(ENV), production)
|
||||
@echo "Collecte des fichiers statiques..."
|
||||
$(PYTHON) manage.py collectstatic --no-input --verbosity 0
|
||||
endif
|
||||
|
||||
static-local: ## supprime puis collecte les fichiers statiques (permet de rafraichir 'local')
|
||||
$(PYTHON) manage.py collectstatic --clear --no-input --verbosity 0
|
||||
|
||||
## Cibles liées à l'environnement virtuel
|
||||
|
||||
create-venv: $(PYTHON)
|
||||
|
||||
$(PYTHON):
|
||||
ifeq ($(USE_VENV), "yes")
|
||||
ifeq ($(USE_VENV), y)
|
||||
virtualenv $(VENV_OPT) $(VENV_PYTHON) $(VENV_DIR)
|
||||
else
|
||||
@echo "\033[31mErreur !\033[0m Impossible de trouver l'exécutable Python $(PYTHON)"
|
||||
|
@ -107,23 +129,26 @@ clear-venv: ## supprime l'environnement virtuel
|
|||
serve: ### démarre un serveur local pour l'application
|
||||
$(PYTHON) manage.py runserver
|
||||
|
||||
test: ### lance la suite de tests
|
||||
$(PYTHON) manage.py test --parallel=4 betg.apps.organisation betg.apps.evenements
|
||||
test: ### lance les tests de l'application
|
||||
$(PYTHON) manage.py test betg
|
||||
|
||||
testcov: ### lance la suite de tests avec rapport de couverture
|
||||
$(PYTHON) venv/bin/coverage run --source='betg' manage.py test betg.apps.organisation betg.apps.evenements
|
||||
$(PYTHON) venv/bin/coverage report --show-missing --omit='*/migrations/*','*/tests/*'
|
||||
coverage: ### vérifie la couverture de code
|
||||
$(PYTHON) -m coverage run manage.py test betg
|
||||
$(PYTHON) -m coverage report -m
|
||||
$(PYTHON) -m coverage html
|
||||
@echo open htmlcov/index.html
|
||||
|
||||
lint: ### vérifie la syntaxe et le code python
|
||||
flake8 betg
|
||||
lint: ### vérifie la syntaxe du code Python
|
||||
@$(PYTHON) -m flake8 betg || \
|
||||
{ echo "\033[31mErreur !\033[0m Veuillez corriger la syntaxe avec : make format"; false; }
|
||||
|
||||
sql-reset: ### réinitialise la base de données (reset_db de django_extensions)
|
||||
@test "x$(FORCE)" = "xYES" || { \
|
||||
echo "Cela va effacer toutes les données de la base. Si vous êtes sûr, spécifiez FORCE=YES à la commande." ; exit 1 ; }
|
||||
$(PYTHON) manage.py reset_db --noinput
|
||||
format: ### formate le code Python
|
||||
$(PYTHON) -m isort betg
|
||||
$(PYTHON) -m black betg
|
||||
|
||||
psql-reset: ### réinitialise la base de données postgresql
|
||||
# TODO: utiliser la commande reset_db de django_extensions
|
||||
@test "x$(FORCE)" = "xYES" || { \
|
||||
echo "Cela va effacer toutes les données de la base. Si vous êtes sûr, spécifiez FORCE=YES à la commande." ; exit 1 ; }
|
||||
@cat scripts/psql_reset.sql | $(PYTHON) manage.py dbshell
|
||||
shell: ### lance un shell Python dans l'environnement
|
||||
ifeq ($(ENV), production)
|
||||
$(PYTHON) manage.py shell
|
||||
else
|
||||
$(PYTHON) manage.py shell_plus
|
||||
endif
|
||||
|
|
|
@ -1 +1,24 @@
|
|||
from .base import * # noqa
|
||||
import environ
|
||||
|
||||
"""The default environment to use."""
|
||||
DEFAULT_ENVIRONMENT = 'production'
|
||||
|
||||
"""The environment variables of the app instance."""
|
||||
env = environ.Env()
|
||||
|
||||
"""Path to the package root - e.g. Django project."""
|
||||
root_dir = environ.Path(__file__) - 2
|
||||
|
||||
"""Path to the base directory of the app instance."""
|
||||
base_dir = env.path('BASE_DIR', default=str(root_dir - 1))
|
||||
|
||||
# Load config.env, OS environment variables will take precedence
|
||||
env.read_env(str(base_dir.path('config.env')))
|
||||
|
||||
"""The Django settings module's name to use."""
|
||||
DJANGO_SETTINGS_MODULE = env(
|
||||
'DJANGO_SETTINGS_MODULE',
|
||||
default='betg.settings.{}'.format(
|
||||
env('ENV', default=DEFAULT_ENVIRONMENT)
|
||||
),
|
||||
)
|
||||
|
|
Fichier diff supprimé car celui-ci est trop grand
Voir la Diff
|
@ -1,47 +1,46 @@
|
|||
"""
|
||||
Development settings.
|
||||
|
||||
- set debug mode to `True` by default
|
||||
- use Console backend for emails sending by default
|
||||
- add the django-debug-toolbar
|
||||
"""
|
||||
from .base import * # noqa
|
||||
from .base import INSTALLED_APPS, MIDDLEWARE, env
|
||||
|
||||
# DEBUG
|
||||
# GENERAL
|
||||
# ------------------------------------------------------------------------------
|
||||
DEBUG = env.bool('DJANGO_DEBUG', default=True)
|
||||
TEMPLATES[0]['OPTIONS']['debug'] = DEBUG
|
||||
|
||||
# SECRET CONFIGURATION
|
||||
# ------------------------------------------------------------------------------
|
||||
# @link https://docs.djangoproject.com/en/stable/ref/settings/#secret-key
|
||||
# Note: This key only used for development and testing.
|
||||
# https://docs.djangoproject.com/en/stable/ref/settings/#secret-key
|
||||
SECRET_KEY = env('DJANGO_SECRET_KEY', default='CHANGEME!!!')
|
||||
|
||||
# EMAIL CONFIGURATION
|
||||
# https://docs.djangoproject.com/en/stable/ref/settings/#allowed-hosts
|
||||
ALLOWED_HOSTS = env.list(
|
||||
'DJANGO_ALLOWED_HOSTS', default=['localhost', '0.0.0.0', '127.0.0.1']
|
||||
)
|
||||
|
||||
# EMAIL
|
||||
# ------------------------------------------------------------------------------
|
||||
# @link https://docs.djangoproject.com/en/stable/topics/email/#email-backends
|
||||
# @link https://django-environ.readthedocs.io/en/stable/#supported-types
|
||||
EMAIL_CONFIG = env.email_url('DJANGO_EMAIL_URL', default='consolemail://')
|
||||
|
||||
vars().update(EMAIL_CONFIG)
|
||||
|
||||
# django-debug-toolbar
|
||||
# ------------------------------------------------------------------------------
|
||||
MIDDLEWARE += ['debug_toolbar.middleware.DebugToolbarMiddleware', ]
|
||||
INSTALLED_APPS += ['debug_toolbar', ]
|
||||
|
||||
INTERNAL_IPS = ['127.0.0.1', ]
|
||||
|
||||
DEBUG_TOOLBAR_CONFIG = {
|
||||
'DISABLE_PANELS': [
|
||||
'debug_toolbar.panels.redirects.RedirectsPanel',
|
||||
],
|
||||
'SHOW_TEMPLATE_CONTEXT': True,
|
||||
# Uncomment if jQuery is already loaded by your assets:
|
||||
'JQUERY_URL': '',
|
||||
}
|
||||
# https://docs.djangoproject.com/en/stable/topics/email/#email-backends
|
||||
# https://django-environ.readthedocs.io/en/stable/#supported-types
|
||||
vars().update(env.email_url('DJANGO_EMAIL_URL', default='consolemail://'))
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# APPLICATION AND 3RD PARTY LIBRARY SETTINGS
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
# DJANGO DEBUG TOOLBAR
|
||||
# ------------------------------------------------------------------------------
|
||||
# https://django-debug-toolbar.readthedocs.io/en/stable/installation.html
|
||||
if env.bool('DJANGO_DEBUG_TOOLBAR', default=False):
|
||||
MIDDLEWARE += ['debug_toolbar.middleware.DebugToolbarMiddleware']
|
||||
INSTALLED_APPS += ['debug_toolbar']
|
||||
INTERNAL_IPS = ['127.0.0.1']
|
||||
DEBUG_TOOLBAR_CONFIG = {
|
||||
'DISABLE_PANELS': ['debug_toolbar.panels.redirects.RedirectsPanel'],
|
||||
'SHOW_TEMPLATE_CONTEXT': True,
|
||||
'JQUERY_URL': '',
|
||||
}
|
||||
|
||||
# DJANGO EXTENSIONS
|
||||
# ------------------------------------------------------------------------------
|
||||
# https://django-extensions.readthedocs.io/en/stable/index.html
|
||||
INSTALLED_APPS += ['django_extensions']
|
||||
|
|
|
@ -2,12 +2,16 @@
|
|||
Production settings.
|
||||
|
||||
- validate the configuration
|
||||
- disable debug mode
|
||||
- load secret key from environment variables
|
||||
- set other production configurations
|
||||
"""
|
||||
import os
|
||||
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
|
||||
from .base import * # noqa
|
||||
from .base import TEMPLATES, env, var_dir
|
||||
|
||||
# CONFIGURATION VALIDATION
|
||||
# ------------------------------------------------------------------------------
|
||||
|
@ -18,21 +22,84 @@ if not env('DJANGO_DATABASE_URL', default=None):
|
|||
"the value of your DATABASE_URL environment variable."
|
||||
)
|
||||
|
||||
# SECRET CONFIGURATION
|
||||
# Ensure that the default email address has been set
|
||||
if not env('DEFAULT_FROM_EMAIL', default=None):
|
||||
raise ImproperlyConfigured(
|
||||
"No default email address has been set, you should check "
|
||||
"the value of your DEFAULT_FROM_EMAIL environment variable."
|
||||
)
|
||||
|
||||
# GENERAL
|
||||
# ------------------------------------------------------------------------------
|
||||
# @link https://docs.djangoproject.com/en/stable/ref/settings/#secret-key
|
||||
# Raises ImproperlyConfigured exception if DJANGO_SECRET_KEY not in os.environ
|
||||
# https://docs.djangoproject.com/en/stable/ref/settings/#debug
|
||||
DEBUG = False
|
||||
|
||||
# https://docs.djangoproject.com/en/stable/ref/settings/#secret-key
|
||||
SECRET_KEY = env('DJANGO_SECRET_KEY')
|
||||
|
||||
# SITE CONFIGURATION
|
||||
# ------------------------------------------------------------------------------
|
||||
# Hosts/domain names that are valid for this site
|
||||
# @link https://docs.djangoproject.com/en/stable/ref/settings/#allowed-hosts
|
||||
# https://docs.djangoproject.com/en/stable/ref/settings/#allowed-hosts
|
||||
ALLOWED_HOSTS = env.list('DJANGO_ALLOWED_HOSTS', default=[])
|
||||
|
||||
# Always disable debug mode in production
|
||||
DEBUG = False
|
||||
# TEMPLATES
|
||||
# ------------------------------------------------------------------------------
|
||||
# https://docs.djangoproject.com/en/stable/ref/settings/#templates
|
||||
TEMPLATES[0]['OPTIONS']['debug'] = DEBUG
|
||||
TEMPLATES[0]['OPTIONS']['loaders'] = [
|
||||
(
|
||||
'django.template.loaders.cached.Loader',
|
||||
[
|
||||
'django.template.loaders.filesystem.Loader',
|
||||
'django.template.loaders.app_directories.Loader',
|
||||
],
|
||||
)
|
||||
]
|
||||
|
||||
# LOGGING
|
||||
# ------------------------------------------------------------------------------
|
||||
# https://docs.djangoproject.com/en/stable/topics/logging/
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
'disable_existing_loggers': False,
|
||||
'formatters': {
|
||||
'verbose': {
|
||||
'format': '%(asctime)s - %(levelname)s - %(module)s: %(message)s'
|
||||
}
|
||||
},
|
||||
'handlers': {
|
||||
'mail_admins': {
|
||||
'level': 'ERROR',
|
||||
'class': 'django.utils.log.AdminEmailHandler',
|
||||
},
|
||||
'file': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.handlers.TimedRotatingFileHandler',
|
||||
'filename': var_dir('log/betg.log'),
|
||||
'formatter': 'verbose',
|
||||
'when': 'midnight',
|
||||
'interval': 1,
|
||||
'backupCount': 30,
|
||||
},
|
||||
},
|
||||
'loggers': {
|
||||
'django': {
|
||||
'level': 'WARNING',
|
||||
'handlers': ['file'],
|
||||
'propagate': True,
|
||||
},
|
||||
'django.request': {
|
||||
'level': 'WARNING',
|
||||
'handlers': ['file', 'mail_admins'],
|
||||
'propagate': True,
|
||||
},
|
||||
'betg': {
|
||||
'level': 'INFO',
|
||||
'handlers': ['file', 'mail_admins'],
|
||||
'propagate': True,
|
||||
},
|
||||
},
|
||||
}
|
||||
if not os.path.isdir(var_dir('log')):
|
||||
os.mkdir(var_dir('log'), mode=0o750)
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# APPLICATION AND 3RD PARTY LIBRARY SETTINGS
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
"""
|
||||
With these settings, tests run faster.
|
||||
"""
|
||||
from .base import * # noqa
|
||||
from .base import TEMPLATES, env
|
||||
|
||||
# GENERAL
|
||||
# ------------------------------------------------------------------------------
|
||||
# https://docs.djangoproject.com/en/stable/ref/settings/#debug
|
||||
DEBUG = False
|
||||
|
||||
# https://docs.djangoproject.com/en/stable/ref/settings/#secret-key
|
||||
SECRET_KEY = env('DJANGO_SECRET_KEY', default='CHANGEME!!!')
|
||||
|
||||
# https://docs.djangoproject.com/en/stable/ref/settings/#test-runner
|
||||
TEST_RUNNER = 'django.test.runner.DiscoverRunner'
|
||||
|
||||
# CACHES
|
||||
# ------------------------------------------------------------------------------
|
||||
# https://docs.djangoproject.com/en/stable/ref/settings/#caches
|
||||
CACHES = {
|
||||
'default': {
|
||||
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
|
||||
'LOCATION': '',
|
||||
}
|
||||
}
|
||||
|
||||
# PASSWORDS
|
||||
# ------------------------------------------------------------------------------
|
||||
# https://docs.djangoproject.com/en/stable/ref/settings/#password-hashers
|
||||
PASSWORD_HASHERS = ['django.contrib.auth.hashers.MD5PasswordHasher']
|
||||
|
||||
# TEMPLATES
|
||||
# ------------------------------------------------------------------------------
|
||||
# https://docs.djangoproject.com/en/stable/ref/settings/#templates
|
||||
TEMPLATES[0]['OPTIONS']['debug'] = DEBUG
|
||||
TEMPLATES[0]['OPTIONS']['loaders'] = [
|
||||
(
|
||||
'django.template.loaders.cached.Loader',
|
||||
[
|
||||
'django.template.loaders.filesystem.Loader',
|
||||
'django.template.loaders.app_directories.Loader',
|
||||
],
|
||||
)
|
||||
]
|
||||
|
||||
# EMAIL
|
||||
# ------------------------------------------------------------------------------
|
||||
# https://docs.djangoproject.com/en/stable/ref/settings/#email-backend
|
||||
EMAIL_BACKEND = 'django.core.mail.backends.locmem.EmailBackend'
|
||||
# https://docs.djangoproject.com/en/stable/ref/settings/#email-host
|
||||
EMAIL_HOST = 'localhost'
|
||||
# https://docs.djangoproject.com/en/stable/ref/settings/#email-port
|
||||
EMAIL_PORT = 1025
|
|
@ -1,34 +1,105 @@
|
|||
# Base directory of the app instance, where the local and var folders are
|
||||
# located. Default is the current directory.
|
||||
# BASE_DIR=
|
||||
###########################################################
|
||||
# #
|
||||
# Edit the following configuration to suits your needs. #
|
||||
# #
|
||||
###########################################################
|
||||
|
||||
# Database configuration as an URL.
|
||||
# DJANGO_DATABASE_URL=psql://user:password@127.0.0.1:8458/betg
|
||||
|
||||
# Email configuration as an URL. Default is the local SMTP server in
|
||||
# production and the console in development.
|
||||
# use urllib.parse.quote_plus() for escaping reserved char (like @, :, $, &)
|
||||
# note @ is escaped as %40
|
||||
# DJANGO_EMAIL_URL='smtp+tls://'
|
||||
###############################################################################
|
||||
# MAIN SETTINGS
|
||||
###############################################################################
|
||||
|
||||
# Environment to use within the application.
|
||||
# Note that if you want to change the default value, this variable should be
|
||||
# either set by your uWSGI server or defined in your OS environment.
|
||||
# DJANGO_SETTINGS_MODULE=betg.settings.developement
|
||||
DJANGO_SETTINGS_MODULE=betg.settings.production
|
||||
#
|
||||
# The environment is used to load the proper settings for your application
|
||||
# instance. There is two ways for defining it, with the following precedence:
|
||||
# - DJANGO_SETTINGS_MODULE: the Python path to the settings module to use. It
|
||||
# allows you to define and use your own settings module. Use it with care!
|
||||
# Note: the module name will be used as the environment.
|
||||
# - ENV: the environment to use, which is one of 'production' or 'development'.
|
||||
#
|
||||
# Default is the 'production' environment.
|
||||
#ENV=production
|
||||
#ENV=development
|
||||
|
||||
# The secret key used to provide cryptographic signing. It should be set to
|
||||
# a unique, unpredictable value. On a GNU/Linux system, you could generate a
|
||||
# new one with:
|
||||
# $ head -c50 /dev/urandom | base64
|
||||
# DJANGO_SECRET_KEY=CHANGEME!!!
|
||||
# The secret key used to provide cryptographic signing.
|
||||
#
|
||||
# It should be set to a unique, unpredictable value. On a GNU/Linux system, you
|
||||
# could generate a new one with:
|
||||
#
|
||||
# $ head -c50 /dev/urandom | base64
|
||||
#
|
||||
# /!\ Required in production.
|
||||
#DJANGO_SECRET_KEY=CHANGEME!!!
|
||||
|
||||
# A coma-separated string representing the host/domain names that this Django
|
||||
# site can serve.
|
||||
# DJANGO_ALLOWED_HOSTS=example.org,
|
||||
# A coma-separated string representing the host/domain names that this
|
||||
# application instance can serve.
|
||||
#
|
||||
# /!\ Required in production.
|
||||
#DJANGO_ALLOWED_HOSTS=example.org,
|
||||
|
||||
# Turn on/off debug mode. Note that it's always disabled in production.
|
||||
# DJANGO_DEBUG=off
|
||||
###############################################################################
|
||||
# DATABASE SETTINGS
|
||||
###############################################################################
|
||||
|
||||
# Chemin sur lequel est servie l'application.
|
||||
# APP_LOCATION=/
|
||||
# Database configuration, as an URI.
|
||||
#
|
||||
# In production, the recommended database backend for better performances is
|
||||
# PostgreSQL - or MySQL if you prefer.
|
||||
#
|
||||
# Default is a SQLite database in development only.
|
||||
#
|
||||
# /!\ Required in production.
|
||||
#DJANGO_DATABASE_URL=postgres://user:password@127.0.0.1:5432/betg
|
||||
#DJANGO_DATABASE_URL=mysql://user:password@127.0.0.1:3306/betg
|
||||
|
||||
###############################################################################
|
||||
# EMAILS SETTINGS
|
||||
###############################################################################
|
||||
|
||||
# Email configuration for sending messages, as an URI.
|
||||
#
|
||||
# In production, you should either use a local SMTP server or a relay one. The
|
||||
# URI will be in that case of the form:
|
||||
#
|
||||
# PROTOCOL://[USER:PASSWORD@]HOST[:PORT]
|
||||
#
|
||||
# PROTOCOL can be smtp, smtp+ssl or smtp+tls. Note that special characters
|
||||
# in USER and PASSWORD - e.g. @ - must be escaped. It can be achieve with:
|
||||
#
|
||||
# $ python3 -c 'from urllib.parse import quote as q;print(q("USER")+":"+q("PASSWORD"))'
|
||||
#
|
||||
# Default is the local SMTP server in production and the console in development.
|
||||
#DJANGO_EMAIL_URL=smtp://localhost:25
|
||||
|
||||
# Default email address to use for various automated correspondence.
|
||||
#
|
||||
# /!\ Required in production.
|
||||
#DEFAULT_FROM_EMAIL=webmaster@example.org
|
||||
|
||||
# A comma separated list of all the people who get production error
|
||||
# notifications, following rfc2822 format
|
||||
#ADMINS='Cliss XXI <tech@cliss21.com>'
|
||||
|
||||
###############################################################################
|
||||
# MISC SETTINGS
|
||||
###############################################################################
|
||||
|
||||
# URL prefix on which the application is served.
|
||||
#
|
||||
# This is used to generate the static and media URLs, but also links to the
|
||||
# application which require an absolute URL.
|
||||
#
|
||||
# Default is '/', e.g. at the domain root.
|
||||
#APP_LOCATION=/
|
||||
|
||||
# Base directory of the app instance, where the local and var folders are
|
||||
# located.
|
||||
#
|
||||
# Default is the current directory.
|
||||
#BASE_DIR=
|
||||
|
||||
# Turn on/off debug mode.
|
||||
#
|
||||
# Note that it's always disabled in production.
|
||||
#DJANGO_DEBUG=off
|
||||
#DJANGO_DEBUG_TOOLBAR=on
|
||||
|
|
28
manage.py
28
manage.py
|
@ -2,35 +2,25 @@
|
|||
import os
|
||||
import sys
|
||||
|
||||
import environ
|
||||
|
||||
DEFAULT_DJANGO_SETTINGS_MODULE = 'betg.settings.production'
|
||||
from betg.settings import DJANGO_SETTINGS_MODULE
|
||||
|
||||
if __name__ == "__main__":
|
||||
env = environ.Env()
|
||||
|
||||
# Charge la configuration définie dans config.env
|
||||
if (env.bool('DJANGO_READ_CONFIG_FILE', default=True) and
|
||||
os.path.isfile('config.env')):
|
||||
env.read_env('config.env')
|
||||
|
||||
# Définis la valeur par défaut pour le module de settings
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', env(
|
||||
'DJANGO_SETTINGS_MODULE', default=DEFAULT_DJANGO_SETTINGS_MODULE
|
||||
))
|
||||
# Set the default settings module to use.
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', DJANGO_SETTINGS_MODULE)
|
||||
|
||||
try:
|
||||
from django.core.management import execute_from_command_line
|
||||
except ImportError:
|
||||
# L'importation pouvant échouer pour une raison quelconque, on s'assure
|
||||
# que le problème vient vraiment du fait que Django n'est pas installé.
|
||||
# The above import may fail for some other reason. Ensure that the
|
||||
# issue is really that Django is missing to avoid masking other
|
||||
# exceptions on Python 2.
|
||||
try:
|
||||
import django # noqa
|
||||
except ImportError:
|
||||
raise ImportError(
|
||||
"Impossible d'importer Django. Êtes-vous sûr qu'il est "
|
||||
"installé dans votre environnement ou que celui-ci est "
|
||||
"bien activé ?"
|
||||
"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?"
|
||||
)
|
||||
raise
|
||||
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
[tool.black]
|
||||
line-length = 79
|
||||
skip-string-normalization = true
|
||||
exclude = '''
|
||||
/(
|
||||
\.git
|
||||
| venv
|
||||
| local
|
||||
| var
|
||||
| migrations
|
||||
| node_modules
|
||||
| assets
|
||||
)/
|
||||
| urls(|_.+|/.+).py
|
||||
'''
|
||||
|
||||
[tool.isort]
|
||||
profile = 'black'
|
||||
line_length = 80
|
||||
known_django = 'django'
|
||||
known_first_party = 'betg'
|
||||
sections = [
|
||||
'FUTURE', 'STDLIB', 'DJANGO', 'THIRDPARTY', 'FIRSTPARTY', 'LOCALFOLDER'
|
||||
]
|
||||
skip_glob = '**/migrations/*.py'
|
|
@ -1,5 +1,6 @@
|
|||
# Local development dependencies.
|
||||
-r base.txt
|
||||
-r test.txt
|
||||
|
||||
coverage
|
||||
# Django
|
||||
# ------------------------------------------------------------------------------
|
||||
django-debug-toolbar
|
||||
django-extensions
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
# Tip: Try not to put anything here. Avoid dependencies in
|
||||
# production that aren't in development.
|
||||
-r base.txt
|
||||
|
||||
# PRECAUTION: avoid production dependencies that aren't in development.
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
-r base.txt
|
||||
|
||||
# Testing
|
||||
# ------------------------------------------------------------------------------
|
||||
pytest
|
||||
pytest-django
|
||||
|
||||
# Code quality
|
||||
# ------------------------------------------------------------------------------
|
||||
black
|
||||
flake8 >=3.5.0
|
||||
flake8-black
|
||||
flake8-isort
|
||||
isort >=5.0
|
||||
pytest-cov
|
27
setup.cfg
27
setup.cfg
|
@ -1,11 +1,32 @@
|
|||
[coverage:run]
|
||||
branch = True
|
||||
source =
|
||||
betg
|
||||
omit =
|
||||
betg/*tests*,
|
||||
betg/*/migrations/*,
|
||||
betg/settings/*,
|
||||
betg/wsgi.py
|
||||
|
||||
[coverage:report]
|
||||
exclude_lines =
|
||||
pragma: no cover
|
||||
if settings.DEBUG:
|
||||
raise NotImplementedError
|
||||
show_missing = True
|
||||
|
||||
[flake8]
|
||||
exclude =
|
||||
.git,
|
||||
.tox,
|
||||
venv,
|
||||
*/migrations/*,
|
||||
*/static/*,
|
||||
assets,
|
||||
build,
|
||||
dist,
|
||||
venv,
|
||||
*/migrations/*,
|
||||
betg/settings
|
||||
docs,
|
||||
node_modules
|
||||
per-file-ignores =
|
||||
urls.py: BLK
|
||||
max-line-length = 80
|
||||
|
|
Chargement…
Référencer dans un nouveau ticket