"""
Django settings for classy_ordering_system project.

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

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

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
from dotenv import load_dotenv 
load_dotenv(os.path.join(BASE_DIR, "COS", ".env"))
# 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!
SECRET_KEY = '9$qwhe@i6y*&1%ahwirb3(tt343)bx7w&!co1p0y44v*1@!@i='

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

ALLOWED_HOSTS = ["*","sataware.dev","www.sataware.dev","testing.sataware.dev", "www.testing.sataware.dev"]


# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'admin_reorder',
]

LOCAL_APPS = [
    'accounts',
    'app',
    'franchise',
    'room_options',
    'inventory_options',
    'production_center',
    'jobline',
]

INSTALLED_APPS += LOCAL_APPS

AUTH_USER_MODEL = 'accounts.User'

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',
    'admin_reorder.middleware.ModelAdminReorder',

]

ROOT_URLCONF = 'COS.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',
                'franchise.custom_context_processor.order_status_renderer',
            ],
        },
    },
]

WSGI_APPLICATION = 'COS.wsgi.application'


# Database
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
DATABASES = {
    'default': {
        'ENGINE': os.environ.get('DATABASE_ENGINE', 'django.db.backends.mysql'),
        'NAME': os.environ.get('DATABASE_NAME', 'cos_db'),
        'USER': os.environ.get('DATABASE_USER', 'root'),
        'PASSWORD': os.environ.get('DATABASE_PASSWORD', 'root'),
        'HOST': os.environ.get('DATABASE_HOST', 'localhost'),
        'PORT': os.environ.get('DATABASE_PORT', '3306'),
    }
}


# 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',
    },
]


# 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 = os.environ.get("STATIC_URL",'/static/')

# EMAIL SETTINGS

EMAIL_USE_TLS =  os.environ.get("EMAIL_USE_TLS")
EMAIL_HOST =  os.environ.get("EMAIL_HOST")
EMAIL_PORT =  os.environ.get("EMAIL_PORT")
EMAIL_HOST_USER =  os.environ.get("EMAIL_HOST_USER")
EMAIL_HOST_PASSWORD =  os.environ.get("EMAIL_HOST_PASSWORD")
EMAIL_DEFAULT =  os.environ.get("EMAIL_DEFAULT")
FROM_EMAIL_DEFAULT =  os.environ.get("FROM_EMAIL_DEFAULT")
DEFAULT_FROM_EMAIL = EMAIL_DEFAULT

ACCOUNT_VERIFY_TOKEN_EXPIRE_IN = {
    'minutes': 1440
}

STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'app', 'static'),
    os.path.join(BASE_DIR, 'room_options', 'static'),
]

STATIC_ROOT = os.path.join(BASE_DIR, 'public', 'static')
MEDIA_URL =os.environ.get("MEDIA_URL")
MEDIA_ROOT = os.path.join(BASE_DIR, 'public', os.environ.get("MEDIA_ROOT",'media'))

CLASSY_URL=os.environ.get("CLASSY_URL")

from django.contrib.messages import constants as message_constants
MESSAGE_TAGS = {message_constants.DEBUG: 'debug',
                message_constants.INFO: 'info',
                message_constants.SUCCESS: 'success',
                message_constants.WARNING: 'warning',
                message_constants.ERROR: 'danger',}


API_LOGIN_URL=os.environ.get('API_LOGIN_URL')
API_TENENT_LIST=os.environ.get('API_TENENT_LIST')
API_PROJECT_LIST=os.environ.get('API_PROJECT_LIST','https://staging-crm.classyclosets.com/api/projects/list')
API_EMAIL=os.environ.get('API_EMAIL')
API_PASSWORD=os.environ.get('API_PASSWORD')

ADMIN_REORDER = (
    # Keep original label and models
    'sites',
    'accounts',
    'app',
    'auth',
    # Rename app
    {'app': 'franchise', 'label': 'Job','models':('franchise.CategoryCode','franchise.ProductionCenter' )},

    # Reorder app models
        {'app': 'franchise','label': 'Room', 'models': 
        ('franchise.RoomColorChoiceModelMap',
         'franchise.RoomMatTypeModelMap',
          'franchise.RoomProfileModelMap',
          'franchise.RoomEdgeType', 
          'franchise.RoomStainColorChoiceModelMap',
          'franchise.ProdMeterialColorMap'),
        },

{'app': 'room_options', 'label': 'KD s ','models':('room_options.KdDepth','room_options.KdWidth',
    'room_options.KdMaterial','room_options.KdEdge','room_options.KdInsertBacking', 'room_options.RoomOptionsMasterModel')},
    
{'app': 'room_options', 'label': 'Adj.Shelves ','models':('room_options.AdjDepth','room_options.AdjWidth',
    'room_options.AdjMaterial','room_options.AdjEdge','room_options.AdjInsertBacking','room_options.AdjExposedEnd')},

{'app': 'room_options', 'label': 'Doors 1/2 Pair','models':('room_options.DoorOpeningSizeMapModel','room_options.DoorOpeningheightWidthMapModel',
    'room_options.DoorDrillMapModel','room_options.GlassTypeMapModel')},
{'app': 'room_options', 'label': 'Doors Single','models':('room_options.DoorSingleOpeningSizeMapModel','room_options.DoorSingleOpeningheightWidthMapModel',)},

{'app': 'room_options', 'label': 'Custom Form Options','models':('room_options.CustomMapCategory',
                                                                 'room_options.CustomMapMaterial',
                                                                 'room_options.CustomMapBoardColor',
                                                                 'room_options.CustomMapEdgeProfile',
                                                                 'room_options.CustomMapEdgeType',
                                                                 'room_options.CustomMapEdgeColor',
                                                                 'room_options.CustomStainColor',
                                                                 'room_options.CustomMapDrill',
                                                                 )},
{'app': 'room_options', 'label': 'Custom Partition Drills','models':('room_options.CustomPartitionDrillMap',
                                                                 )},
{'app': 'room_options', 'label': 'LTI Doors','models':('room_options.DoorDrawerBaseTypeMapModel','room_options.SolidDoorMapModel',
'room_options.DoorGlassOptionsMapModel','room_options.DoorColorsMapModel','room_options.DoorSizeMapModel','room_options.LTIDrawerSizeMapModel',)},

{'app': 'room_options', 'label': 'Wood Doors','models':('room_options.WoodDoorDrawerStyleMapModel','room_options.WoodSpeciesMapModel',
'room_options.WoodDoorColorChoiceMap','room_options.WoodDrawerSizeMapModel', 'room_options.WoodDoorDrawerSizeMapModel')},

'inventory_options',
'production_center',
    # Exclude models
  #  {'app': 'auth', 'models': ('auth.User', )},

    # Cross-linked models
    # {'app': 'auth', 'models': ('auth.User', 'sites.Site')},

    # models with custom name
    # {'app': 'auth', 'models': (
    #     'auth.Group',
    #     {'model': 'auth.User', 'label': 'Staff'},
    # )},
)