"""
Django settings for Bucki project.

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

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

import environ

ROOT_DIR = environ.Path(__file__)-3
APPS_DIR = ROOT_DIR.path('bucki')

env = environ.Env()

DEBUG = env.bool('DJANGO_DEBUG', False)


# Internationalization
# https://docs.djangoproject.com/en/3.2/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
SITE_ID = 1
USE_I18N = True
USE_L10N = True
USE_TZ = True


# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
DATABASES = {
    'default': env.db('DATABASE_URL'),
}
DATABASES['default']['ATOMIC_REQUEST'] = True

# URLs
ROOT_URLCONF = 'config.urls'

# WSGI
WSGI_APPLICATION = 'config.wsgi.application'

# Users
# https://docs.djangoproject.com/en/3.2/topics/auth/customizing/#auth-custom-user
AUTH_USER_MODEL = 'users.User'


# Applications configuration
# https://docs.djangoproject.com/en/3.2/ref/applications/
DJANGO_APPS = [
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.admin',
]
THIRD_PARTY_APPS = [
    'taggit',
    'rest_framework',
    'rest_framework.authtoken',
    'django_filters'
]
LOCAL_APPS = [
    'bucki.users.apps.UsersAppConfig',
    'bucki.buckets.apps.BucketsAppConfig',
]

INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS

# Password hashers
# https://docs.djangoproject.com/en/3.2/topics/auth/passwords/#auth-password-storage
PASSWORD_HASHERS = [
    'django.contrib.auth.hashers.Argon2PasswordHasher',
    'django.contrib.auth.hashers.PBKDF2PasswordHasher',
    'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
    'django.contrib.auth.hashers.BCryptSHA256PasswordHasher',
    'django.contrib.auth.hashers.BCryptPasswordHasher',
]

# Password validation
# https://docs.djangoproject.com/en/3.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',
    },
]

# Middleware
# https://docs.djangoproject.com/en/3.2/topics/http/middleware/
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',
]

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.2/howto/static-files/
STATIC_ROOT = str(ROOT_DIR('staticfiles'))
STATIC_URL = '/static/'

# Static files directories
# https://docs.djangoproject.com/en/3.2/ref/settings/#std:setting-STATICFILES_DIRS
STATICFILES_DIRS = [
    str(APPS_DIR.path('static')),
]

# Static files finders
# https://docs.djangoproject.com/en/3.2/ref/settings/#std:setting-STATICFILES_FINDERS
STATICFILES_FINDERS = [
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
]

# Media root
# https://docs.djangoproject.com/en/3.2/ref/settings/#std:setting-MEDIA_ROOT
MEDIA_ROOT = str(APPS_DIR('media'))

# Media url
# https://docs.djangoproject.com/en/3.2/ref/settings/#std:setting-MEDIA_URL
MEDIA_URL = '/media/'

# Templates
# https://docs.djangoproject.com/en/3.2/ref/templates/
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            str(APPS_DIR.path('templates')),
        ],
        'OPTIONS': {
            'debug': DEBUG,
            'loaders': [
                'django.template.loaders.filesystem.Loader',
                'django.template.loaders.app_directories.Loader',
            ],
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.template.context_processors.i18n',
                'django.template.context_processors.media',
                'django.template.context_processors.static',
                'django.template.context_processors.tz',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

# Security
SESSION_COOKIE_HTTPONLY = True
CSRF_COOKIE_HTTPONLY = True
SECURE_BROWSER_XSS_FILTER = True
X_FRAME_OPTIONS = 'DENY'

# Email
# https://docs.djangoproject.com/en/3.2/topics/email/
EMAIL_BACKEND = env('DJANGO_EMAIL_BACKEND', default='django.core.mail.backends.smtp.EmailBackend')

# Admin
ADMIN_URL = 'admin/'
ADMINS = [
    ("""<NAME>""", '<EMAIL>'),
]
MANAGERS = ADMINS

# Model tags
# https://django-taggit.readthedocs.io/en/latest/
TAGGIT_CASE_INSENSITIVE = True

# Django REST Framework
# https://www.django-rest-framework.org/
REST_FRAMEWORK = {
    'DEFAULT_RENDERER_CLASSES': (
        'rest_framework.renderers.JSONRenderer',
    ),
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework.authentication.TokenAuthentication',
    ),
    'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
    'PAGE_SIZE': 10,
}

# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

"""
Django settings for Bucki project.

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

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

import environ

ROOT_DIR = environ.Path(__file__)-3
APPS_DIR = ROOT_DIR.path('bucki')

env = environ.Env()

DEBUG = env.bool('DJANGO_DEBUG', False)


# Internationalization
# https://docs.djangoproject.com/en/3.2/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
SITE_ID = 1
USE_I18N = True
USE_L10N = True
USE_TZ = True


# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
DATABASES = {
    'default': env.db('DATABASE_URL'),
}
DATABASES['default']['ATOMIC_REQUEST'] = True

# URLs
ROOT_URLCONF = 'config.urls'

# WSGI
WSGI_APPLICATION = 'config.wsgi.application'

# Users
# https://docs.djangoproject.com/en/3.2/topics/auth/customizing/#auth-custom-user
AUTH_USER_MODEL = 'users.User'


