Reformatage #29

Closed
thubrecht wants to merge 19 commits from thubrecht/python3 into master
6 changed files with 103 additions and 111 deletions
Showing only changes of commit 2c92f35a75 - Show all commits

View file

@ -1,6 +1,7 @@
from authens.backends import ENSCASBackend as AuthENSBackend from authens.backends import ENSCASBackend as AuthENSBackend
from authens.utils import parse_entrance_year from authens.utils import parse_entrance_year
class ENSCASBackend(AuthENSBackend): class ENSCASBackend(AuthENSBackend):
# Override AuthENS backend user creation to implement the @<promo> logic # Override AuthENS backend user creation to implement the @<promo> logic

View file

@ -10,9 +10,10 @@ https://docs.djangoproject.com/en/1.7/ref/settings/
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os import os
from django.urls import reverse_lazy from django.urls import reverse_lazy
from .secrets import SECRET_KEY, GOOGLE_API_KEY, MAPBOX_API_KEY from .secrets import GOOGLE_API_KEY, MAPBOX_API_KEY, SECRET_KEY
BASE_DIR = os.path.dirname(os.path.dirname(__file__)) BASE_DIR = os.path.dirname(os.path.dirname(__file__))
@ -24,68 +25,65 @@ ALLOWED_HOSTS = []
# Application definition # Application definition
INSTALLED_APPS = [ INSTALLED_APPS = [
'django.contrib.admin', "django.contrib.admin",
'django.contrib.auth', "django.contrib.auth",
'django.contrib.contenttypes', "django.contrib.contenttypes",
'django.contrib.sessions', "django.contrib.sessions",
'django.contrib.messages', "django.contrib.messages",
'django.contrib.staticfiles', "django.contrib.staticfiles",
'django.contrib.gis', "django.contrib.gis",
'django.contrib.sites', "django.contrib.sites",
"django_elasticsearch_dsl",
'django_elasticsearch_dsl',
#'allauth', # Uncomment that part when you #'allauth', # Uncomment that part when you
#'allauth.account', # apply migration #'allauth.account', # apply migration
#'allauth.socialaccount', # Allauth -> AuthENS #'allauth.socialaccount', # Allauth -> AuthENS
"simple_email_confirmation",
'simple_email_confirmation', "authens",
'authens', "tastypie",
'tastypie', "braces",
'braces', "tinymce",
'tinymce', "taggit",
'taggit', "taggit_autosuggest",
'taggit_autosuggest', "avisstage",
'avisstage'
] ]
MIDDLEWARE = ( MIDDLEWARE = (
'django.middleware.security.SecurityMiddleware', "django.middleware.security.SecurityMiddleware",
'django.contrib.sessions.middleware.SessionMiddleware', "django.contrib.sessions.middleware.SessionMiddleware",
'django.middleware.common.CommonMiddleware', "django.middleware.common.CommonMiddleware",
'django.middleware.csrf.CsrfViewMiddleware', "django.middleware.csrf.CsrfViewMiddleware",
'django.contrib.auth.middleware.AuthenticationMiddleware', "django.contrib.auth.middleware.AuthenticationMiddleware",
'django.contrib.messages.middleware.MessageMiddleware', "django.contrib.messages.middleware.MessageMiddleware",
'django.middleware.clickjacking.XFrameOptionsMiddleware', "django.middleware.clickjacking.XFrameOptionsMiddleware",
) )
TEMPLATES = [ TEMPLATES = [
{ {
'BACKEND': 'django.template.backends.django.DjangoTemplates', "BACKEND": "django.template.backends.django.DjangoTemplates",
'DIRS': [ "DIRS": [
# insert your TEMPLATE_DIRS here # insert your TEMPLATE_DIRS here
], ],
'APP_DIRS': True, "APP_DIRS": True,
'OPTIONS': { "OPTIONS": {
'context_processors': [ "context_processors": [
'django.contrib.auth.context_processors.auth', "django.contrib.auth.context_processors.auth",
'django.template.context_processors.debug', "django.template.context_processors.debug",
'django.template.context_processors.i18n', "django.template.context_processors.i18n",
'django.template.context_processors.media', "django.template.context_processors.media",
'django.template.context_processors.static', "django.template.context_processors.static",
'django.template.context_processors.tz', "django.template.context_processors.tz",
'django.template.context_processors.request', "django.template.context_processors.request",
'django.contrib.messages.context_processors.messages', "django.contrib.messages.context_processors.messages",
], ],
}, },
}, },
] ]
ROOT_URLCONF = 'experiENS.urls' ROOT_URLCONF = "experiENS.urls"
WSGI_APPLICATION = 'experiENS.wsgi.application' WSGI_APPLICATION = "experiENS.wsgi.application"
# Database # Database
@ -94,9 +92,9 @@ WSGI_APPLICATION = 'experiENS.wsgi.application'
# Internationalization # Internationalization
# https://docs.djangoproject.com/en/1.7/topics/i18n/ # https://docs.djangoproject.com/en/1.7/topics/i18n/
LANGUAGE_CODE = 'fr' LANGUAGE_CODE = "fr"
TIME_ZONE = 'Europe/Paris' TIME_ZONE = "Europe/Paris"
USE_I18N = True USE_I18N = True
@ -109,37 +107,37 @@ SITE_ID = 1
# Static files (CSS, JavaScript, Images) # Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/ # https://docs.djangoproject.com/en/1.7/howto/static-files/
STATIC_URL = '/static/' STATIC_URL = "/static/"
AUTHENTICATION_BACKENDS = ( AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend', "django.contrib.auth.backends.ModelBackend",
'experiENS.auth.ENSCASBackend', "experiENS.auth.ENSCASBackend",
) )
CAS_SERVER_URL = "https://cas.eleves.ens.fr/" # SPI CAS CAS_SERVER_URL = "https://cas.eleves.ens.fr/" # SPI CAS
AUTHENS_USE_OLDCAS = False AUTHENS_USE_OLDCAS = False
LOGIN_URL = reverse_lazy('authens:login') LOGIN_URL = reverse_lazy("authens:login")
LOGOUT_URL = reverse_lazy('authens:logout') LOGOUT_URL = reverse_lazy("authens:logout")
LOGIN_REDIRECT_URL = reverse_lazy('avisstage:perso') LOGIN_REDIRECT_URL = reverse_lazy("avisstage:perso")
LOGOUT_REDIRECT_URL = reverse_lazy('avisstage:index') LOGOUT_REDIRECT_URL = reverse_lazy("avisstage:index")
LOGGING = { LOGGING = {
'version': 1, "version": 1,
'disable_existing_loggers': False, "disable_existing_loggers": False,
'handlers': { "handlers": {
'file': { "file": {
'level': 'INFO', "level": "INFO",
'class': 'logging.FileHandler', "class": "logging.FileHandler",
'filename': os.path.join(BASE_DIR, 'recherche.log'), "filename": os.path.join(BASE_DIR, "recherche.log"),
}, },
}, },
'loggers': { "loggers": {
'recherche': { "recherche": {
'handlers': ['file'], "handlers": ["file"],
'level': 'INFO', "level": "INFO",
'propagate': True, "propagate": True,
}, },
}, },
} }

