<gh_stars>0
"""
Django settings for students_performance_monitoring project.

Generated by 'django-admin startproject' using Django 2.2.7.

For more information on this file, see
https://docs.djangoproject.com/en/2.2/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.2/ref/settings/
"""

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.getenv('SP_DJANGO_SECRET_KEY')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = [
    '127.0.0.1',
    'encrypted-fox.ru',
    'students-monitor.herokuapp.com',
]

CORS_ORIGIN_ALLOW_ALL = True

CORS_ORIGIN_WHITELIST = [
    'http://127.0.0.1',
    'http://172.16.17.32',
    'http://encrypted-fox.ru',
    'https://students-monitor.herokuapp.com',
]

CSRF_TRUSTED_ORIGINS = [
    '127.0.0.1',
    '172.16.17.32',
    'encrypted-fox.ru',
    'students-monitor.herokuapp.com',
]

CORS_ALLOW_METHODS = [
    'DELETE',
    'GET',
    'OPTIONS',
    'PATCH',
    'POST',
    'PUT',
]

CORS_ALLOW_HEADERS = [
    'accept',
    'accept-encoding',
    'authorization',
    'content-type',
    'dnt',
    'origin',
    'user-agent',
    'x-csrftoken',
    'x-requested-with',
]

# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django_filters',
    'oauth2_provider',
    'rest_framework',
    'drf_yasg',
    'corsheaders',
    'subjects',
    'information',
    'people',
    'university_structure',
    'users',
    'django_extensions',
    'documents'
]

MIDDLEWARE = [
    'whitenoise.middleware.WhiteNoiseMiddleware',
    'corsheaders.middleware.CorsMiddleware',
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'oauth2_provider.middleware.OAuth2TokenMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'students_performance_monitoring.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(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 = 'students_performance_monitoring.wsgi.application'

# Database (!!!!!!!!LOCALHOST_DEFAULTS)!!!!!!!!)
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': os.getenv('SP_POSTGRESQL_DATABASE_NAME'),
        'USER': os.getenv('SP_POSTGRESQL_DATABASE_USER'),
        'PASSWORD': os.getenv('SP_POSTGRESQL_DATABASE_PASSWORD'),
        'HOST': os.getenv('SP_POSTGRESQL_DATABASE_HOST'),
        'PORT': os.getenv('SP_POSTGRESQL_DATABASE_PORT'),
    }
}

# DATABASES = {
#     'default': {
#         'ENGINE': 'django.db.backends.mysql',
#         'NAME': os.getenv('SP_MYSQL_DATABASE_NAME'),
#         'USER': os.getenv('SP_MYSQL_DATABASE_USER'),
#         'PASSWORD': os.getenv('SP_MYSQL_DATABASE_PASSWORD'),
#         'HOST': os.getenv('SP_MYSQL_DATABASE_HOST'),
#         'PORT': os.getenv('SP_MYSQL_DATABASE_PORT'),
#     }
# }

# DATABASES = {
#     'default': {
#         'ENGINE': 'django.db.backends.sqlite3',
#         'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
#     }
# }

# Rest Framework
# https://www.django-rest-framework.org/

OAUTH2_PROVIDER = {
    'SCOPES': {
        'read': 'Read scope',
        'write': 'Write scope',
        'groups': 'Access to your groups'
    },
}

AUTHENTICATION_BACKENDS = (
    'django.contrib.auth.backends.ModelBackend',
    'oauth2_provider.backends.OAuth2Backend',
)

AUTH_USER_MODEL = 'users.CustomUser'

REST_FRAMEWORK = {
    'DEFAULT_PERMISSION_CLASSES': (
        'rest_framework.permissions.AllowAny',
    ),
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'oauth2_provider.contrib.rest_framework.OAuth2Authentication',
        'rest_framework.authentication.SessionAuthentication',
    ),
    'DEFAULT_FILTER_BACKENDS': ['django_filters.rest_framework.DjangoFilterBackend'],
    'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
    'PAGE_SIZE': 20,
}

SWAGGER_SETTINGS = {
    'USE_SESSION_AUTH': False,
    'SECURITY_DEFINITIONS': {
        'swagger': {
            'type': 'oauth2',
            'authorizationUrl': '/api/v0/o/authorize/',
            'tokenUrl': '/api/v0/o/token/',
            'flow': 'app',
        }
    },
    'OAUTH2_CONFIG': {
        'clientId': os.getenv('SP_OAUTH2_CLIENT_ID'),
        'clientSecret': os.getenv('SP_OAUTH2_CLIENT_SECRET'),
        'appName': 'swagger'
    },
}

# Password validation
# https://docs.djangoproject.com/en/2.2/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/2.2/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

# Static files (CSS, JavaScript, Images)/
# https://docs.djangoproject.com/en/2.2/howto/static-files/

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

"""
Django settings for students_performance_monitoring project.

Generated by 'django-admin startproject' using Django 2.2.7.

For more information on this file, see
https://docs.djangoproject.com/en/2.2/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.2/ref/settings/
"""

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.getenv('SP_DJANGO_SECRET_KEY')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = [
    '127.0.0.1',
    'encrypted-fox.ru',
    'students-monitor.herokuapp.com',
]

CORS_ORIGIN_ALLOW_ALL = True

CORS_ORIGIN_WHITELIST = [
    'http://127.0.0.1',
    'http://172.16.17.32',
    'http://encrypted-fox.ru',
    'https://students-monitor.herokuapp.com',
]