# Applications configuration
# https://docs.djangoproject.com/en/3.2/ref/applications/
DJANGO_APPS = [
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.admin',
]
THIRD_PARTY_APPS = [
    'taggit',
    'rest_framework',
    'rest_framework.authtoken',
    'django_filters'
]
LOCAL_APPS = [
    'bucki.users.apps.UsersAppConfig',
    'bucki.buckets.apps.BucketsAppConfig',
]

INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS

# Password hashers
# https://docs.djangoproject.com/en/3.2/topics/auth/passwords/#auth-password-storage
PASSWORD_HASHERS = [
    'django.contrib.auth.hashers.Argon2PasswordHasher',
    'django.contrib.auth.hashers.PBKDF2PasswordHasher',
    'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
    'django.contrib.auth.hashers.BCryptSHA256PasswordHasher',
    'django.contrib.auth.hashers.BCryptPasswordHasher',
]

# Password validation
# https://docs.djangoproject.com/en/3.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',
    },
]

# Middleware
# https://docs.djangoproject.com/en/3.2/topics/http/middleware/
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',
]

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.2/howto/static-files/
STATIC_ROOT = str(ROOT_DIR('staticfiles'))
STATIC_URL = '/static/'

# Static files directories
# https://docs.djangoproject.com/en/3.2/ref/settings/#std:setting-STATICFILES_DIRS
STATICFILES_DIRS = [
    str(APPS_DIR.path('static')),
]

# Static files finders
# https://docs.djangoproject.com/en/3.2/ref/settings/#std:setting-STATICFILES_FINDERS
STATICFILES_FINDERS = [
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
]

# Media root
# https://docs.djangoproject.com/en/3.2/ref/settings/#std:setting-MEDIA_ROOT
MEDIA_ROOT = str(APPS_DIR('media'))

# Media url
# https://docs.djangoproject.com/en/3.2/ref/settings/#std:setting-MEDIA_URL
MEDIA_URL = '/media/'

# Templates
# https://docs.djangoproject.com/en/3.2/ref/templates/
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            str(APPS_DIR.path('templates')),
        ],
        'OPTIONS': {
            'debug': DEBUG,
            'loaders': [
                'django.template.loaders.filesystem.Loader',
                'django.template.loaders.app_directories.Loader',
            ],
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.template.context_processors.i18n',
                'django.template.context_processors.media',
                'django.template.context_processors.static',
                'django.template.context_processors.tz',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

# Security
SESSION_COOKIE_HTTPONLY = True
CSRF_COOKIE_HTTPONLY = True
SECURE_BROWSER_XSS_FILTER = True
X_FRAME_OPTIONS = 'DENY'

# Email
# https://docs.djangoproject.com/en/3.2/topics/email/
EMAIL_BACKEND = env('DJANGO_EMAIL_BACKEND', default='django.core.mail.backends.smtp.EmailBackend')

# Admin
ADMIN_URL = 'admin/'
ADMINS = [
    ("""<NAME>""", '<EMAIL>'),
]
MANAGERS = ADMINS

# Model tags
# https://django-taggit.readthedocs.io/en/latest/
TAGGIT_CASE_INSENSITIVE = True

# Django REST Framework
# https://www.django-rest-framework.org/
REST_FRAMEWORK = {
    'DEFAULT_RENDERER_CLASSES': (
        'rest_framework.renderers.JSONRenderer',
    ),
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework.authentication.TokenAuthentication',
    ),
    'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
    'PAGE_SIZE': 10,
}

# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

Django settings for Bucki project.  For more information on this file, see https://docs.djangoproject.com/en/3.2/topics/settings/  For the full list of settings and their values, see https://docs.djangoproject.com/en/3.2/ref/settings/ # Internationalization # https://docs.djangoproject.com/en/3.2/topics/i18n/ # Database # https://docs.djangoproject.com/en/3.2/ref/settings/#databases # URLs # WSGI # Users # https://docs.djangoproject.com/en/3.2/topics/auth/customizing/#auth-custom-user # Applications configuration # https://docs.djangoproject.com/en/3.2/ref/applications/ # Password hashers # https://docs.djangoproject.com/en/3.2/topics/auth/passwords/#auth-password-storage # Password validation # https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators # Middleware # https://docs.djangoproject.com/en/3.2/topics/http/middleware/ # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/3.2/howto/static-files/ # Static files directories # https://docs.djangoproject.com/en/3.2/ref/settings/#std:setting-STATICFILES_DIRS # Static files finders # https://docs.djangoproject.com/en/3.2/ref/settings/#std:setting-STATICFILES_FINDERS # Media root # https://docs.djangoproject.com/en/3.2/ref/settings/#std:setting-MEDIA_ROOT # Media url # https://docs.djangoproject.com/en/3.2/ref/settings/#std:setting-MEDIA_URL # Templates # https://docs.djangoproject.com/en/3.2/ref/templates/ # Security # Email # https://docs.djangoproject.com/en/3.2/topics/email/ # Admin <NAME> # Model tags # https://django-taggit.readthedocs.io/en/latest/ # Django REST Framework # https://www.django-rest-framework.org/ # Default primary key field type # https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field