"""
Django settings for _keenthemes project.

Generated by 'django-admin startproject' using Django 4.0.3.

For more information on this file, see
https://docs.djangoproject.com/en/4.0/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.0/ref/settings/
"""

import os
from pathlib import Path
from datetime import timedelta
from firebase_admin import initialize_app, credentials
from google.auth import load_credentials_from_file

from dotenv import load_dotenv, find_dotenv
load_dotenv(find_dotenv())

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent

X_FRAME_OPTIONS = 'SAMEORIGIN'
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ['SECRET_KEY']
# SECURITY WARNING: don't run with debug turned on in production!

BASE_URL = 'https://ea.stagingstorm.com'

DEBUG = True

ALLOWED_HOSTS = ['ea.stagingstorm.com','112.213.37.150','127.0.0.1','www.shadowserver.org','api.ipify.org']

# if DEBUG: 
#   STATIC_ROOT = os.path.join(BASE_DIR, '/assets')
# else:
#   STATIC_ROOT = os.path.join(BASE_DIR, 'assets') 
# Application definition

INSTALLED_APPS = [

    #dependencies
    # 'daphne',
    # 'channels',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django_dump_die',
    # 'django_json-diff',
    'rest_framework',
    'rest_framework_simplejwt',
    'reversion',
    'fcm_django',
   
    
     #apps
    'dashboards.apps.DashboardsConfig',
    'authentication.apps.AuthenticationConfig',
    'product.apps.ProductConfig',
    'customer.apps.CustomerConfig',
    'supplier.apps.SupplierConfig',
    'myobconnect.apps.MyobconnectConfig',
    'user.apps.UserConfig',
    'quotation.apps.QuotationConfig',
    'technician.apps.TechnicianConfig',
    'service.apps.ServiceConfig',
    'leads',
    'django.contrib.humanize',

]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django_dump_die.middleware.DumpAndDieMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    
    'whitenoise.middleware.WhiteNoiseMiddleware',
    'reversion.middleware.RevisionMiddleware',
    #'middleware.login_required_middleware.LoginRequiredMiddleware',
]

SESSION_EXPIRE_SECONDS = 30
# SESSION_COOKIE_AGE =20
SESSION_EXPIRE_AFTER_LAST_ACTIVITY = True

# SESSION_ENGINE = 'django.contrib.sessions.backends.db'
# SESSION_EXPIRE_AT_BROWSER_CLOSE = True

ROOT_URLCONF = '_keenthemes.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',
                'quotation.context_processors.custom_context_processors.product_list_to_bill_count',
                'quotation.context_processors.custom_context_processors.order_item_serial_number_unallocate_list',
                'quotation.context_processors.custom_context_processors.part_requested_list',
                'quotation.context_processors.custom_context_processors.active_arrival_count',
                'quotation.context_processors.custom_context_processors.active_arrival_list',
                'quotation.context_processors.custom_context_processors.note_customer_count',
                'quotation.context_processors.custom_context_processors.TotalCount',
                'quotation.context_processors.custom_context_processors.leadnote_customer_count',
                'quotation.context_processors.custom_context_processors.TotalCountSales',
                'quotation.context_processors.custom_context_processors.trade_product_count',
                'quotation.context_processors.custom_context_processors.service_request_count',
            ],
            'libraries': {
                'theme': '_keenthemes.templatetags.theme',
            },
            'builtins': [
                'django.templatetags.static',
                '_keenthemes.templatetags.theme',
            ]
        },
    },
]

WSGI_APPLICATION = '_keenthemes.wsgi.application'
# ASGI_APPLICATION = '_keenthemes.asgi.application'


# Database
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'eastagingstorm_excitechLive',
        'USER': 'eastagingstorm_excitechliveusr',
        'PASSWORD': 'ZXCV!@#$4321qwertD78',
        # 'NAME': 'excitech',
        # 'USER': 'root',
        # 'PASSWORD': '',
        'HOST':'127.0.0.1',
        'PORT':'3306',
    }
}


# Password validation
# https://docs.djangoproject.com/en/4.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/4.0/topics/i18n/

LANGUAGE_CODE = 'en-US'

TIME_ZONE = "Australia/Sydney"

USE_I18N = True

USE_TZ = True

LOCALE_PATHS = [
    os.path.join(BASE_DIR, '_locale'),
]


STATIC_URL = 'assets/'
MEDIA_URL = '/media/'

if DEBUG:
    # STATIC_ROOT = os.path.join(BASE_DIR, 'assets/')
    STATICFILES_DIRS = [os.path.join(BASE_DIR, 'assets/')]

else:
    STATIC_ROOT = os.path.join(BASE_DIR, 'assets/')

MEDIA_ROOT = os.path.join(BASE_DIR, 'media')