View file

@ -3,9 +3,9 @@ from .settings_base import *
DEBUG = True DEBUG = True
DATABASES = { DATABASES = {
'default': { "default": {
'ENGINE': 'django.contrib.gis.db.backends.spatialite', "ENGINE": "django.contrib.gis.db.backends.spatialite",
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), "NAME": os.path.join(BASE_DIR, "db.sqlite3"),
} }
} }
@ -13,35 +13,30 @@ USE_DEBUG_TOOLBAR = False
if USE_DEBUG_TOOLBAR: if USE_DEBUG_TOOLBAR:
INSTALLED_APPS += [ INSTALLED_APPS += [
'debug_toolbar', "debug_toolbar",
] ]
MIDDLEWARE = ( MIDDLEWARE = ("debug_toolbar.middleware.DebugToolbarMiddleware",) + MIDDLEWARE
'debug_toolbar.middleware.DebugToolbarMiddleware',
) + MIDDLEWARE
INTERNAL_IPS = ['127.0.0.1'] INTERNAL_IPS = ["127.0.0.1"]
SPATIALITE_LIBRARY_PATH = 'mod_spatialite' SPATIALITE_LIBRARY_PATH = "mod_spatialite"
STATIC_ROOT = "/home/evarin/Bureau/experiENS/static/" STATIC_ROOT = "/home/evarin/Bureau/experiENS/static/"
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
STATIC_URL = "/experiens/static/" STATIC_URL = "/experiens/static/"
ELASTICSEARCH_DSL = { ELASTICSEARCH_DSL = {
'default': { "default": {"hosts": "localhost:9200"},
'hosts': 'localhost:9200'
},
} }
CLIPPER_LDAP_SERVER = 'ldaps://localhost:636' CLIPPER_LDAP_SERVER = "ldaps://localhost:636"
# Changer à True pour développer avec ES # Changer à True pour développer avec ES
USE_ELASTICSEARCH = False USE_ELASTICSEARCH = False
if not USE_ELASTICSEARCH: if not USE_ELASTICSEARCH:
INSTALLED_APPS.remove('django_elasticsearch_dsl') INSTALLED_APPS.remove("django_elasticsearch_dsl")

