mirror of
https://github.com/Rushilwiz/global.git
synced 2025-04-09 15:00:16 -04:00
142 lines
3.6 KiB
Python
142 lines
3.6 KiB
Python
from pathlib import Path
|
|
from django.urls import reverse_lazy
|
|
|
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
|
|
|
|
|
# Quick-start development settings - unsuitable for production
|
|
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/
|
|
|
|
|
|
# Application definition
|
|
|
|
INSTALLED_APPS = [
|
|
'social_django',
|
|
'global.apps.base',
|
|
|
|
'django.contrib.admin',
|
|
'django.contrib.auth',
|
|
'django.contrib.contenttypes',
|
|
'django.contrib.sessions',
|
|
'django.contrib.messages',
|
|
'django.contrib.staticfiles',
|
|
]
|
|
|
|
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',
|
|
]
|
|
|
|
ROOT_URLCONF = 'global.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',
|
|
],
|
|
},
|
|
},
|
|
]
|
|
|
|
WSGI_APPLICATION = 'global.wsgi.application'
|
|
|
|
|
|
# Password validation
|
|
# https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators
|
|
|
|
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',
|
|
},
|
|
]
|
|
|
|
|
|
# Internationalization
|
|
# https://docs.djangoproject.com/en/4.1/topics/i18n/
|
|
|
|
LANGUAGE_CODE = 'en-us'
|
|
|
|
TIME_ZONE = 'UTC'
|
|
|
|
USE_I18N = True
|
|
|
|
USE_TZ = True
|
|
|
|
|
|
# Static files (CSS, JavaScript, Images)
|
|
# https://docs.djangoproject.com/en/4.1/howto/static-files/
|
|
|
|
STATIC_ROOT = BASE_DIR / 'serve/'
|
|
|
|
STATIC_URL = '/static/'
|
|
|
|
STATICFILES_DIRS = (
|
|
BASE_DIR / 'static/',
|
|
)
|
|
|
|
MEDIA_ROOT = BASE_DIR / 'media/'
|
|
|
|
MEDIA_URL = '/media/'
|
|
|
|
# Default primary key field type
|
|
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
|
|
|
|
AUTH_USER_MODEL = 'base.User'
|
|
AUTHENTICATION_BACKENDS = ['global.apps.base.oauth.IonOauth2']
|
|
|
|
LOGIN_REDIRECT_URL = reverse_lazy("base:index")
|
|
LOGOUT_REDIRECT_URL = reverse_lazy("base:index")
|
|
LOGIN_URL = reverse_lazy("base:login")
|
|
|
|
SOCIAL_AUTH_ALWAYS_ASSOCIATE = True
|
|
|
|
SOCIAL_AUTH_PIPELINE = (
|
|
"social_core.pipeline.social_auth.social_details",
|
|
"social_core.pipeline.social_auth.social_uid",
|
|
"social_core.pipeline.social_auth.auth_allowed",
|
|
"social_core.pipeline.social_auth.social_user",
|
|
"social_core.pipeline.social_auth.associate_by_email",
|
|
"social_core.pipeline.user.create_user",
|
|
"social_core.pipeline.social_auth.associate_user",
|
|
"social_core.pipeline.social_auth.load_extra_data",
|
|
)
|
|
|
|
SOCIAL_AUTH_URL_NAMESPACE = "social"
|
|
|
|
SOCIAL_AUTH_USER_FIELDS = [
|
|
"first_name",
|
|
"graduation_year",
|
|
"id",
|
|
"is_staff",
|
|
"is_superuser",
|
|
"last_name",
|
|
"username",
|
|
]
|
|
|
|
from datetime import date
|
|
from dateutil.relativedelta import relativedelta
|
|
|
|
CURRENT_YEAR = (date.today() - relativedelta(months=7)).year
|
|
|
|
from .secret import * |