Commit initial
révision
e97b486356
|
@ -0,0 +1,36 @@
|
||||||
|
# Editors
|
||||||
|
*~
|
||||||
|
*.sw[po]
|
||||||
|
|
||||||
|
# Python
|
||||||
|
*.py[cod]
|
||||||
|
__pycache__
|
||||||
|
|
||||||
|
# Virtual environment
|
||||||
|
.env
|
||||||
|
venv
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
pip-log.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
.coverage
|
||||||
|
.tox
|
||||||
|
nosetests.xml
|
||||||
|
htmlcov
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
*.mo
|
||||||
|
*.pot
|
||||||
|
|
||||||
|
# Databases
|
||||||
|
sqlite.db
|
||||||
|
|
||||||
|
# Local configuration
|
||||||
|
config.env
|
||||||
|
|
||||||
|
# Local overrides and variable content
|
||||||
|
local/
|
||||||
|
var/
|
|
@ -0,0 +1,8 @@
|
||||||
|
# Changelog
|
||||||
|
All notable changes to PIAF will be documented in this file.
|
||||||
|
|
||||||
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||||
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
|
|
||||||
|
## [Unreleased]
|
||||||
|
### Added
|
|
@ -0,0 +1 @@
|
||||||
|
This software is developped by Cliss XXI.
|
Fichier diff supprimé car celui-ci est trop grand
Voir la Diff
|
@ -0,0 +1,103 @@
|
||||||
|
# -*- mode: makefile-gmake -*-
|
||||||
|
## 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"
|
||||||
|
# Configuration de l'environnement virtuel.
|
||||||
|
VENV_DIR := venv
|
||||||
|
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")
|
||||||
|
PYTHON := $(VENV_DIR)/bin/$(PYTHON_EXE_BASENAME)
|
||||||
|
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
|
||||||
|
endif
|
||||||
|
# ... et définis l'environnement à utiliser.
|
||||||
|
ifdef DJANGO_SETTINGS_MODULE
|
||||||
|
ENV = $(shell echo $(DJANGO_SETTINGS_MODULE) | cut -d. -f3)
|
||||||
|
else
|
||||||
|
ENV = "production"
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Définition des cibles -------------------------------------------------------
|
||||||
|
|
||||||
|
.PHONY: clean-pyc clean-build clear-venv help
|
||||||
|
.DEFAULT_GOAL := help
|
||||||
|
|
||||||
|
# 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}'
|
||||||
|
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}'
|
||||||
|
endif
|
||||||
|
|
||||||
|
clean: clean-build clean-pyc ## nettoie tous les fichiers temporaires
|
||||||
|
|
||||||
|
clean-build: ### nettoie les fichiers de construction du paquet
|
||||||
|
rm -rf build/
|
||||||
|
rm -rf dist/
|
||||||
|
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 {} +
|
||||||
|
|
||||||
|
init: create-venv config.env update ## initialise l'environnement et l'application
|
||||||
|
|
||||||
|
config.env: # TODO: lancer une commande interactive
|
||||||
|
cp config.env.example config.env
|
||||||
|
|
||||||
|
update: install-deps migrate static ## mets à jour l'application et ses dépendances
|
||||||
|
touch piaf/wsgi.py
|
||||||
|
|
||||||
|
install-deps: ## installe les dépendances de l'application
|
||||||
|
$(PIP) install -r requirements/$(ENV).txt
|
||||||
|
|
||||||
|
migrate: ## mets à jour le schéma de la base de données
|
||||||
|
$(PYTHON) manage.py migrate
|
||||||
|
|
||||||
|
static: ## collecte les fichiers statiques
|
||||||
|
ifeq ($(ENV), "production") # on evite de faire du bruit en dev
|
||||||
|
@echo "Collecte des fichiers statiques..."
|
||||||
|
$(PYTHON) manage.py collectstatic --no-input --verbosity 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
## Cibles liées à l'environnement virtuel
|
||||||
|
|
||||||
|
create-venv: $(PYTHON)
|
||||||
|
|
||||||
|
$(PYTHON):
|
||||||
|
ifeq ($(USE_VENV), "yes")
|
||||||
|
virtualenv $(VENV_OPT) $(VENV_PYTHON) $(VENV_DIR)
|
||||||
|
else
|
||||||
|
@echo "\033[31mErreur !\033[0m Impossible de trouver l'exécutable Python $(PYTHON)"
|
||||||
|
@exit 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
clear-venv: ## supprime l'environnement virtuel
|
||||||
|
-rm -rf $(VENV_DIR)
|
||||||
|
|
||||||
|
## Cibles pour le développement
|
||||||
|
|
||||||
|
test: ### lance les tests de l'application
|
||||||
|
$(PYTHON) manage.py test --parallel 4
|
||||||
|
|
||||||
|
serve: ### démarre un serveur local pour l'application
|
||||||
|
$(PYTHON) manage.py runserver
|
||||||
|
|
||||||
|
lint: ### vérifie la syntaxe et le code python
|
||||||
|
flake8 piaf
|
|
@ -0,0 +1,98 @@
|
||||||
|
# PIAF
|
||||||
|
|
||||||
|
Portail Internet pour les Activités Familiales
|
||||||
|
|
||||||
|
[![Built with Cookiecutter Django](https://img.shields.io/badge/built%20with-Cookiecutter%20Django-ff69b4.svg)](https://github.com/pydanny/cookiecutter-django/)
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
### Requirements
|
||||||
|
|
||||||
|
On a Debian-based host - running at least Debian Stretch, you will need the
|
||||||
|
following packages:
|
||||||
|
- python3
|
||||||
|
- virtualenv
|
||||||
|
- python3-psycopg2 (optional, in case of a PostgreSQL database)
|
||||||
|
|
||||||
|
Note: if you're serving the application with uWSGI and NGINX on a sub location, ensure
|
||||||
|
that you've added `route-run = fixpathinfo:` to your uWSGI configuration (from
|
||||||
|
[v2.0.11](https://uwsgi-docs.readthedocs.io/en/latest/Changelog-2.0.11.html#fixpathinfo-routing-action)).
|
||||||
|
|
||||||
|
### Step by step
|
||||||
|
|
||||||
|
In waiting for a complete `Makefile`, you will have to follow those steps to
|
||||||
|
install the application.
|
||||||
|
|
||||||
|
It assumes that you have downloaded the last release of PIAF,
|
||||||
|
extracted it and that you moved to that folder.
|
||||||
|
|
||||||
|
1. Start by creating a new virtual environment under `./venv` and activate it:
|
||||||
|
|
||||||
|
$ virtualenv --system-site-packages ./venv
|
||||||
|
$ source ./venv/bin/activate
|
||||||
|
|
||||||
|
2. Install the required Python packages depending on your environment:
|
||||||
|
|
||||||
|
$ pip install -r requirements/production.txt
|
||||||
|
... or ...
|
||||||
|
$ pip install -r requirements/development.txt
|
||||||
|
|
||||||
|
3. Configure the application by setting the proper environment variables
|
||||||
|
depending on your environment. You can use the `config.env.example` which
|
||||||
|
give you the main variables with example values.
|
||||||
|
|
||||||
|
$ cp config.env.example config.env
|
||||||
|
$ nano config.env
|
||||||
|
|
||||||
|
Note that this `./config.env` file will be loaded by default when the
|
||||||
|
application starts. If you don't want that, just move this file away or set
|
||||||
|
the `DJANGO_READ_CONFIG_FILE` environment variable to `false`.
|
||||||
|
|
||||||
|
4. Create the database tables - it assumes that you have created the database
|
||||||
|
and set the proper configuration to use it:
|
||||||
|
|
||||||
|
$ ./manage.py migrate
|
||||||
|
|
||||||
|
That's it! You should now be able to start the Django development server to
|
||||||
|
check that everything is working fine with:
|
||||||
|
|
||||||
|
$ ./manage.py runserver
|
||||||
|
|
||||||
|
## Structure
|
||||||
|
### Overview
|
||||||
|
|
||||||
|
All the application files - e.g. Django code including settings, templates and
|
||||||
|
statics - are located into the `piaf/`. It should
|
||||||
|
permit in a near future to distribute the application as a Python package and
|
||||||
|
install it system-wide.
|
||||||
|
|
||||||
|
Two environments are defined - either for requirements and settings:
|
||||||
|
- `development`: for local application development and testing. It uses a
|
||||||
|
SQLite3 database and enable debugging by default, add some useful settings
|
||||||
|
and applications for development purpose - i.e. the `django-debug-toolbar`.
|
||||||
|
- `production`: for production. It checks that configuration is set and
|
||||||
|
correct, try to optimize performances and enforce some settings - i.e. HTTPS
|
||||||
|
related ones.
|
||||||
|
|
||||||
|
### Local changes
|
||||||
|
|
||||||
|
You can override and extend statics and templates locally. This can be useful
|
||||||
|
if you have to change the logo for a specific instance for example. For that,
|
||||||
|
just put your files under the `local/static/` and `local/templates/` folders.
|
||||||
|
|
||||||
|
Regarding the statics, do not forget to collect them after that. Note also that
|
||||||
|
the `local/` folder is ignored by *git*.
|
||||||
|
|
||||||
|
### Variable content
|
||||||
|
|
||||||
|
All the variable content - e.g. user-uploaded media, collected statics - are
|
||||||
|
stored inside the `var/` folder. It is also ignored by *git* as it's specific
|
||||||
|
to each application installation.
|
||||||
|
|
||||||
|
So, you will have to configure your Web server to serve the `var/media/` and
|
||||||
|
`var/static/` folders, which should point to `/media/` and `/static/`,
|
||||||
|
respectively.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
PIAF is developed by Cliss XXI and licensed under the
|
||||||
|
[AGPLv3+](LICENSE).
|
|
@ -0,0 +1,37 @@
|
||||||
|
# Base directory of the app instance, where the local and var folders are
|
||||||
|
# located. Default is the current directory.
|
||||||
|
# BASE_DIR=
|
||||||
|
|
||||||
|
# Database configuration as an URL.
|
||||||
|
# /!\ It must be set in production.
|
||||||
|
# DJANGO_DATABASE_URL=psql://user:password@127.0.0.1:5432/piaf
|
||||||
|
|
||||||
|
# Email configuration as an URL. Default is the local SMTP server in
|
||||||
|
# production and the console in development.
|
||||||
|
# DJANGO_EMAIL_URL=smtp+tls://localhost:587
|
||||||
|
|
||||||
|
# Default email address to use for various automated correspondence.
|
||||||
|
# /!\ It must be set in production.
|
||||||
|
# DEFAULT_FROM_EMAIL=webmaster@example.org
|
||||||
|
|
||||||
|
# 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=piaf.settings.production
|
||||||
|
|
||||||
|
# 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
|
||||||
|
# /!\ It must be set 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,
|
||||||
|
|
||||||
|
# Turn on/off debug mode. Note that it's always disabled in production.
|
||||||
|
# DJANGO_DEBUG=off
|
||||||
|
|
||||||
|
# Location on which the application is served.
|
||||||
|
# APP_LOCATION=/
|
|
@ -0,0 +1,25 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE',
|
||||||
|
'piaf.settings.development')
|
||||||
|
|
||||||
|
try:
|
||||||
|
from django.core.management import execute_from_command_line
|
||||||
|
except ImportError:
|
||||||
|
# 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(
|
||||||
|
"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
|
||||||
|
|
||||||
|
execute_from_command_line(sys.argv)
|
|
@ -0,0 +1 @@
|
||||||
|
__version__ = '0.1.0'
|
|
@ -0,0 +1 @@
|
||||||
|
default_app_config = 'piaf.base.apps.BaseConfig'
|
|
@ -0,0 +1,6 @@
|
||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class BaseConfig(AppConfig):
|
||||||
|
name = 'piaf.base'
|
||||||
|
verbose_name = "Base"
|
|
@ -0,0 +1,7 @@
|
||||||
|
from django.urls import path
|
||||||
|
from django.views.generic import TemplateView
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path('', TemplateView.as_view(template_name='pages/home.html'),
|
||||||
|
name='home'),
|
||||||
|
]
|
|
@ -0,0 +1 @@
|
||||||
|
from .base import * # noqa
|
|
@ -0,0 +1,258 @@
|
||||||
|
"""
|
||||||
|
Django settings for PIAF project.
|
||||||
|
|
||||||
|
For more information on this file, see
|
||||||
|
https://docs.djangoproject.com/en/2.0/topics/settings/
|
||||||
|
|
||||||
|
For the full list of settings and their values, see
|
||||||
|
https://docs.djangoproject.com/en/2.0/ref/settings/
|
||||||
|
"""
|
||||||
|
import logging
|
||||||
|
import os.path
|
||||||
|
|
||||||
|
import environ
|
||||||
|
|
||||||
|
logger = logging.getLogger('piaf')
|
||||||
|
|
||||||
|
# ENVIRONMENT VARIABLES AND PATHS
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Load environment variables
|
||||||
|
env = environ.Env()
|
||||||
|
|
||||||
|
# Package - e.g. Django project - root and apps directories
|
||||||
|
root_dir = environ.Path(__file__) - 2
|
||||||
|
apps_dir = root_dir.path('apps')
|
||||||
|
|
||||||
|
# Base directory of the app instance
|
||||||
|
# Note that it should be defined in OS environment variables in case of a
|
||||||
|
# multi-instances application.
|
||||||
|
base_dir = env.path('BASE_DIR', default=str(root_dir - 1))
|
||||||
|
|
||||||
|
# Local directory used for static and templates overrides
|
||||||
|
local_dir = base_dir.path('local')
|
||||||
|
|
||||||
|
# Directory for variable stuffs, i.e. user-uploaded media
|
||||||
|
var_dir = base_dir.path('var')
|
||||||
|
if not os.path.isdir(var_dir()):
|
||||||
|
os.mkdir(var_dir(), mode=0o755)
|
||||||
|
|
||||||
|
# Whether config.env should be loaded here
|
||||||
|
READ_CONFIG_FILE = env.bool('DJANGO_READ_CONFIG_FILE', default=True)
|
||||||
|
|
||||||
|
if READ_CONFIG_FILE:
|
||||||
|
# Note that OS environment variables have precedence over variables defined
|
||||||
|
# in the config.env file. The latter will only be used if not defined as
|
||||||
|
# environment variables.
|
||||||
|
env_file = str(base_dir.path('config.env'))
|
||||||
|
if os.path.isfile(env_file):
|
||||||
|
logger.debug('Loading configuration from: %s', env_file)
|
||||||
|
env.read_env(env_file)
|
||||||
|
else:
|
||||||
|
logger.warning('Configuration file does not exist: %s', env_file)
|
||||||
|
|
||||||
|
# Location on which the application is served
|
||||||
|
APP_LOCATION = env('APP_LOCATION', default='/')
|
||||||
|
|
||||||
|
# APP CONFIGURATION
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
DJANGO_APPS = [
|
||||||
|
'django.contrib.admin',
|
||||||
|
'django.contrib.auth',
|
||||||
|
'django.contrib.contenttypes',
|
||||||
|
'django.contrib.sessions',
|
||||||
|
'django.contrib.messages',
|
||||||
|
'django.contrib.staticfiles',
|
||||||
|
]
|
||||||
|
|
||||||
|
# Project dependencies
|
||||||
|
THIRD_PARTY_APPS = []
|
||||||
|
|
||||||
|
# Project applications
|
||||||
|
LOCAL_APPS = [
|
||||||
|
'piaf.base',
|
||||||
|
]
|
||||||
|
|
||||||
|
# @link https://docs.djangoproject.com/en/2.0/ref/settings/#installed-apps
|
||||||
|
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
|
||||||
|
|
||||||
|
# MIDDLEWARE CONFIGURATION
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# @link https://docs.djangoproject.com/en/2.0/ref/settings/#middleware
|
||||||
|
MIDDLEWARE = [
|
||||||
|
'django.middleware.security.SecurityMiddleware',
|
||||||
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||||
|
'django.middleware.common.CommonMiddleware',
|
||||||
|
'django.middleware.csrf.CsrfViewMiddleware',
|
||||||
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||||
|
'django.contrib.messages.middleware.MessageMiddleware',
|
||||||
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
# DEBUG
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# @link https://docs.djangoproject.com/en/2.0/ref/settings/#debug
|
||||||
|
DEBUG = env.bool('DJANGO_DEBUG', default=False)
|
||||||
|
|
||||||
|
# FIXTURE CONFIGURATION
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# @link https://docs.djangoproject.com/en/2.0/ref/settings/#fixture-dirs
|
||||||
|
FIXTURE_DIRS = (
|
||||||
|
root_dir('fixtures'),
|
||||||
|
)
|
||||||
|
|
||||||
|
# EMAIL CONFIGURATION
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# @link https://docs.djangoproject.com/en/2.0/topics/email/#email-backends
|
||||||
|
# @link https://django-environ.readthedocs.io/en/stable/#supported-types
|
||||||
|
vars().update(env.email_url(
|
||||||
|
'DJANGO_EMAIL_URL', default='smtp://localhost:25'))
|
||||||
|
|
||||||
|
DEFAULT_FROM_EMAIL = env('DEFAULT_FROM_EMAIL', default='webmaster@localhost')
|
||||||
|
|
||||||
|
# MANAGER CONFIGURATION
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# @link https://docs.djangoproject.com/en/2.0/ref/settings/#admins
|
||||||
|
ADMINS = [
|
||||||
|
("""Cliss XXI""", 'tech@cliss21.com'),
|
||||||
|
]
|
||||||
|
|
||||||
|
# @link https://docs.djangoproject.com/en/2.0/ref/settings/#managers
|
||||||
|
MANAGERS = ADMINS
|
||||||
|
|
||||||
|
# DATABASE CONFIGURATION
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# @link https://docs.djangoproject.com/en/2.0/ref/settings/#databases
|
||||||
|
# @link https://django-environ.readthedocs.io/en/stable/#supported-types
|
||||||
|
DATABASES = {
|
||||||
|
'default': env.db_url(
|
||||||
|
'DJANGO_DATABASE_URL', default='sqlite:///{}'.format(
|
||||||
|
base_dir('sqlite.db'))),
|
||||||
|
}
|
||||||
|
|
||||||
|
# GENERAL CONFIGURATION
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Local time zone for this installation.
|
||||||
|
TIME_ZONE = 'Europe/Paris'
|
||||||
|
|
||||||
|
# @link https://docs.djangoproject.com/en/2.0/ref/settings/#language-code
|
||||||
|
LANGUAGE_CODE = 'fr'
|
||||||
|
|
||||||
|
# @link https://docs.djangoproject.com/en/2.0/ref/settings/#use-i18n
|
||||||
|
USE_I18N = True
|
||||||
|
|
||||||
|
# @link https://docs.djangoproject.com/en/2.0/ref/settings/#use-l10n
|
||||||
|
USE_L10N = True
|
||||||
|
|
||||||
|
# @link https://docs.djangoproject.com/en/2.0/ref/settings/#use-tz
|
||||||
|
USE_TZ = True
|
||||||
|
|
||||||
|
# TEMPLATE CONFIGURATION
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# @link https://docs.djangoproject.com/en/2.0/ref/settings/#templates
|
||||||
|
# @link https://docs.djangoproject.com/en/2.0/topics/templates/
|
||||||
|
TEMPLATES = [
|
||||||
|
{
|
||||||
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
|
'DIRS': [
|
||||||
|
root_dir('templates'),
|
||||||
|
],
|
||||||
|
'OPTIONS': {
|
||||||
|
'debug': DEBUG,
|
||||||
|
'loaders': [
|
||||||
|
'django.template.loaders.filesystem.Loader',
|
||||||
|
'django.template.loaders.app_directories.Loader',
|
||||||
|
],
|
||||||
|
'context_processors': [
|
||||||
|
'django.template.context_processors.debug',
|
||||||
|
'django.template.context_processors.request',
|
||||||
|
'django.contrib.auth.context_processors.auth',
|
||||||
|
# 'django.template.context_processors.i18n',
|
||||||
|
'django.template.context_processors.media',
|
||||||
|
'django.template.context_processors.static',
|
||||||
|
'django.template.context_processors.tz',
|
||||||
|
'django.contrib.messages.context_processors.messages',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
if os.path.isdir(local_dir('templates')):
|
||||||
|
TEMPLATES[0]['DIRS'].insert(0, local_dir('templates'))
|
||||||
|
|
||||||
|
# STATIC FILE CONFIGURATION
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# @link https://docs.djangoproject.com/en/2.0/ref/settings/#static-files
|
||||||
|
STATIC_ROOT = var_dir('static')
|
||||||
|
|
||||||
|
STATIC_URL = os.path.join(APP_LOCATION, 'static/')
|
||||||
|
|
||||||
|
STATICFILES_DIRS = [
|
||||||
|
root_dir('static'),
|
||||||
|
]
|
||||||
|
|
||||||
|
if os.path.isdir(local_dir('static')):
|
||||||
|
STATICFILES_DIRS.insert(0, local_dir('static'))
|
||||||
|
|
||||||
|
STATICFILES_FINDERS = [
|
||||||
|
'django.contrib.staticfiles.finders.FileSystemFinder',
|
||||||
|
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
||||||
|
]
|
||||||
|
|
||||||
|
# MEDIA CONFIGURATION
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# @link https://docs.djangoproject.com/en/2.0/ref/settings/#media-root
|
||||||
|
MEDIA_ROOT = var_dir('media')
|
||||||
|
|
||||||
|
# @link https://docs.djangoproject.com/en/2.0/ref/settings/#media-url
|
||||||
|
MEDIA_URL = os.path.join(APP_LOCATION, 'media/')
|
||||||
|
|
||||||
|
# URL Configuration
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
ROOT_URLCONF = 'piaf.urls'
|
||||||
|
|
||||||
|
# @link https://docs.djangoproject.com/en/2.0/ref/settings/#wsgi-application
|
||||||
|
WSGI_APPLICATION = 'piaf.wsgi.application'
|
||||||
|
|
||||||
|
# PASSWORD STORAGE SETTINGS
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# @link https://docs.djangoproject.com/en/2.0/ref/settings/#password-hashers
|
||||||
|
PASSWORD_HASHERS = [
|
||||||
|
'django.contrib.auth.hashers.PBKDF2PasswordHasher',
|
||||||
|
'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
|
||||||
|
'django.contrib.auth.hashers.BCryptSHA256PasswordHasher',
|
||||||
|
'django.contrib.auth.hashers.BCryptPasswordHasher',
|
||||||
|
# @link https://docs.djangoproject.com/en/2.0/topics/auth/passwords/#using-argon2-with-django # noqa
|
||||||
|
# 'django.contrib.auth.hashers.Argon2PasswordHasher',
|
||||||
|
]
|
||||||
|
|
||||||
|
# PASSWORD VALIDATION
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# @link https://docs.djangoproject.com/en/2.0/topics/auth/passwords/#password-validation # noqa
|
||||||
|
AUTH_PASSWORD_VALIDATORS = [
|
||||||
|
{
|
||||||
|
'NAME': ('django.contrib.auth.password_validation.'
|
||||||
|
'UserAttributeSimilarityValidator'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'NAME': ('django.contrib.auth.password_validation.'
|
||||||
|
'MinimumLengthValidator'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'NAME': ('django.contrib.auth.password_validation.'
|
||||||
|
'CommonPasswordValidator'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'NAME': ('django.contrib.auth.password_validation.'
|
||||||
|
'NumericPasswordValidator'),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
# COOKIES
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
SESSION_COOKIE_PATH = APP_LOCATION
|
||||||
|
CSRF_COOKIE_PATH = APP_LOCATION
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# APPLICATION AND 3RD PARTY LIBRARY SETTINGS
|
||||||
|
# ------------------------------------------------------------------------------
|
|
@ -0,0 +1,43 @@
|
||||||
|
"""
|
||||||
|
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
|
||||||
|
|
||||||
|
# DEBUG
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
DEBUG = env.bool('DJANGO_DEBUG', default=True)
|
||||||
|
TEMPLATES[0]['OPTIONS']['debug'] = DEBUG
|
||||||
|
|
||||||
|
# SECRET CONFIGURATION
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Note: This key only used for development and testing.
|
||||||
|
SECRET_KEY = env('DJANGO_SECRET_KEY', default='CHANGEME!!!')
|
||||||
|
|
||||||
|
# EMAIL CONFIGURATION
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
vars().update(env.email_url(
|
||||||
|
'DJANGO_EMAIL_URL', default='consolemail://'))
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# APPLICATION AND 3RD PARTY LIBRARY SETTINGS
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# 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': '',
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
"""
|
||||||
|
Production settings.
|
||||||
|
|
||||||
|
- validate the configuration
|
||||||
|
- load secret key from environment variables
|
||||||
|
- set other production configurations
|
||||||
|
"""
|
||||||
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
|
|
||||||
|
from .base import * # noqa
|
||||||
|
|
||||||
|
# CONFIGURATION VALIDATION
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Ensure that the database configuration has been set
|
||||||
|
if not env('DJANGO_DATABASE_URL', default=None):
|
||||||
|
raise ImproperlyConfigured(
|
||||||
|
"No database configuration has been set, you should check "
|
||||||
|
"the value of your DATABASE_URL environment variable."
|
||||||
|
)
|
||||||
|
|
||||||
|
# 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."
|
||||||
|
)
|
||||||
|
|
||||||
|
# Always disable debug mode in production
|
||||||
|
DEBUG = False
|
||||||
|
TEMPLATES[0]['OPTIONS']['debug'] = DEBUG
|
||||||
|
|
||||||
|
# SECRET CONFIGURATION
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Raises ImproperlyConfigured exception if DJANGO_SECRET_KEY not in os.environ
|
||||||
|
SECRET_KEY = env('DJANGO_SECRET_KEY')
|
||||||
|
|
||||||
|
# SITE CONFIGURATION
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Hosts/domain names that are valid for this site
|
||||||
|
# @link https://docs.djangoproject.com/en/2.0/ref/settings/#allowed-hosts
|
||||||
|
ALLOWED_HOSTS = env.list('DJANGO_ALLOWED_HOSTS', default=[])
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# APPLICATION AND 3RD PARTY LIBRARY SETTINGS
|
||||||
|
# ------------------------------------------------------------------------------
|
|
@ -0,0 +1,7 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}Page introuvable{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<p>La page que vous demandez semble introuvable...</p>
|
||||||
|
{% endblock %}
|
|
@ -0,0 +1,7 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}Erreur interne{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<p>Une erreur inattendue est survenue...</p>
|
||||||
|
{% endblock %}
|
|
@ -0,0 +1,43 @@
|
||||||
|
{% load staticfiles %}<!DOCTYPE html>
|
||||||
|
<html class="no-js" lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
|
||||||
|
<title>
|
||||||
|
{% block title %}{% endblock %}
|
||||||
|
{% block title_suffix %}- PIAF{% endblock %}
|
||||||
|
</title>
|
||||||
|
|
||||||
|
<meta name="description" content="">
|
||||||
|
<meta name="keywords" content="">
|
||||||
|
|
||||||
|
{% block css %}
|
||||||
|
<link rel="stylesheet" href="{% static "css/app.css" %}">
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block extra_head %}{% endblock %}
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
|
||||||
|
{% if messages %}
|
||||||
|
{% for message in messages %}
|
||||||
|
<div class="callout{% if message.tags %} {{ message.tags }}{% endif %}">{{ message }}</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<p>Utilisez ce modèle pour démarrer rapidement une nouvelle application.</p>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
</div><!-- .container -->
|
||||||
|
|
||||||
|
{% block modal %}{% endblock %}
|
||||||
|
|
||||||
|
{% block javascript %}
|
||||||
|
<script src="{% static "js/app.js" %}"></script>
|
||||||
|
{% endblock %}
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,8 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}Accueil{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>Bienvenue !</h1>
|
||||||
|
<p>Cette page ne dira pas grand chose de plus, à vous de la personnaliser.</p>
|
||||||
|
{% endblock content %}
|
|
@ -0,0 +1,37 @@
|
||||||
|
from django.conf import settings
|
||||||
|
from django.contrib import admin
|
||||||
|
from django.urls import include, path
|
||||||
|
|
||||||
|
from .base import urls as base_urls
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path('admin/', admin.site.urls),
|
||||||
|
|
||||||
|
# Local applications
|
||||||
|
# ...
|
||||||
|
]
|
||||||
|
|
||||||
|
if settings.DEBUG:
|
||||||
|
from django.conf.urls.static import static
|
||||||
|
from django.views import defaults as default_views
|
||||||
|
|
||||||
|
# This allows the error pages to be debugged during development, just visit
|
||||||
|
# these url in browser to see how these error pages look like.
|
||||||
|
urlpatterns += [
|
||||||
|
path('400/', default_views.bad_request,
|
||||||
|
kwargs={'exception': Exception('Bad Request!')}),
|
||||||
|
path('403/', default_views.permission_denied,
|
||||||
|
kwargs={'exception': Exception('Permission Denied')}),
|
||||||
|
path('404/', default_views.page_not_found,
|
||||||
|
kwargs={'exception': Exception('Page not Found')}),
|
||||||
|
path('500/', default_views.server_error),
|
||||||
|
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||||
|
|
||||||
|
if 'debug_toolbar' in settings.INSTALLED_APPS:
|
||||||
|
import debug_toolbar
|
||||||
|
urlpatterns.insert(0, path('__debug__/', include(debug_toolbar.urls)))
|
||||||
|
|
||||||
|
# Root application
|
||||||
|
urlpatterns += [
|
||||||
|
path('', include(base_urls)),
|
||||||
|
]
|
|
@ -0,0 +1,23 @@
|
||||||
|
"""
|
||||||
|
WSGI config for PIAF project.
|
||||||
|
|
||||||
|
This module contains the WSGI application used by Django's development server
|
||||||
|
and any production WSGI deployments. It should expose a module-level variable
|
||||||
|
named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover
|
||||||
|
this application via the ``WSGI_APPLICATION`` setting.
|
||||||
|
"""
|
||||||
|
import os
|
||||||
|
|
||||||
|
from django.core.wsgi import get_wsgi_application
|
||||||
|
|
||||||
|
# We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks
|
||||||
|
# if running multiple sites in the same mod_wsgi process. To fix this, use
|
||||||
|
# mod_wsgi daemon mode with each site in its own daemon process, or use
|
||||||
|
# os.environ["DJANGO_SETTINGS_MODULE"] = "config.settings.production"
|
||||||
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE',
|
||||||
|
'piaf.settings.production')
|
||||||
|
|
||||||
|
# This application object is used by any WSGI server configured to use this
|
||||||
|
# file. This includes Django's development server, if the WSGI_APPLICATION
|
||||||
|
# setting points here.
|
||||||
|
application = get_wsgi_application()
|
|
@ -0,0 +1,3 @@
|
||||||
|
# This file is here because many Platforms as a Service look for
|
||||||
|
# requirements.txt in the root directory of a project.
|
||||||
|
-r requirements/production.txt
|
|
@ -0,0 +1,2 @@
|
||||||
|
django >=2.0,<2.1
|
||||||
|
django-environ
|
|
@ -0,0 +1,7 @@
|
||||||
|
# Local development dependencies.
|
||||||
|
-r base.txt
|
||||||
|
|
||||||
|
django-debug-toolbar
|
||||||
|
ipython
|
||||||
|
flake8
|
||||||
|
httpie
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Tip: Try not to put anything here. Avoid dependencies in
|
||||||
|
# production that aren't in development.
|
||||||
|
-r base.txt
|
|
@ -0,0 +1,13 @@
|
||||||
|
[flake8]
|
||||||
|
exclude =
|
||||||
|
.git,
|
||||||
|
.tox,
|
||||||
|
venv,
|
||||||
|
*/migrations/*,
|
||||||
|
*/static/*,
|
||||||
|
# assets & compilation
|
||||||
|
assets,
|
||||||
|
build,
|
||||||
|
dist,
|
||||||
|
node_modules
|
||||||
|
max-line-length = 80
|
Chargement…
Référencer dans un nouveau ticket