<reponame>CrowdcoinSA/crowdcoin-platform<gh_stars>0
import uuid
uuid._uuid_generate_random = None
"""
Django settings for crowdcoin project.

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

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

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

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
from logentries import LogentriesHandler
import dj_database_url

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.8/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = bool(os.environ.get('DJANGO_DEBUG'))

CROWDCOIN_ENV = os.environ.get('CROWDCOIN_ENV')

CROWDCOIN_USSD_STRING = "*120*912*87*87#"

ALLOWED_HOSTS = ['*']

CELERY_ACCEPT_CONTENT = ['json']


# Application definition

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.humanize',
    'django.contrib.postgres',
    'website',
    'django.contrib.sites',
    'tastypie',
)

SITE_ID = 1

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'corsheaders.middleware.CorsMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
   )

ROOT_URLCONF = 'crowdcoincoza.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',
            ],
        },
    },
]

WSGI_APPLICATION = 'crowdcoincoza.wsgi.application'


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


DATABASES = {'default': dj_database_url.config()}
DATABASES['default']['ENGINE'] = 'django.db.backends.postgresql_psycopg2'
DATABASES['default']['NAME'] = os.environ.get('DB_NAME','postgres')
DATABASES['default']['USER'] = os.environ.get('DB_USER','postgres')
DATABASES['default']['PASSWORD'] = os.environ.get('DB_PASSWORD')
DATABASES['default']['HOST'] = os.environ.get('DB_HOST','db')
DATABASES['default']['PORT'] = 5432


# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/

LANGUAGE_CODE = 'en-za'

TIME_ZONE = 'Africa/Johannesburg'

USE_I18N = True

USE_L10N = True

USE_TZ = True


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

STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, "static_files"),
]
STATIC_URL = '/static/'
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage'
STATICFILES_LOCATION = 'static'
MEDIAFILES_LOCATION = 'media'
UPLOADS_DIRECTORY ='uploads/'

TASTYPIE_ALLOW_MISSING_SLASH = True

X_FRAME_OPTIONS = 'Access-Control-Allow-Origin'

#Site-wide logging
LOGGING = {
    'version': 1,
    'disable_existing_loggers': True,
    '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': 'crowdcoin-django.log',
            'formatter': 'verbose'
        },
        'console': {
            'class': 'logging.StreamHandler',
            'level': 'DEBUG',
            'formatter': 'verbose'
        },
    },
    'loggers': {
        'django': {
            'handlers':['file','console'],
            'propagate': True,
            'level':'WARNING',
            'formatter': 'verbose',
        },
        'website': {
            'handlers': ['file','console'],
            'level': 'INFO',
            'formatter': ['verbose'],
        },
        'xhtml2pdf': {
            'handlers':['file'],
            'propagate': True,
            'level':'INFO',
        },
        'celery.task': {
            'handlers':['file','console'],
            'propagate': True,
            'level':'INFO',
        },
        'celery': {
            'handlers':['file','console'],
            'propagate': True,
            'level':'INFO',
        }
    }
}

SESSION_SAVE_EVERY_REQUEST = True
LOGIN_URL = '/admin/login/'
LOGIN_REDIRECT_URL = '/'


EMAIL_USE_TLS = bool(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')


FRESHDESK_URL = os.environ.get('FRESHDESK_URL','crowdcoin.freshdesk.com/')
FRESHDESK_KEY = os.environ.get('FRESHDESK_KEY')

SUPPORTED_NETWORKS = ["MTN"]

#----- CROWDCOIN FEES -----
VOUCHER_SENDING_FEE = 0
VOUCHER_RECIEVING_FEE = 0

PANACEA_USER  = os.environ.get('PANACEA_USER')

PANACEA_PASSWORD  = <PASSWORD>.get('<PASSWORD>A_PASSWORD')

TIM_CERT = os.environ.get('TIM_CERT')

TIM_KEY = os.environ.get('TIM_KEY')
import uuid
uuid._uuid_generate_random = None
"""
Django settings for crowdcoin project.

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

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

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

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
from logentries import LogentriesHandler
import dj_database_url

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.8/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = bool(os.environ.get('DJANGO_DEBUG'))

