<gh_stars>0
"""
Django settings for analytics project.

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

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

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

import os
from config import system
from config import database

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

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = system.APP_SECRET_KEY

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

ALLOWED_HOSTS = ['0.0.0.0', 'localhost']

# Session serializers
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'


# Application definition

INSTALLED_APPS = [
    'corsheaders',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'lead',
    'fund',
    'partner',
]

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',
    'corsheaders.middleware.CorsMiddleware',
]

# App urls
ROOT_URLCONF = 'analytics.urls'

CORS_ORIGIN_ALLOW_ALL = system.CORS_ORIGIN_ALLOW

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            BASE_DIR + system.TEMPLATE_PATH,    # base 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',
            ],
        },
    },
]

CACHES = {
	"default": {
		"BACKEND": "django_redis.cache.RedisCache",
		"LOCATION": "redis://127.0.0.1:6379/1",
		"TIMEOUT": None,
		"OPTIONS": {
			"MAX_ENTRIES": 1000,
			"CLIENT_CLASS": "django_redis.client.DefaultClient",
			"CONNECTION_POOL_KWARGS": {"max_connections": 100}
		}
	}
}

WSGI_APPLICATION = 'analytics.wsgi.application'

LOGIN_URL = '/login/'

# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases

DATABASES = {
    db: {
		"ENGINE": database.config[db]["ENGINE"],
		"NAME": database.config[db]["DB_NAME"],
		"USER": database.config[db]["USERNAME"],
		"PASSWORD": database.config[db]["PASSWORD"],
		"HOST": database.config[db]["HOST"],
		"PORT": database.config[db]["PORT"]
	}
	for db in database.config
}


# Password validation
# https://docs.djangoproject.com/en/1.11/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/1.11/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'Asia/Calcutta'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/

# Directory where static files are stored
STATICFILES_DIRS = [
	os.path.join(BASE_DIR, "static"),
	BASE_DIR + "/",
]

STATIC_URL = STATICFILES_DIRS[1]
FILES_DIR = os.path.join(BASE_DIR, system.TEMP_FOLDER)

# logger settings
LOGGING = {
	"version": 1,
	"disable_existing_loggers": False,
	"formatters": {
		"verbose": {
			"format": "[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s",
			"datefmt": "%d/%b/%Y %H:%M:%S"
		},
		"simple": {
			"format": "%(levelname)s %(message)s"
		},
	},
	"handlers": {
		"file": {
			"level": "DEBUG",
			"class": "logging.FileHandler",
			"filename": "logs.log",
			"formatter": "verbose"
		},
	},
	"loggers": {
		"django": {
			"handlers": ["file"],
			"propagate": True,
			"level": "DEBUG",
		},
		"bo": {
			"handlers": ["file"],
			"level": "DEBUG",
		},
		"django.request": {
			"handlers": ["file"],
			"level": "DEBUG",
			"propagate": False,
		},
	}
}

# RQ Queues
RQ_QUEUES = {
    'default': {
        'HOST': 'localhost',
        'PORT': 6379,
        'DB': 0,
        'PASSWORD': '<PASSWORD>',
        'DEFAULT_TIMEOUT': 360,
    },
    'high': {
        'URL': os.getenv('REDISTOGO_URL', 'redis://localhost:6379/0'), # If you're on Heroku
        'DEFAULT_TIMEOUT': 500,
    },
    'low': {
        'HOST': 'localhost',
        'PORT': 6379,
        'DB': 0,
    }
}
"""
Django settings for analytics project.

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

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

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

import os
from config import system
from config import database

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

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = system.APP_SECRET_KEY

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

ALLOWED_HOSTS = ['0.0.0.0', 'localhost']

# Session serializers
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'


# Application definition

INSTALLED_APPS = [
    'corsheaders',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'lead',
    'fund',
    'partner',
]

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',
    'corsheaders.middleware.CorsMiddleware',
]

# App urls
ROOT_URLCONF = 'analytics.urls'

CORS_ORIGIN_ALLOW_ALL = system.CORS_ORIGIN_ALLOW

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            BASE_DIR + system.TEMPLATE_PATH,    # base 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',
            ],
        },
    },
]

CACHES = {
	"default": {
		"BACKEND": "django_redis.cache.RedisCache",
		"LOCATION": "redis://127.0.0.1:6379/1",
		"TIMEOUT": None,
		"OPTIONS": {
			"MAX_ENTRIES": 1000,
			"CLIENT_CLASS": "django_redis.client.DefaultClient",
			"CONNECTION_POOL_KWARGS": {"max_connections": 100}
		}
	}
}

WSGI_APPLICATION = 'analytics.wsgi.application'

LOGIN_URL = '/login/'

# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases

DATABASES = {
    db: {
		"ENGINE": database.config[db]["ENGINE"],
		"NAME": database.config[db]["DB_NAME"],
		"USER": database.config[db]["USERNAME"],
		"PASSWORD": database.config[db]["PASSWORD"],
		"HOST": database.config[db]["HOST"],
		"PORT": database.config[db]["PORT"]
	}
	for db in database.config
}


# Password validation
# https://docs.djangoproject.com/en/1.11/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/1.11/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'Asia/Calcutta'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/

# Directory where static files are stored
STATICFILES_DIRS = [
	os.path.join(BASE_DIR, "static"),
	BASE_DIR + "/",
]

STATIC_URL = STATICFILES_DIRS[1]
FILES_DIR = os.path.join(BASE_DIR, system.TEMP_FOLDER)

# logger settings
LOGGING = {
	"version": 1,
	"disable_existing_loggers": False,
	"formatters": {
		"verbose": {
			"format": "[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s",
			"datefmt": "%d/%b/%Y %H:%M:%S"
		},
		"simple": {
			"format": "%(levelname)s %(message)s"
		},
	},
	"handlers": {
		"file": {
			"level": "DEBUG",
			"class": "logging.FileHandler",
			"filename": "logs.log",
			"formatter": "verbose"
		},
	},
	"loggers": {
		"django": {
			"handlers": ["file"],
			"propagate": True,
			"level": "DEBUG",
		},
		"bo": {
			"handlers": ["file"],
			"level": "DEBUG",
		},
		"django.request": {
			"handlers": ["file"],
			"level": "DEBUG",
			"propagate": False,
		},
	}
}

# RQ Queues
RQ_QUEUES = {
    'default': {
        'HOST': 'localhost',
        'PORT': 6379,
        'DB': 0,
        'PASSWORD': '<PASSWORD>',
        'DEFAULT_TIMEOUT': 360,
    },
    'high': {
        'URL': os.getenv('REDISTOGO_URL', 'redis://localhost:6379/0'), # If you're on Heroku
        'DEFAULT_TIMEOUT': 500,
    },
    'low': {
        'HOST': 'localhost',
        'PORT': 6379,
        'DB': 0,
    }
}
Django settings for analytics project.  Generated by 'django-admin startproject' using Django 1.11.10.  For more information on this file, see https://docs.djangoproject.com/en/1.11/topics/settings/  For the full list of settings and their values, see https://docs.djangoproject.com/en/1.11/ref/settings/ # Build paths inside the project like this: os.path.join(BASE_DIR, ...) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! # SECURITY WARNING: don't run with debug turned on in production! # Session serializers # Application definition # App urls # base templates # Database # https://docs.djangoproject.com/en/1.11/ref/settings/#databases # Password validation # https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators # Internationalization # https://docs.djangoproject.com/en/1.11/topics/i18n/ # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.11/howto/static-files/ # Directory where static files are stored # logger settings # RQ Queues # If you're on Heroku