mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-06-21 01:48:21 +02:00
Merge branch 'consos' into rights
# Conflicts: # apps/logs/signals.py # note_kfet/settings/base.py
This commit is contained in:
@ -1,8 +1,12 @@
|
||||
import os
|
||||
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
import re
|
||||
|
||||
from .base import *
|
||||
|
||||
|
||||
def read_env():
|
||||
"""Pulled from Honcho code with minor updates, reads local default
|
||||
environment variables from a .env file located in the project root
|
||||
@ -25,22 +29,53 @@ def read_env():
|
||||
val = re.sub(r'\\(.)', r'\1', m3.group(1))
|
||||
os.environ.setdefault(key, val)
|
||||
|
||||
|
||||
read_env()
|
||||
|
||||
app_stage = os.environ.get('DJANGO_APP_STAGE', 'dev')
|
||||
if app_stage == 'prod':
|
||||
from .production import *
|
||||
DATABASES["default"]["PASSWORD"] = os.environ.get('DJANGO_DB_PASSWORD','CHANGE_ME_IN_ENV_SETTINGS')
|
||||
SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY','CHANGE_ME_IN_ENV_SETTINGS')
|
||||
ALLOWED_HOSTS.append(os.environ.get('ALLOWED_HOSTS','localhost'))
|
||||
else:
|
||||
from .development import *
|
||||
|
||||
try:
|
||||
#in secrets.py defines everything you want
|
||||
from .secrets import *
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
# env variables set at the of in /env/bin/activate
|
||||
# don't forget to unset in deactivate !
|
||||
if "cas" in INSTALLED_APPS:
|
||||
MIDDLEWARE += ['cas.middleware.CASMiddleware']
|
||||
# CAS Settings
|
||||
CAS_SERVER_URL = "https://" + os.getenv("NOTE_URL", "note.example.com") + "/cas/"
|
||||
CAS_AUTO_CREATE_USER = False
|
||||
CAS_LOGO_URL = "/static/img/Saperlistpopette.png"
|
||||
CAS_FAVICON_URL = "/static/favicon/favicon-32x32.png"
|
||||
CAS_SHOW_SERVICE_MESSAGES = True
|
||||
CAS_SHOW_POWERED = False
|
||||
CAS_REDIRECT_TO_LOGIN_AFTER_LOGOUT = False
|
||||
CAS_PROVIDE_URL_TO_LOGOUT = True
|
||||
CAS_INFO_MESSAGES = {
|
||||
"cas_explained": {
|
||||
"message": _(
|
||||
u"The Central Authentication Service grants you access to most of our websites by "
|
||||
u"authenticating only once, so you don't need to type your credentials again unless "
|
||||
u"your session expires or you logout."
|
||||
),
|
||||
"discardable": True,
|
||||
"type": "info", # one of info, success, info, warning, danger
|
||||
},
|
||||
}
|
||||
|
||||
CAS_INFO_MESSAGES_ORDER = [
|
||||
'cas_explained',
|
||||
]
|
||||
AUTHENTICATION_BACKENDS += ('cas.backends.CASBackend',)
|
||||
|
||||
|
||||
if "logs" in INSTALLED_APPS:
|
||||
MIDDLEWARE += ('logs.middlewares.LogsMiddleware',)
|
||||
|
||||
if "debug_toolbar" in INSTALLED_APPS:
|
||||
MIDDLEWARE.insert(1, "debug_toolbar.middleware.DebugToolbarMiddleware")
|
||||
INTERNAL_IPS = ['127.0.0.1']
|
||||
|
@ -37,9 +37,10 @@ INSTALLED_APPS = [
|
||||
|
||||
# External apps
|
||||
'polymorphic',
|
||||
'reversion',
|
||||
'crispy_forms',
|
||||
'django_tables2',
|
||||
'cas_server',
|
||||
'cas',
|
||||
# Django contrib
|
||||
'django.contrib.admin',
|
||||
'django.contrib.admindocs',
|
||||
@ -55,9 +56,6 @@ INSTALLED_APPS = [
|
||||
# Autocomplete
|
||||
'dal',
|
||||
'dal_select2',
|
||||
# CAS
|
||||
'cas_server',
|
||||
'cas',
|
||||
|
||||
# Note apps
|
||||
'activity',
|
||||
@ -81,7 +79,6 @@ MIDDLEWARE = [
|
||||
'django.middleware.locale.LocaleMiddleware',
|
||||
'django.contrib.sites.middleware.CurrentSiteMiddleware',
|
||||
'note_kfet.middlewares.TurbolinksMiddleware',
|
||||
'cas.middleware.CASMiddleware',
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'note_kfet.urls'
|
||||
@ -98,7 +95,7 @@ TEMPLATES = [
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
'django.template.context_processors.request',
|
||||
# 'django.template.context_processors.media',
|
||||
# 'django.template.context_processors.media',
|
||||
],
|
||||
},
|
||||
},
|
||||
@ -133,7 +130,7 @@ PASSWORD_HASHERS = [
|
||||
# Django Guardian object permissions
|
||||
|
||||
AUTHENTICATION_BACKENDS = (
|
||||
#'django.contrib.auth.backends.ModelBackend', # this is default
|
||||
# 'django.contrib.auth.backends.ModelBackend', # this is default
|
||||
'member.backends.PermissionBackend',
|
||||
'cas.backends.CASBackend',
|
||||
)
|
||||
@ -146,12 +143,13 @@ REST_FRAMEWORK = {
|
||||
'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
|
||||
],
|
||||
'DEFAULT_AUTHENTICATION_CLASSES': [
|
||||
'rest_framework.authentication.SessionAuthentication',
|
||||
'rest_framework.authentication.TokenAuthentication',
|
||||
]
|
||||
],
|
||||
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
|
||||
'PAGE_SIZE': 20,
|
||||
}
|
||||
|
||||
ANONYMOUS_USER_NAME = None # Disable guardian anonymous user
|
||||
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/2.2/topics/i18n/
|
||||
|
||||
@ -182,7 +180,7 @@ FIXTURE_DIRS = [os.path.join(BASE_DIR, "note_kfet/fixtures")]
|
||||
# Don't put anything in this directory yourself; store your static files
|
||||
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
|
||||
# Example: "/var/www/example.com/static/"
|
||||
STATIC_ROOT = os.path.join(BASE_DIR,"static/")
|
||||
STATIC_ROOT = os.path.join(BASE_DIR, "static/")
|
||||
# STATICFILES_DIRS = [
|
||||
# os.path.join(BASE_DIR, 'static')]
|
||||
STATICFILES_DIRS = []
|
||||
@ -194,15 +192,9 @@ STATIC_URL = '/static/'
|
||||
|
||||
ALIAS_VALIDATOR_REGEX = r''
|
||||
|
||||
MEDIA_ROOT=os.path.join(BASE_DIR,"media")
|
||||
MEDIA_URL='/media/'
|
||||
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
|
||||
MEDIA_URL = '/media/'
|
||||
|
||||
# Profile Picture Settings
|
||||
PIC_WIDTH = 200
|
||||
PIC_RATIO = 1
|
||||
|
||||
# CAS Settings
|
||||
CAS_AUTO_CREATE_USER = False
|
||||
CAS_LOGO_URL = "/static/img/Saperlistpopette.png"
|
||||
CAS_FAVICON_URL = "/static/favicon/favicon-32x32.png"
|
||||
|
||||
|
@ -11,17 +11,30 @@
|
||||
# - and more ...
|
||||
|
||||
|
||||
import os
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
|
||||
from . import *
|
||||
import os
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
||||
if os.getenv("DJANGO_DEV_STORE_METHOD", "sqllite") == "postgresql":
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||
'NAME': os.environ.get('DJANGO_DB_NAME', 'note_db'),
|
||||
'USER': os.environ.get('DJANGO_DB_USER', 'note'),
|
||||
'PASSWORD': os.environ.get('DJANGO_DB_PASSWORD', 'CHANGE_ME_IN_ENV_SETTINGS'),
|
||||
'HOST': os.environ.get('DJANGO_DB_HOST', 'localhost'),
|
||||
'PORT': os.environ.get('DJANGO_DB_PORT', ''), # Use default port
|
||||
}
|
||||
}
|
||||
else:
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Break it, fix it!
|
||||
DEBUG = True
|
||||
@ -38,7 +51,7 @@ EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
|
||||
# EMAIL_HOST_USER = 'change_me'
|
||||
# EMAIL_HOST_PASSWORD = 'change_me'
|
||||
|
||||
SERVER_EMAIL = 'no-reply@example.org'
|
||||
SERVER_EMAIL = 'no-reply@' + os.getenv("DOMAIN", "example.com")
|
||||
|
||||
# Security settings
|
||||
SECURE_CONTENT_TYPE_NOSNIFF = False
|
||||
@ -51,4 +64,8 @@ SESSION_COOKIE_AGE = 60 * 60 * 3
|
||||
|
||||
# CAS Client settings
|
||||
# Can be modified in secrets.py
|
||||
CAS_SERVER_URL = "https://note.comby.xyz/cas/"
|
||||
CAS_SERVER_URL = "http://localhost:8000/cas/"
|
||||
|
||||
STATIC_ROOT = '' # not needed in development settings
|
||||
STATICFILES_DIRS = [
|
||||
os.path.join(BASE_DIR, 'static')]
|
||||
|
@ -1,6 +1,8 @@
|
||||
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import os
|
||||
|
||||
########################
|
||||
# Production Settings #
|
||||
########################
|
||||
@ -14,11 +16,11 @@
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||
'NAME': 'note_db',
|
||||
'USER': 'note',
|
||||
'PASSWORD': 'update_in_env_variable',
|
||||
'HOST': '127.0.0.1',
|
||||
'PORT': '',
|
||||
'NAME': os.environ.get('DJANGO_DB_NAME', 'note_db'),
|
||||
'USER': os.environ.get('DJANGO_DB_USER', 'note'),
|
||||
'PASSWORD': os.environ.get('DJANGO_DB_PASSWORD', 'CHANGE_ME_IN_ENV_SETTINGS'),
|
||||
'HOST': os.environ.get('DJANGO_DB_HOST', 'localhost'),
|
||||
'PORT': os.environ.get('DJANGO_DB_PORT', ''), # Use default port
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,7 +28,9 @@ DATABASES = {
|
||||
DEBUG = True
|
||||
|
||||
# Mandatory !
|
||||
ALLOWED_HOSTS = ['127.0.0.1','note.comby.xyz']
|
||||
ALLOWED_HOSTS = [os.environ.get('NOTE_URL', 'localhost')]
|
||||
|
||||
SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY', 'CHANGE_ME_IN_ENV_SETTINGS')
|
||||
|
||||
# Emails
|
||||
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
|
||||
@ -37,7 +41,7 @@ EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
|
||||
# EMAIL_HOST_USER = 'change_me'
|
||||
# EMAIL_HOST_PASSWORD = 'change_me'
|
||||
|
||||
SERVER_EMAIL = 'no-reply@example.org'
|
||||
SERVER_EMAIL = 'no-reply@' + os.getenv("DOMAIN", "example.com")
|
||||
|
||||
# Security settings
|
||||
SECURE_CONTENT_TYPE_NOSNIFF = False
|
||||
@ -49,4 +53,4 @@ X_FRAME_OPTIONS = 'DENY'
|
||||
SESSION_COOKIE_AGE = 60 * 60 * 3
|
||||
|
||||
# CAS Client settings
|
||||
CAS_SERVER_URL = "https://note.crans.org/cas/"
|
||||
CAS_SERVER_URL = "https://" + os.getenv("NOTE_URL", "note.example.com") + "/cas/"
|
||||
|
9
note_kfet/settings/secrets_example.py
Normal file
9
note_kfet/settings/secrets_example.py
Normal file
@ -0,0 +1,9 @@
|
||||
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
# CAS
|
||||
OPTIONAL_APPS = [
|
||||
# 'cas_server',
|
||||
# 'cas',
|
||||
# 'debug_toolbar'
|
||||
]
|
Reference in New Issue
Block a user