"""
Django settings for recipeBox project.

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

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

For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.0/ref/settings/
"""
#-- !!CREATE A MODELS.PY AND VIEWS.PY FILE INSIDE THE PROJECE DIR:
    # 1. CREATE CLASSES IN MODELS.PY [INCLUDE django models 'from django.db import models']
    # 2. CREATE FUNCT OR CLASSES IN VIEWS.PY
        # [INCLUDE: 'from django.shortcuts import render & from django.http import HttpResponse
        # & from recipeBox.models import NewsItem]
# -- !! if coming back to the project and virtualenv isnt started, use $poetry shell, then $python <filename> runserver
import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
    #--wherever our project is located, helps w/ deployment.Take proj
    #--dir drop on another machine and it should run.
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/3.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
    #--- nonce is a one-time use cipher usually to power CSRF keys in forms,
        # so when you send a form, there is a secret key generated by the webserver
        # that is a hidden field inside form.  when you submit the form, hidden field goes
        # back to the webserver & uses key to validate whether form is legit.  did it come from
        # a webserver it served.
SECRET_KEY = 'av&__9su=h$#bt81x_04qs)6t9xj7hb$5k^n9cfn2aby69q+(w'

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

#---added the hostname that is acceptable ie example.com
ALLOWED_HOSTS = ['*']


# Application definition
#---have to !!ADD THE NAME OF THE PROJECT FOLDER AT THE BOTTOM OF INSTALLED APPS LIST
    # in order for django to find it.
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'recipeBox'
]

#---where anything that needs to modify the request goes.  hits the middleware in order.
    # where most of the performance hits happen. always runs twice.
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',
]

#-- where do we start looking for things? Check out urls.py to see links.
#--!! THIS SHLD SAY '<DIRNAME>.URLS' automatically when installed apps is updated.
ROOT_URLCONF = 'recipeBox.urls'

#--the individual pieces of html that we are serving back to the end-user
# !!ADDED A TEMPLATE DIRECTORY TO 'DIRS' BELOW
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [BASE_DIR + '/recipeBox/html'],
        '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 = 'recipeBox.wsgi.application'


# Database
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
#--can have multiple databases, can set a default and have secondaries
#!! MUST CREATE DATABASE
    # migrations is the django term for anything that makes up a database.
    # every piece of modle added, etc.  We run the migrations to get base template stuff
        # to get migrations ran, use '$ python manage.py migrate'.
        # it looks at models folder, then takes all the default stuff and makes raw sql and
        # commits it to db.
#!! MUST CREATE SUPER USER TO ACCESS /ADMIN SITE:
    # 1. '$python manage.py createsuperuser'
    # 2. input username, password, and email address
    # 3.  when you go to localhost: <port>/admin ... you can login
    # admin page has users and groups: user = drop user into any app;
    # groups = pop users and assign permissions.  Both are extendable.
# !! MAY NEED TABLES CREATED
    #  if no table error: To ensure tables are created,
    # use '$python manage.py --run-syncdb' to create correct tables.
    #--NOte: manipulating the db after models have been created sometimes doesnt work well.

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


# Password validation
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
#-- can have extra or disable validation.
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/3.0/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/3.0/howto/static-files/

STATIC_URL = '/static/'