FILE_UPLOAD_HANDLERS = [
    'django.core.files.uploadhandler.TemporaryFileUploadHandler',
]

# Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'


######################
# Keenthemes Settings
######################

KT_THEME = 'metronic'


# Theme layout templates directory

KT_THEME_LAYOUT_DIR = 'layout'


# Theme Mode
# Value: light | dark | system

KT_THEME_MODE_DEFAULT = 'light'
KT_THEME_MODE_SWITCH_ENABLED = True


# Theme Direction
# Value: ltr | rtl

KT_THEME_DIRECTION = 'ltr'


# Keenicons
# Value: duotone | outline | bold

KT_THEME_ICONS = 'duotone'


# Theme Assets

KT_THEME_ASSETS = {
    "favicon": "media/logos/favicon.ico",
    "fonts": [
        'https://fonts.googleapis.com/css?family=Inter:300,400,500,600,700',
    ],
    "css": [
        "plugins/global/plugins.bundle.css",
        "css/style.bundle.css"
    ],
    "js": [
        "plugins/global/plugins.bundle.js",
        "js/scripts.bundle.js",
    ]
}


# Theme Vendors

KT_THEME_VENDORS = {
    "datatables": {
        "css": [
            "plugins/custom/datatables/datatables.bundle.css"
        ],
        "js": [
            "plugins/custom/datatables/datatables.bundle.js"
        ]
    },
    "formrepeater": {
        "js": [
            "plugins/custom/formrepeater/formrepeater.bundle.js"
        ]
    },
    "fullcalendar": {
        "css": [
            "plugins/custom/fullcalendar/fullcalendar.bundle.css"
        ],
        "js": [
            "plugins/custom/fullcalendar/fullcalendar.bundle.js"
        ]
    },
    "flotcharts": {
        "js": [
            "plugins/custom/flotcharts/flotcharts.bundle.js"
        ]
    },
    "google-jsapi": {
        "js": [
            "//www.google.com/jsapi"
        ]
    },
    "tinymce": {
        "js": [
            "plugins/custom/tinymce/tinymce.bundle.js"
        ]
    },
    "ckeditor-classic": {
        "js": [
            "plugins/custom/ckeditor/ckeditor-classic.bundle.js"
        ]
    },
    "ckeditor-inline": {
        "js": [
            "plugins/custom/ckeditor/ckeditor-inline.bundle.js"
        ]
    },
    "ckeditor-balloon": {
        "js": [
            "plugins/custom/ckeditor/ckeditor-balloon.bundle.js"
        ]
    },
    "ckeditor-balloon-block": {
        "js": [
            "plugins/custom/ckeditor/ckeditor-balloon-block.bundle.js"
        ]
    },
    "ckeditor-document": {
        "js": [
            "plugins/custom/ckeditor/ckeditor-document.bundle.js"
        ]
    },
    "draggable": {
        "js": [
            "plugins/custom/draggable/draggable.bundle.js"
        ]
    },
    "fslightbox": {
        "js": [
            "plugins/custom/fslightbox/fslightbox.bundle.js"
        ]
    },
    "jkanban": {
        "css": [
            "plugins/custom/jkanban/jkanban.bundle.css"
        ],
        "js": [
            "plugins/custom/jkanban/jkanban.bundle.js"
        ]
    },
    "typedjs": {
        "js": [
            "plugins/custom/typedjs/typedjs.bundle.js"
        ]
    },
    "cookiealert": {
        "css": [
            "plugins/custom/cookiealert/cookiealert.bundle.css"
        ],
        "js": [
            "plugins/custom/cookiealert/cookiealert.bundle.js"
        ]
    },
    "cropper": {
        "css": [
            "plugins/custom/cropper/cropper.bundle.css"
        ],
        "js": [
            "plugins/custom/cropper/cropper.bundle.js"
        ]
    },
    "vis-timeline": {
        "css": [
            "plugins/custom/vis-timeline/vis-timeline.bundle.css"
        ],
        "js": [
            "plugins/custom/vis-timeline/vis-timeline.bundle.js"
        ]
    },
    "jstree": {
        "css": [
            "plugins/custom/jstree/jstree.bundle.css"
        ],
        "js": [
            "plugins/custom/jstree/jstree.bundle.js"
        ]
    },
    "prismjs": {
        "css": [
            "plugins/custom/prismjs/prismjs.bundle.css"
        ],
        "js": [
            "plugins/custom/prismjs/prismjs.bundle.js"
        ]
    },
    "leaflet": {
        "css": [
            "plugins/custom/leaflet/leaflet.bundle.css"
        ],
        "js": [
            "plugins/custom/leaflet/leaflet.bundle.js"
        ]
    },
    "amcharts": {
        "js": [
            "https://cdn.amcharts.com/lib/5/index.js",
            "https://cdn.amcharts.com/lib/5/xy.js",
            "https://cdn.amcharts.com/lib/5/percent.js",
            "https://cdn.amcharts.com/lib/5/radar.js",
            "https://cdn.amcharts.com/lib/5/themes/Animated.js"
        ]
    },
    "amcharts-maps": {
        "js": [
            "https://cdn.amcharts.com/lib/5/index.js",
            "https://cdn.amcharts.com/lib/5/map.js",
            "https://cdn.amcharts.com/lib/5/geodata/worldLow.js",
            "https://cdn.amcharts.com/lib/5/geodata/continentsLow.js",
            "https://cdn.amcharts.com/lib/5/geodata/usaLow.js",
            "https://cdn.amcharts.com/lib/5/geodata/worldTimeZonesLow.js",
            "https://cdn.amcharts.com/lib/5/geodata/worldTimeZoneAreasLow.js",
            "https://cdn.amcharts.com/lib/5/themes/Animated.js"
        ]
    },
    "amcharts-stock": {
        "js": [
            "https://cdn.amcharts.com/lib/5/index.js",
            "https://cdn.amcharts.com/lib/5/xy.js",
            "https://cdn.amcharts.com/lib/5/themes/Animated.js"
        ]
    },
    "bootstrap-select": {
        "css": [
            "plugins/custom/bootstrap-select/bootstrap-select.bundle.css"
        ],
        "js": [
            "plugins/custom/bootstrap-select/bootstrap-select.bundle.js"
        ]
    }
}

