
"""
settings.py
Author: Haidar Khazen
created 6/27/20

(c) Copyright by The Rhazenette Corp for Chemtrusion

Django settings for Chemtrusion Informant project.

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

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/

"""

import os
from django.contrib.messages import constants as messages

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

# 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/3.0/howto/deployment/checklist/

# Application definition

# https://docs.djangoproject.com/en/3.0/ref/settings/#std:setting-INSTALLED_APPS
INSTALLED_APPS = [
    # Add your apps here to enable them
    'accounts',
    'informant_erp',
    'informant_site',
    'informant_lookups',
    'informant_reports',
    'support',
    'support.datetime_field',
    'support.django_popup_view_field',
    'support.bootstrap_modal_forms',
    'bootstrap4',
    'crispy_forms',
    'widget_tweaks',
    'easy_timezones',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.humanize',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',
    'import_export',
]

SITE_ID = 1  #1=IN, 2=TX

DJANGO_POPUP_VIEW_FIELD_TEMPLATE_PACK = 'bootstrap4'
CRISPY_TEMPLATE_PACK = 'bootstrap4'

# Middleware framework
# https://docs.djangoproject.com/en/3.0/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',
    'easy_timezones.middleware.EasyTimezoneMiddleware',
    'informant_site.middleware.DynamicSiteMiddleware',
]

ROOT_URLCONF = 'informant.urls'

# Template configuration
# https://docs.djangoproject.com/en/3.0/topics/templates/
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.template.context_processors.media',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
                'support.context_processors.copyright_year',
                'support.context_processors.copyright_company',
            ],
        },
    },
]

WSGI_APPLICATION = 'informant.wsgi.application'

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

# Timezone settings
TIME_ZONE = 'UTC'
USE_TZ = True
GEOIP_DATABASE = os.path.join(BASE_DIR, 'geoip//GeoLiteCity.dat')
GEOIPV6_DATABASE = os.path.join(BASE_DIR, 'geoip//GeoLiteCityv6.dat')

DATETIME_FORMAT = 'm/d/Y, H:i'
DATE_FORMAT = 'm/d/Y'
from django.conf.global_settings import DATETIME_INPUT_FORMATS, DATE_INPUT_FORMATS
DATETIME_INPUT_FORMATS += ('%m-%d-%Y, %H:%M', '%m-%d-%y, %H:%M', '%m/%d/%Y, %H:%M', '%m/%d/%y, %H:%M','%m-%d-%Y %H:%M', '%m-%d-%y %H:%M', '%m/%d/%Y %H:%M', '%m/%d/%y %H:%M', '%m-%d-%Y', '%m-%d-%y', '%m/%d/%Y', '%m/%d/%y')
DATE_INPUT_FORMATS += ('%m-%d-%Y', '%m-%d-%y', '%m/%d/%Y', '%m/%d/%y',)

# Internationalization
# https://docs.djangoproject.com/en/3.0/topics/i18n/
LANGUAGE_CODE = 'en-us'
USE_I18N = True
USE_L10N = False
USE_THOUSAND_SEPARATOR = True

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, "static/")

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, "media/")

EXPORT_ROOT = os.path.join(BASE_DIR, "export/")
EXPORT_TEMPLATES = os.path.join(BASE_DIR, 'templates', 'informant_reports', 'export')

# Message tags = css for display
MESSAGE_TAGS = {
    messages.DEBUG: 'alert-info',
    messages.INFO: 'alert-info',
    messages.SUCCESS: 'alert-success',
    messages.WARNING: 'alert-warning',
    messages.ERROR: 'alert-danger',
}

DATA_UPLOAD_MAX_NUMBER_FIELDS = 5000