# encoding: utf-8

"""
@summary:       {{ project_name }} dev settings
@author:        Eric Pieuchot
@copyright:     Copyright 2016 Rubicubix Ltd
@license:       GNU GPL
@contact:       eric@rubicubix.co.uk
"""

from {{ project_name }}.settings.base import *

from os.path import join

__all__ = [
    'DEBUG_TOOLBAR_CONFIG',
    'INTERNAL_IPS',
    'SECRET_KEY',
    'DATABASES',
    'LOGGING',
    'PROJECT_ROOT',
    'BASE_DIR',
    'SITE_NAME',
    'STATICFILES_DIRS',
    'PROJECT_TEMPLATES',
    'STATIC_ROOT',
    'MEDIA_ROOT',
    'STATICFILES_DIRS',
    'PROJECT_TEMPLATES',
    'INSTALLED_APPS',
    'MIDDLEWARE',
    'TEMPLATES',
    'WSGI_APPLICATION',
    'ROOT_URLCONF',
    'SITE_ID',
    'STATIC_URL',
    'MEDIA_URL',
    'LANGUAGE_CODE',
    'LANGUAGES',
    'TIME_ZONE',
    'USE_I18N',
    'USE_L10N',
    'USE_TZ',
]


# ##### DEBUG TOOLBAR CONFIGURATION ###########################################

# Apps
# http://django-debug-toolbar.readthedocs.io/en/stable/installation.html
INSTALLED_APPS += [
    'debug_toolbar',
]

# Middlewares
MIDDLEWARE += [
    'debug_toolbar.middleware.DebugToolbarMiddleware',
]

# Configs
DEBUG_TOOLBAR_CONFIG = {
    'INTERCEPT_REDIRECTS': False,
    'SHOW_TEMPLATE_CONTEXT': True,
    'HIDE_DJANGO_SQL': False,
}

# Hosts
INTERNAL_IPS = [
    '127.0.0.1',
]


# ##### SECURITY CONFIGURATION ################################################

# Store / create secret key
# https://docs.djangoproject.com/en/1.10/ref/settings/#secret-key
try:
    _path = join(PROJECT_ROOT, 'app', 'secret.key')
    with open(_path, 'r') as f:
        SECRET_KEY = f.read().strip()

except IOError:

    with open(_path, 'w') as f:
        from django.utils.crypto import get_random_string
        _chars = 'abcdefghijklmnopqrstuvwxyz0123456789!$%&()=+-_'
        SECRET_KEY = get_random_string(50, _chars)
        f.write(SECRET_KEY)

    pass
