First commit
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
"""
|
||||
Point d'entrée ASGI pour le projet LOGIS.
|
||||
"""
|
||||
import os
|
||||
from django.core.asgi import get_asgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'logis_project.settings.production')
|
||||
|
||||
application = get_asgi_application()
|
||||
@@ -0,0 +1,138 @@
|
||||
"""
|
||||
Configuration de base commune à tous les environnements.
|
||||
"""
|
||||
from pathlib import Path
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from decouple import config, Csv
|
||||
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent.parent
|
||||
|
||||
SECRET_KEY = config('SECRET_KEY')
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'django.contrib.sitemaps',
|
||||
'django_resized',
|
||||
'adminsortable2',
|
||||
'properties',
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'whitenoise.middleware.WhiteNoiseMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.locale.LocaleMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'logis_project.urls'
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [BASE_DIR / 'templates'],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
'django.template.context_processors.debug',
|
||||
'django.template.context_processors.request',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
'django.template.context_processors.i18n',
|
||||
'properties.context_processors.site_settings',
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
WSGI_APPLICATION = 'logis_project.wsgi.application'
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': BASE_DIR / 'db.sqlite3',
|
||||
}
|
||||
}
|
||||
|
||||
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'},
|
||||
]
|
||||
|
||||
# Internationalisation
|
||||
LANGUAGE_CODE = 'fr'
|
||||
LANGUAGES = [
|
||||
('fr', _('Français')),
|
||||
('en', _('English')),
|
||||
]
|
||||
TIME_ZONE = 'Europe/Paris'
|
||||
USE_I18N = True
|
||||
USE_L10N = True
|
||||
USE_TZ = True
|
||||
LOCALE_PATHS = [BASE_DIR / 'locale']
|
||||
|
||||
# Fichiers statiques
|
||||
STATIC_URL = '/static/'
|
||||
STATIC_ROOT = BASE_DIR / 'staticfiles'
|
||||
STATICFILES_DIRS = [BASE_DIR / 'static']
|
||||
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
|
||||
|
||||
# Fichiers médias
|
||||
MEDIA_URL = '/media/'
|
||||
MEDIA_ROOT = BASE_DIR / 'media'
|
||||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||
|
||||
# django-resized : configuration par défaut
|
||||
DJANGORESIZED_DEFAULT_SIZE = [1920, 1080]
|
||||
DJANGORESIZED_DEFAULT_SCALE = 1.0
|
||||
DJANGORESIZED_DEFAULT_QUALITY = 85
|
||||
DJANGORESIZED_DEFAULT_KEEP_META = True
|
||||
DJANGORESIZED_DEFAULT_FORCE_FORMAT = 'WEBP'
|
||||
DJANGORESIZED_DEFAULT_FORMAT_EXTENSIONS = {'WEBP': '.webp', 'JPEG': '.jpg'}
|
||||
DJANGORESIZED_DEFAULT_NORMALIZE_ROTATION = True
|
||||
|
||||
# Configuration email (envoi uniquement)
|
||||
EMAIL_BACKEND = config(
|
||||
'EMAIL_BACKEND',
|
||||
default='django.core.mail.backends.smtp.EmailBackend',
|
||||
)
|
||||
EMAIL_HOST = config('EMAIL_HOST', default='localhost')
|
||||
EMAIL_PORT = config('EMAIL_PORT', default=587, cast=int)
|
||||
EMAIL_USE_TLS = config('EMAIL_USE_TLS', default=True, cast=bool)
|
||||
EMAIL_HOST_USER = config('EMAIL_HOST_USER', default='')
|
||||
EMAIL_HOST_PASSWORD = config('EMAIL_HOST_PASSWORD', default='')
|
||||
SITE_DOMAIN = config('SITE_DOMAIN', default='')
|
||||
DEFAULT_FROM_EMAIL = config('DEFAULT_FROM_EMAIL', default='LOGIS <noreply@example.com>')
|
||||
ADMIN_EMAIL = config('ADMIN_EMAIL', default='admin@example.com')
|
||||
|
||||
# Logging
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
'disable_existing_loggers': False,
|
||||
'handlers': {
|
||||
'console': {'class': 'logging.StreamHandler'},
|
||||
},
|
||||
'root': {
|
||||
'handlers': ['console'],
|
||||
'level': 'WARNING',
|
||||
},
|
||||
'loggers': {
|
||||
'properties': {
|
||||
'handlers': ['console'],
|
||||
'level': 'INFO',
|
||||
'propagate': False,
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
"""
|
||||
Configuration pour l'environnement de développement.
|
||||
"""
|
||||
from .base import * # noqa: F401, F403
|
||||
from decouple import config
|
||||
|
||||
DEBUG = True
|
||||
|
||||
ALLOWED_HOSTS = ['localhost', '127.0.0.1', '0.0.0.0']
|
||||
|
||||
# Email en console pendant le développement
|
||||
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
|
||||
|
||||
# Désactive la compression des fichiers statiques en dev
|
||||
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage'
|
||||
@@ -0,0 +1,63 @@
|
||||
"""
|
||||
Configuration pour l'environnement de production.
|
||||
"""
|
||||
from .base import * # noqa: F401, F403
|
||||
from decouple import config, Csv
|
||||
|
||||
DEBUG = False
|
||||
|
||||
ALLOWED_HOSTS = config('ALLOWED_HOSTS', cast=Csv(), default='localhost')
|
||||
|
||||
# Sécurité HTTPS
|
||||
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
||||
SECURE_SSL_REDIRECT = True
|
||||
SESSION_COOKIE_SECURE = True
|
||||
CSRF_COOKIE_SECURE = True
|
||||
SECURE_HSTS_SECONDS = 31536000
|
||||
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
|
||||
SECURE_HSTS_PRELOAD = True
|
||||
SECURE_CONTENT_TYPE_NOSNIFF = True
|
||||
X_FRAME_OPTIONS = 'DENY'
|
||||
|
||||
# Cache des sessions
|
||||
SESSION_ENGINE = 'django.contrib.sessions.backends.db'
|
||||
|
||||
# Logging en production vers fichier
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
'disable_existing_loggers': False,
|
||||
'formatters': {
|
||||
'verbose': {
|
||||
'format': '{levelname} {asctime} {module} {message}',
|
||||
'style': '{',
|
||||
},
|
||||
},
|
||||
'handlers': {
|
||||
'file': {
|
||||
'class': 'logging.FileHandler',
|
||||
'filename': '/var/log/logis/django.log',
|
||||
'formatter': 'verbose',
|
||||
},
|
||||
},
|
||||
'root': {
|
||||
'handlers': ['file'],
|
||||
'level': 'WARNING',
|
||||
},
|
||||
'loggers': {
|
||||
'django.request': {
|
||||
'handlers': ['file'],
|
||||
'level': 'ERROR', # 404 → silencieux, seuls les 500 sont loggués
|
||||
'propagate': False,
|
||||
},
|
||||
'django.security': {
|
||||
'handlers': ['file'],
|
||||
'level': 'ERROR',
|
||||
'propagate': False,
|
||||
},
|
||||
'properties': {
|
||||
'handlers': ['file'],
|
||||
'level': 'INFO',
|
||||
'propagate': False,
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
"""
|
||||
URLs principales du projet LOGIS.
|
||||
"""
|
||||
from django.contrib import admin
|
||||
from django.conf import settings
|
||||
from django.conf.urls.static import static
|
||||
from django.conf.urls.i18n import i18n_patterns
|
||||
from django.urls import path, include
|
||||
from django.contrib.sitemaps.views import sitemap
|
||||
from django.views.generic import TemplateView
|
||||
from properties.sitemaps import PropertySitemap
|
||||
|
||||
admin.site.site_header = 'LOGIS — Administration'
|
||||
admin.site.site_title = 'LOGIS'
|
||||
admin.site.index_title = 'Gestion des biens immobiliers'
|
||||
|
||||
_sitemaps = {'properties': PropertySitemap()}
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path('i18n/', include('django.conf.urls.i18n')),
|
||||
path('sitemap.xml', sitemap, {'sitemaps': _sitemaps}, name='django.contrib.sitemaps.views.sitemap'),
|
||||
path('robots.txt', TemplateView.as_view(template_name='robots.txt', content_type='text/plain')),
|
||||
]
|
||||
|
||||
urlpatterns += i18n_patterns(
|
||||
path('', include('properties.urls')),
|
||||
prefix_default_language=False,
|
||||
)
|
||||
|
||||
if settings.DEBUG:
|
||||
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
|
||||
@@ -0,0 +1,9 @@
|
||||
"""
|
||||
Point d'entrée WSGI pour le projet LOGIS.
|
||||
"""
|
||||
import os
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'logis_project.settings.production')
|
||||
|
||||
application = get_wsgi_application()
|
||||
Reference in New Issue
Block a user