CROWDCOIN_ENV = os.environ.get('CROWDCOIN_ENV')

CROWDCOIN_USSD_STRING = "*120*912*87*87#"

ALLOWED_HOSTS = ['*']

CELERY_ACCEPT_CONTENT = ['json']


# Application definition

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.humanize',
    'django.contrib.postgres',
    'website',
    'django.contrib.sites',
    'tastypie',
)

SITE_ID = 1

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'corsheaders.middleware.CorsMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
   )

ROOT_URLCONF = 'crowdcoincoza.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',
            ],
        },
    },
]

WSGI_APPLICATION = 'crowdcoincoza.wsgi.application'


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


DATABASES = {'default': dj_database_url.config()}
DATABASES['default']['ENGINE'] = 'django.db.backends.postgresql_psycopg2'
DATABASES['default']['NAME'] = os.environ.get('DB_NAME','postgres')
DATABASES['default']['USER'] = os.environ.get('DB_USER','postgres')
DATABASES['default']['PASSWORD'] = os.environ.get('DB_PASSWORD')
DATABASES['default']['HOST'] = os.environ.get('DB_HOST','db')
DATABASES['default']['PORT'] = 5432


# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/

LANGUAGE_CODE = 'en-za'

TIME_ZONE = 'Africa/Johannesburg'

USE_I18N = True

USE_L10N = True

USE_TZ = True


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

STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, "static_files"),
]
STATIC_URL = '/static/'
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage'
STATICFILES_LOCATION = 'static'
MEDIAFILES_LOCATION = 'media'
UPLOADS_DIRECTORY ='uploads/'

TASTYPIE_ALLOW_MISSING_SLASH = True

X_FRAME_OPTIONS = 'Access-Control-Allow-Origin'

#Site-wide logging
LOGGING = {
    'version': 1,
    'disable_existing_loggers': True,
    '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': 'crowdcoin-django.log',
            'formatter': 'verbose'
        },
        'console': {
            'class': 'logging.StreamHandler',
            'level': 'DEBUG',
            'formatter': 'verbose'
        },
    },
    'loggers': {
        'django': {
            'handlers':['file','console'],
            'propagate': True,
            'level':'WARNING',
            'formatter': 'verbose',
        },
        'website': {
            'handlers': ['file','console'],
            'level': 'INFO',
            'formatter': ['verbose'],
        },
        'xhtml2pdf': {
            'handlers':['file'],
            'propagate': True,
            'level':'INFO',
        },
        'celery.task': {
            'handlers':['file','console'],
            'propagate': True,
            'level':'INFO',
        },
        'celery': {
            'handlers':['file','console'],
            'propagate': True,
            'level':'INFO',
        }
    }
}

SESSION_SAVE_EVERY_REQUEST = True
LOGIN_URL = '/admin/login/'
LOGIN_REDIRECT_URL = '/'


EMAIL_USE_TLS = bool(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')


FRESHDESK_URL = os.environ.get('FRESHDESK_URL','crowdcoin.freshdesk.com/')
FRESHDESK_KEY = os.environ.get('FRESHDESK_KEY')

SUPPORTED_NETWORKS = ["MTN"]

#----- CROWDCOIN FEES -----
VOUCHER_SENDING_FEE = 0
VOUCHER_RECIEVING_FEE = 0

PANACEA_USER  = os.environ.get('PANACEA_USER')

PANACEA_PASSWORD  = <PASSWORD>.get('<PASSWORD>A_PASSWORD')

TIM_CERT = os.environ.get('TIM_CERT')

TIM_KEY = os.environ.get('TIM_KEY')
Django settings for crowdcoin project.  Generated by 'django-admin startproject' using Django 1.8.  For more information on this file, see https://docs.djangoproject.com/en/1.8/topics/settings/  For the full list of settings and their values, see https://docs.djangoproject.com/en/1.8/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.8/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! # SECURITY WARNING: don't run with debug turned on in production! #" # Application definition # Database # https://docs.djangoproject.com/en/1.8/ref/settings/#databases # Internationalization # https://docs.djangoproject.com/en/1.8/topics/i18n/ # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.8/howto/static-files/ #Site-wide logging #----- CROWDCOIN FEES -----