CSRF_TRUSTED_ORIGINS = [
    '127.0.0.1',
    '172.16.17.32',
    'encrypted-fox.ru',
    'students-monitor.herokuapp.com',
]

CORS_ALLOW_METHODS = [
    'DELETE',
    'GET',
    'OPTIONS',
    'PATCH',
    'POST',
    'PUT',
]

CORS_ALLOW_HEADERS = [
    'accept',
    'accept-encoding',
    'authorization',
    'content-type',
    'dnt',
    'origin',
    'user-agent',
    'x-csrftoken',
    'x-requested-with',
]

# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django_filters',
    'oauth2_provider',
    'rest_framework',
    'drf_yasg',
    'corsheaders',
    'subjects',
    'information',
    'people',
    'university_structure',
    'users',
    'django_extensions',
    'documents'
]

MIDDLEWARE = [
    'whitenoise.middleware.WhiteNoiseMiddleware',
    'corsheaders.middleware.CorsMiddleware',
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'oauth2_provider.middleware.OAuth2TokenMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'students_performance_monitoring.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(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 = 'students_performance_monitoring.wsgi.application'

# Database (!!!!!!!!LOCALHOST_DEFAULTS)!!!!!!!!)
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': os.getenv('SP_POSTGRESQL_DATABASE_NAME'),
        'USER': os.getenv('SP_POSTGRESQL_DATABASE_USER'),
        'PASSWORD': os.getenv('SP_POSTGRESQL_DATABASE_PASSWORD'),
        'HOST': os.getenv('SP_POSTGRESQL_DATABASE_HOST'),
        'PORT': os.getenv('SP_POSTGRESQL_DATABASE_PORT'),
    }
}

# DATABASES = {
#     'default': {
#         'ENGINE': 'django.db.backends.mysql',
#         'NAME': os.getenv('SP_MYSQL_DATABASE_NAME'),
#         'USER': os.getenv('SP_MYSQL_DATABASE_USER'),
#         'PASSWORD': os.getenv('SP_MYSQL_DATABASE_PASSWORD'),
#         'HOST': os.getenv('SP_MYSQL_DATABASE_HOST'),
#         'PORT': os.getenv('SP_MYSQL_DATABASE_PORT'),
#     }
# }

# DATABASES = {
#     'default': {
#         'ENGINE': 'django.db.backends.sqlite3',
#         'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
#     }
# }

# Rest Framework
# https://www.django-rest-framework.org/

OAUTH2_PROVIDER = {
    'SCOPES': {
        'read': 'Read scope',
        'write': 'Write scope',
        'groups': 'Access to your groups'
    },
}

AUTHENTICATION_BACKENDS = (
    'django.contrib.auth.backends.ModelBackend',
    'oauth2_provider.backends.OAuth2Backend',
)

AUTH_USER_MODEL = 'users.CustomUser'

REST_FRAMEWORK = {
    'DEFAULT_PERMISSION_CLASSES': (
        'rest_framework.permissions.AllowAny',
    ),
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'oauth2_provider.contrib.rest_framework.OAuth2Authentication',
        'rest_framework.authentication.SessionAuthentication',
    ),
    'DEFAULT_FILTER_BACKENDS': ['django_filters.rest_framework.DjangoFilterBackend'],
    'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
    'PAGE_SIZE': 20,
}

SWAGGER_SETTINGS = {
    'USE_SESSION_AUTH': False,
    'SECURITY_DEFINITIONS': {
        'swagger': {
            'type': 'oauth2',
            'authorizationUrl': '/api/v0/o/authorize/',
            'tokenUrl': '/api/v0/o/token/',
            'flow': 'app',
        }
    },
    'OAUTH2_CONFIG': {
        'clientId': os.getenv('SP_OAUTH2_CLIENT_ID'),
        'clientSecret': os.getenv('SP_OAUTH2_CLIENT_SECRET'),
        'appName': 'swagger'
    },
}

# Password validation
# https://docs.djangoproject.com/en/2.2/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/2.2/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

# Static files (CSS, JavaScript, Images)/
# https://docs.djangoproject.com/en/2.2/howto/static-files/

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
Django settings for students_performance_monitoring project.  Generated by 'django-admin startproject' using Django 2.2.7.  For more information on this file, see https://docs.djangoproject.com/en/2.2/topics/settings/  For the full list of settings and their values, see https://docs.djangoproject.com/en/2.2/ref/settings/ # Build paths inside the project like this: os.path.join(BASE_DIR, ...) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! # SECURITY WARNING: don't run with debug turned on in production! # Application definition # Database (!!!!!!!!LOCALHOST_DEFAULTS)!!!!!!!!) # https://docs.djangoproject.com/en/2.2/ref/settings/#databases # DATABASES = { #     'default': { #         'ENGINE': 'django.db.backends.mysql', #         'NAME': os.getenv('SP_MYSQL_DATABASE_NAME'), #         'USER': os.getenv('SP_MYSQL_DATABASE_USER'), #         'PASSWORD': os.getenv('SP_MYSQL_DATABASE_PASSWORD'), #         'HOST': os.getenv('SP_MYSQL_DATABASE_HOST'), #         'PORT': os.getenv('SP_MYSQL_DATABASE_PORT'), #     } # } # DATABASES = { #     'default': { #         'ENGINE': 'django.db.backends.sqlite3', #         'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), #     } # } # Rest Framework # https://www.django-rest-framework.org/ # Password validation # https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators # Internationalization # https://docs.djangoproject.com/en/2.2/topics/i18n/ # Static files (CSS, JavaScript, Images)/ # https://docs.djangoproject.com/en/2.2/howto/static-files/