AUTH_USER_MODEL = 'authentication.User'



EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' 
EMAIL_HOST = 'smtp.mailgun.org'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'postmaster@ea.stagingstorm.com'
EMAIL_HOST_PASSWORD ='2ed0afffc163156b01e5d02344031648-8c8e5529-714209fc'
EMAIL_USE_TLS = False
FROM_EMAIL = 'EXCITECH Australia <noreply@ea.stagingstorm.com>'
FROM_NAME = 'EXCITECH Australia <noreply@ea.stagingstorm.com>'


FINANCIAL_BROKER_EMAIL = 'gs@beedev.com.au'
# FINANCIAL_BROKER_EMAIL = 'supriya@beedev.com.au'
FINANCIAL_BROKER_NAME = 'EXCITECH Australia Finance'

ADMIN_EMAIL='accounts@dentro.com.au'
ADMIN_EMAIL_CC_PO=['kiran@beedev.co.in']
BCC_EMAIL_BD =['kiran@beedev.co.in']
PAGE_RECORDS=50

SCOPES = ['https://www.googleapis.com/auth/youtube.upload']

# ADMIN_EMAIL='supriya@beedev.com.au'

MYOB_CLIENT_ID='d6436eb7-0703-4fc7-9023-f7ee0add8faa'
MYOB_CLIENT_SECRET = 'BZk51mPmwdbRE2w3XTxG2sx7'
MYOB_REDIRECT_URI='https://ea.stagingstorm.com/myob-redirect'
COMPANY_FILE_ID='ed1538a2-94c4-4188-81c6-c21ee5bff73c'


# MYOB_ExpenseAccount = 'f6765acc-e7ed-4f0d-94f0-a30b1a00fc95'
# MYOB_CostOfSalesAccount='f954683f-d0f5-4c38-8d5d-398945bf1177'
# MYOB_IncomeAccount='d6343c99-8ae8-4f21-8723-87e6b540c9ca'
# MYOB_AssetAccount= '0a687ef8-18b6-48f5-a730-93260b85fd5c'
# MYOB_TaxCode='6f5fce5d-604f-49db-9a56-8573e7d2a5ec'



STRIPE_SECRET_KEY='pk_test_51OY9tZSC4oFoHlH8PIAaq3bqefC1Mxw0TpLNOTJXbqLj2nMNgDGOxuDNI4heRrAGNrgegNWOkUwCIu0n17GrYjLq00D1pa9wei'
STRIPE_PUBLISHABLE_KEY='sk_test_51OY9tZSC4oFoHlH8Es769a9dJBzWAdobcuxruYsiCj2wqLzEbGkeyjzIIflH2RumKhUPPFMMljjMoLpCZebXAVg100q3uHEoG2'

LOGIN_URL = '/'
LOGOUT_URL = '/signout/'
LOGIN_REDIRECT_URL = '/'


FCM_DJANGO_SETTINGS = {
    "FCM_SERVER_KEY":os.environ['FCM_SERVER_TOKEN'],
    "FCM_SENDER_ID":os.environ['FCM_SENDER_ID'],
    "ONE_DEVICE_PER_USER": True,
}


# CHANNEL_LAYERS = {
#     "default": {
#         "BACKEND": "channels.layers.InMemoryChannelLayer"
#     }
# }

DATA_UPLOAD_MAX_MEMORY_SIZE = 10485760



