import os
import random
import hashlib
import time

basedir = os.path.abspath(os.path.dirname(__file__))

class BaseConfig(object):
    #DATABASE
    SQLALCHEMY_DATABASE_URI = 'postgresql://proxadmin:CHANGEME@localhost/proxdb'
    SQLALCHEMY_MIGRATE_REPO = os.path.join(basedir, 'db_repository')
    SQLALCHEMY_RECORD_QUERIES = True
    SLOW_DB_QUERY_TIME = 0.5
    SQLALCHEMY_TRACK_MODIFICATIONS = True
    #SQLALCHEMY_ECHO = True

    #MAIL
    MAIL_SERVER = 'mail.server.tld'
    MAIL_PORT = 587
    MAIL_USE_TLS = True
    MAIL_USERNAME = os.environ.get('MAIL_USERNAME') or 'admin@server.tld'
    MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD') or 'CHANGEME'
    MAIL_SUBJECT_PREFIX = '[admin]'
    MAIL_SENDER = 'Virtual Office <admin@server.tld>'
    MAIL_ADMIN = os.environ.get('MAIL_ADMIN') or 'Proxadmin'

    #API
    PROXMASTER_URL='https://api.example.tld'
    APIKEY='CHANGEME'
    ADMIN_EMAIL='adminuser@example.tld'
    ADMIN_PREFIX='admin123456'

    #MISC
    SUPPORTED_LOCALES = ['en']

    #SECURITY
    SECRET_KEY = 'CHANGEME'
    CSRF_ENABLED = True
    WTF_CSRF_ENABLED = True
    WTF_CSRF_TIME_LIMIT = 180
    #SESSION_COOKIE_DOMAIN = "www.example.tld"
    #SESSION_COOKIE_SECURE = True
    RECAPTCHA_PUBLIC_KEY = "CHANGEME"
    RECAPTCHA_PRIVATE_KEY = "CHANGEME"
    RECAPTCHA_DATA_ATTRS = {'theme': 'dark'}

    #FACEBOOK
    FB_APP_ID = 'CHANGEME'
    FB_APP_SECRET = 'CHANGEME'
    FB_PAGE_ID = 'CHANGEME'

    #GOOGLEOAUTH2
    GOOGLE_CLIENT_ID = ('CHANGEME'
                        '.apps.googleusercontent.com')
    GOOGLE_CLIENT_SECRET= '6XScleYPVEY5Vvd_GvZ_RHlB'
    REDIRECT_UTL = 'https://www.example.tld/auth/oauth2callback'
    AUTH_URI = 'https://accounts.google.com/o/oauth2/auth'
    TOKEN_URI = 'https://accounts.google.com/o/oauth2/token'
    USER_INFO = 'https://www.googleapis.com/userinfo/v2/me'

    REGISTER_BONUS = 5.0

    # EXAMPLE DATA
    REGIONS = [ ('region1', 'Region1'),
                ('region2', 'Region2') ]
    CPU_RATIO = 4.7
    MEM_RATIO = 3.0
    HDD_RATIO = 0.4

    @staticmethod
    def init_app(app):
       pass


class ProductionConfig(BaseConfig):
    DEBUG = False

class DevelopmentConfig(BaseConfig):
    DEBUG = True

config = {
    'development': DevelopmentConfig,
    'production': ProductionConfig,
    'default': ProductionConfig
}

