From d8a0e41900fb8a16e9c29dbad72e7da11c836dee Mon Sep 17 00:00:00 2001 From: Maxime Bombar Date: Sun, 20 May 2018 16:47:59 +0200 Subject: [PATCH] [settings.py] Settings de note-galois --- settings.py | 320 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 320 insertions(+) create mode 100644 settings.py diff --git a/settings.py b/settings.py new file mode 100644 index 0000000..4b3b97c --- /dev/null +++ b/settings.py @@ -0,0 +1,320 @@ +#!/usr/bin/env python +# -*- encoding: utf-8 -*- +# Django settings for Django_Client project. + +import socket +import platform +import os.path + +DEV = True + +# Sur quel système la note tourne-t-elle ? +SYSTEM, NODE_NAME, KERNEL, KERNEL_VERSION, _, _ = platform.uname() + +if SYSTEM == 'Linux': + DISTRIBUTION, DIST_VERSION, _ = platform.linux_distribution() +else: + DISTRIBUTION, DIST_VERSION = None, None + +#: Charset par défaut +DEFAULT_CHARSET = "utf-8" +#: Mode de debug +DEBUG = True +#: Debug aussi quand on plante dans le rendering d'un template +TEMPLATE_DEBUG = DEBUG + + +#: Adresse mail à qui envoyer des problèmes durant l'exécution +REPORT_BUGS_EMAIL = 'notekfet2015@crans.org' + +#: Liste des administrateurs et de leur mails +ADMINS = ( + ('Report bugs to', REPORT_BUGS_EMAIL) +) + +#: Url racine +NOTE_ROOT_URL = r'/note/' +#: Url de la page de login +NOTE_LOGIN_URL = NOTE_ROOT_URL + +#: Chemin absolu du répertoire racine du client django +#: (Le ``os.path.join`` est là pour assurer la présence du trailing slash) +ROOT_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), "") +print ROOT_PATH + +#: From des messages d'erreur +SERVER_EMAIL = "notekfet2015@crans.org" +#: A tuple in the same format as ADMINS that specifies who should get broken link notifications when BrokenLinkEmailsMiddleware is enabled. +MANAGERS = ADMINS + +#: Base de données pour stocker les data django. +#: Dans le cas de la NoteKfet2015, elle n'est utilisé que pour stocker les sessions +#: puisque tout est fait dans le backend. +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. + 'NAME': 'django_client', # Or path to database file if using sqlite3. + 'USER': 'note', # Not used with sqlite3. + 'PASSWORD': '', # Not used with sqlite3. + 'HOST': '', # Set to empty string for localhost. Not used with sqlite3. + 'PORT': '', # Set to empty string for default. Not used with sqlite3. + } +} + +#: Local time zone for this installation. Choices can be found here: +#: http://en.wikipedia.org/wiki/List_of_tz_zones_by_name +#: although not all choices may be available on all operating systems. +#: On Unix systems, a value of None will cause Django to use the same +#: timezone as the operating system. +#: If running in a Windows environment this must be set to the same as your +#: system time zone. +TIME_ZONE = 'Europe/Paris' + +#: Language code for this installation. All choices can be found here: +#: http://www.i18nguy.com/unicode/language-identifiers.html +LANGUAGE_CODE = 'fr-FR' + +#: The ID, as an integer, of the current site in the django_site database table. +#: This is used so that application data can hook into specific sites +#: and a single database can manage content for multiple sites. +SITE_ID = 1 + +#: If you set this to False, Django will make some optimizations so as not +#: to load the internationalization machinery. +USE_I18N = True + +#: If you set this to False, Django will not format dates, numbers and +#: calendars according to the current locale. +USE_L10N = True + +#: If you set this to False, Django will not use timezone-aware datetimes. +USE_TZ = True + +#: Absolute filesystem path to the directory that will hold user-uploaded files. +#: Example: "/home/media/media.lawrence.com/media/" +MEDIA_ROOT = ROOT_PATH + 'media/' + +#: URL that handles the media served from MEDIA_ROOT. Make sure to use a +#: trailing slash. +#: Examples: "http://media.lawrence.com/media/", "http://example.com/media/" +MEDIA_URL = NOTE_ROOT_URL + 'media/' + +#: Absolute path to the directory static files should be collected to. +#: Don't put anything in this directory yourself; store your static files +#: in apps' "static/" subdirectories and in STATICFILES_DIRS. +#: Example: "/home/media/media.lawrence.com/static/" +#STATIC_ROOT = ROOT_PATH + 'static/' + +#: URL prefix for static files. +#: Example: "http://media.lawrence.com/static/" +STATIC_URL = '/static/' + +#: Additional locations of static files +STATICFILES_DIRS = ( + ROOT_PATH + "static/", + # Put strings here, like "/home/html/static" or "C:/www/django/static". + # Always use forward slashes, even on Windows. + # Don't forget to use absolute paths, not relative paths. +) + +#: List of finder classes that know how to find static files in +#: various locations. +STATICFILES_FINDERS = ( + 'django.contrib.staticfiles.finders.FileSystemFinder', + 'django.contrib.staticfiles.finders.AppDirectoriesFinder', +# 'django.contrib.staticfiles.finders.DefaultStorageFinder', +) + +from secrets import SECRET_KEY + +#: List of callables that know how to import templates from various sources. +TEMPLATE_LOADERS = ( + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader', +# 'django.template.loaders.eggs.Loader', +) + +#: A tuple of callables that are used to populate the context in RequestContext. +#: These callables take a request object as their argument +#: and return a dictionary of items to be merged into the context. +TEMPLATE_CONTEXT_PROCESSORS = ( + "django.contrib.auth.context_processors.auth", + "django.core.context_processors.debug", + "django.core.context_processors.i18n", + "django.core.context_processors.media", + "django.core.context_processors.static", + "django.core.context_processors.request", + "django.contrib.messages.context_processors.messages" + ) + +#: A tuple of middleware classes to use. See `Middleware `_. +MIDDLEWARE_CLASSES = ( + 'django.middleware.common.CommonMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + # Uncomment the next line for simple clickjacking protection: + # 'django.middleware.clickjacking.XFrameOptionsMiddleware', +) + +#: A string representing the full Python import path to your root URLconf. +#: For example: "mydjangoapps.urls". +#: Can be overridden on a per-request basis by setting the attribute +#: urlconf on the incoming HttpRequest object. +ROOT_URLCONF = 'urls' + +#: Python dotted path to the WSGI application used by Django's runserver. +WSGI_APPLICATION = 'wsgi.application' + +#: List of locations of the template source files searched by django.template.loaders.filesystem.Loader, in search order. +TEMPLATE_DIRS = ( + ROOT_PATH + "templates/", + # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". + # Always use forward slashes, even on Windows. + # Don't forget to use absolute paths, not relative paths. +) + +#: A tuple of strings designating all applications that are enabled in this Django installation. +#: Each string should be a full Python path to a Python package that contains a Django application, +#: as created by ``django-admin.py startapp``. +INSTALLED_APPS = ( + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.sites', + 'django.contrib.messages', + 'django.contrib.staticfiles', + # Uncomment the next line to enable the admin: + 'django.contrib.admin', + # Uncomment the next line to enable admin documentation: + # 'django.contrib.admindocs', + 'note', +) + +#: A sample logging configuration. The only tangible logging +#: performed by this configuration is to send an email to +#: the site admins on every HTTP 500 error when DEBUG=False. +#: See http://docs.djangoproject.com/en/dev/topics/logging for +#: more details on how to customize your logging configuration. +LOGGING = { + 'version': 1, + 'disable_existing_loggers': False, + 'filters': { + 'require_debug_false': { + '()': 'django.utils.log.RequireDebugFalse' + } + }, + 'handlers': { + 'mail_admins': { + 'level': 'ERROR', + 'filters': ['require_debug_false'], + 'class': 'django.utils.log.AdminEmailHandler' + } + }, + 'loggers': { + 'django.request': { + 'handlers': ['mail_admins'], + 'level': 'ERROR', + 'propagate': True, + }, + } +} + +#: ttl des cookies Django en secondes +SESSION_COOKIE_AGE = 60*100 # 100 minutes + +### Photos +#: Taille max autorisée pour les photos +MAX_PHOTO_SIZE = 870000 # en bytes (850KB) +#: Dossier où sont stockées les photos temporairement +PHOTOS_PATH = MEDIA_ROOT + "photos/" +#: URL par laquelle on accède aux photos +PHOTOS_URL = MEDIA_URL + "photos/" +#: Temps avant de supprimer un fichier de photo temporaire +#: Pendant cet intervalle de temps, +#: la photo pourra être affichée sans être redemandée au serveur NK2015 +TIME_BEFORE_PHOTO_DELETE=60*5 # secondes + +### Network +#: IP où joindre le serveur NK2015 +NK2015_IP = "127.0.0.1" +#: Port d'écoute du serveur NK2015 +NK2015_PORT = 4242 + +### Paramètres d'affichage +## Dates +#: Format avec lequel les dates arrivent du serveur NK2015 +DATETIME_INPUT_FORMAT = u"%Y-%m-%d %H:%M:%S" +#: Format d'affichage des dates +DATETIME_RENDERING_FORMAT = "Le %d/%m/%Y à %H:%M:%S" # C'est volontaire si ce n'est pas une chaîne unicode ! +#: Année jusqu'à laquelle les dates sont en 20nn +YEAR_1900s_OVER = 69 + +## Messages d'erreur +ERRMSG_NK2015_DOWN = u"Le Serveur NK2015 est down." +ERRMSG_NK2015_NOT_RESPONDING = u"La connexion avec le serveur NK2015 ne répond pas. Essaye de te reconnecter." +ERRMSG_HELLO_FAILED = u"La version du site utilisée n'est pas supportée par le serveur NK2015." +ERRMSG_UNKOWNERROR = u"Une fucking erreur inconnue s'est produite :" + +ERRMSG_IDBDE_INVALID = u'''"%s" n'est pas un identifiant de compte valide.''' +ERRMSG_IDBDE_FAIL = u"Le compte n°%s n'existe pas." +ERRMSG_IDACT_INVALID = u'''"%s" n'est pas un identifiant d'activité valide.''' +ERRMSG_IDACT_FAIL = u"L'activité n°%s n'existe pas." +ERRMSG_IDALIAS_INVALID = u'''"%s" n'est pas un identifiant d'alias valide.''' +ERRMSG_IDINV_INVALID = u'''"%s" n'est pas un identifiant d'invité valide.''' +ERRMSG_IDINV_FAIL = u"L'invité n°%s n'existe pas." +ERRMSG_IDBUTTON_INVALID = u'''"%s" n'est pas un identifiant de bouton valide.''' +ERRMSG_IDBUTTON_FAIL = u"Le bouton n°%s n'existe pas." +ERRMSG_PREID_INVALID = u'''"%s" n'est pas un identifiant de préinscription valide.''' +ERRMSG_PREID_FAIL = u"La préinscription n°%s n'existe pas." +ERRMSG_IDTRANSACTION_INVALID = u'''"%s" n'est pas un identifiant de transaction valide.''' +ERRMSG_IDTRANSACTION_FAIL = u"La transaction n°%s n'existe pas." + + +ERRMSG_DJANGO_SESSION_EXPIRED = u"Ta session Django a expiré, reconnecte-toi." +ERRMSG_NOSOCKET = u"La connexion avec le serveur NK2015 a été perdue, reconnecte-toi." +ERRMSG_NK2015_SESSION_EXPIRED = u"Ta session NK2015 est invalide ou a expiré, reconnecte-toi." + +ERRMSG_PASSWORD_NEGATIVE_IDBDE = u"Mais oui bien sûr…" +ERRMSG_NO_ACL_CHGPASS = u"Tu n'as pas le droit de changer le mot de passe d'un autre compte que le tien." + +## Messages de succès +SUCCMSG_CHGACT = u"Activité modifiée avec succès." +SUCCMSG_DELACT = u"Activité supprimée avec succès." +SUCCMSG_ADDACT = u"Activité ajoutée avec succès." +SUCCMSG_VALIDACT = u"Activité validée avec succès." +SUCCMSG_DEVALIDACT = u"Activité dévalidée avec succès." +SUCCMSG_DELINV = u"Invité supprimé avec succès." +SUCCMSG_ADDINV = u"Invité ajouté avec succès." +SUCCMSG_ACCOUNT_CHANGED = u"Compte modifié avec succès." +SUCCMSG_ACCOUNT_ADDED = u"Compte ajouté avec succès." +SUCCMSG_ACCOUNT_DELETED = u"Compte supprimé avec succès." +SUCCMSG_ALIAS_ADDED = u"Alias ajouté avec succès." +SUCCMSG_ALIAS_DELETED = u"Alias supprimé avec succès." +SUCCMSG_ALIAS_ALLDELETED = u"Tous les alias supprimés avec succès." +SUCCMSG_PASSWORD_CHANGED = u"Mot de passe modifié avec succès." +SUCCMSG_LOGOUT = u"Tu t'es déconnecté." +SUCCMSG_ADDBUTTON = u"Bouton ajouté avec succès." +SUCCMSG_CHGBUTTON = u"Bouton modifié avec succès." +SUCCMSG_DELBUTTON = u"Bouton supprimé avec succès." +SUCCMSG_PREINSCRIPTION_ADDED = u"Préinscription ajoutée avec succès." +SUCCMSG_PREINSCRIPTION_DELETED = u"Préinscription supprimée avec succès." +SUCCMSG_READHESION = u"Réadhésion effectuée avec succès." +SUCCMSG_PHOTO_UPDATED = u"Photo modifiée avec succès." +SUCCMSG_VALIDATE_TRANSACTION = u"Transaction validée avec succès." +SUCCMSG_DEVALIDATE_TRANSACTION = u"Transaction dévalidée avec succès." +SUCCMSG_RESETPSWD = u"Un mail vous a été envoyé." + +### Masques de droits +#: Droits qu'on n'a pas en se connectant en "restricted" +_acl_restricted = ["myself", "wei", "overforced", "transactions_admin", "chgpass", "comptes", "boutons", "admin", "digicode"] + +#: Dico recensant les masques de droits : ``keyword`` -> ``("nom à afficher", )`` +#: ils seront proposés dans l'ordre des keywords +ACL_MASKS = { + '0_all': (u"Tous mes droits", [[], [], False]), + '1_note': (u"Droits note seulement", [_acl_restricted, _acl_restricted, True]), + } +_acl_masks_keys = ACL_MASKS.keys() +_acl_masks_keys.sort() -- GitLab