View file

@ -1,8 +1,10 @@
from .settings_base import * import os
import sys
import os, sys
from django.core.urlresolvers import reverse_lazy from django.core.urlresolvers import reverse_lazy
from .settings_base import *
PROJECT_DIR = os.path.dirname(os.path.abspath(__file__)) PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
BASE_DIR = os.path.dirname(PROJECT_DIR) BASE_DIR = os.path.dirname(PROJECT_DIR)
@ -10,9 +12,7 @@ DEBUG = False
ALLOWED_HOSTS = ["www.eleves.ens.fr"] ALLOWED_HOSTS = ["www.eleves.ens.fr"]
ADMINS = ( ADMINS = (("Robin Champenois", "champeno@clipper.ens.fr"),)
('Robin Champenois', 'champeno@clipper.ens.fr'),
)
ADMIN_LOGINS = [ ADMIN_LOGINS = [
"champeno", "champeno",
@ -22,33 +22,31 @@ SERVER_EMAIL = "experiens@www.eleves.ens.fr"
ROOT_URL = "/experiens/" ROOT_URL = "/experiens/"
WSGI_APPLICATION = 'experiENS.wsgi.application' WSGI_APPLICATION = "experiENS.wsgi.application"
DATABASES = { DATABASES = {
'default': { "default": {
'ENGINE': 'django.contrib.gis.db.backends.postgis', "ENGINE": "django.contrib.gis.db.backends.postgis",
'NAME': 'experiens', "NAME": "experiens",
'USER': 'experiens', "USER": "experiens",
'PASSWORD': '', "PASSWORD": "",
'HOST': '', "HOST": "",
'PORT': '5432', "PORT": "5432",
} }
} }
STATIC_URL = ROOT_URL + 'static/' STATIC_URL = ROOT_URL + "static/"
MEDIA_URL = ROOT_URL + 'media/' MEDIA_URL = ROOT_URL + "media/"
STATIC_ROOT = os.path.join(BASE_DIR, 'static/') STATIC_ROOT = os.path.join(BASE_DIR, "static/")
EMAIL_HOST = "nef.ens.fr" EMAIL_HOST = "nef.ens.fr"
ELASTICSEARCH_DSL = { ELASTICSEARCH_DSL = {
'default': { "default": {"hosts": "127.0.0.1:9200"},
'hosts': '127.0.0.1:9200'
},
} }
CLIPPER_LDAP_SERVER = 'ldaps://ldap.spi.ens.fr:636' CLIPPER_LDAP_SERVER = "ldaps://ldap.spi.ens.fr:636"
DEFAULT_FROM_EMAIL = "experiens-no-reply@www.eleves.ens.fr" DEFAULT_FROM_EMAIL = "experiens-no-reply@www.eleves.ens.fr"

View file

@ -1,20 +1,18 @@
from django.conf import settings from django.conf import settings
from django.urls import include, path
from django.contrib import admin from django.contrib import admin
from django.urls import include, path
urlpatterns = [ urlpatterns = [
path('', include('avisstage.urls')), path("", include("avisstage.urls")),
path("authens/", include("authens.urls")), path("authens/", include("authens.urls")),
path("tinymce/", include("tinymce.urls")),
path('tinymce/', include('tinymce.urls')), path("taggit_autosuggest/", include("taggit_autosuggest.urls")),
path('taggit_autosuggest/', include('taggit_autosuggest.urls')), path("admin/", admin.site.urls),
path('admin/', admin.site.urls),
] ]
if settings.DEBUG: if settings.DEBUG:
import debug_toolbar import debug_toolbar
urlpatterns = [ urlpatterns = [
path('__debug__/', include(debug_toolbar.urls)), path("__debug__/", include(debug_toolbar.urls)),
] + urlpatterns ] + urlpatterns

View file

@ -8,7 +8,9 @@ https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/
""" """
import os import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "experiENS.settings") os.environ.setdefault("DJANGO_SETTINGS_MODULE", "experiENS.settings")
from django.core.wsgi import get_wsgi_application from django.core.wsgi import get_wsgi_application
application = get_wsgi_application() application = get_wsgi_application()