# -*- coding: utf-8 -*-
import os
import sys

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



class Operations:
    CONFIRM = 'confirm'
    RESET_PASSWORD = 'reset-password'
    CHANGE_EMAIL = 'change-email'


class BaseConfig:
    PHSHARE_ADMIN_EMAIL = os.getenv('PHSHARE_ADMIN', 'admin@helloflask.com')
    PHSHARE_PHOTO_PER_PAGE = 12
    PHSHARE_COMMENT_PER_PAGE = 15
    PHSHARE_NOTIFICATION_PER_PAGE = 20
    PHSHARE_USER_PER_PAGE = 20
    PHSHARE_MANAGE_PHOTO_PER_PAGE = 20
    PHSHARE_MANAGE_USER_PER_PAGE = 30
    PHSHARE_MANAGE_TAG_PER_PAGE = 50
    PHSHARE_MANAGE_COMMENT_PER_PAGE = 30
    PHSHARE_SEARCH_RESULT_PER_PAGE = 20
    PHSHARE_MAIL_SUBJECT_PREFIX = '[Phshare]'
    PHSHARE_UPLOAD_PATH = os.path.join(basedir, 'uploads')
    PHSHARE_PHOTO_SIZE = {'small': 400,
                         'medium': 800}
    PHSHARE_PHOTO_SUFFIX = {
        PHSHARE_PHOTO_SIZE['small']: '_s',  # thumbnail
        PHSHARE_PHOTO_SIZE['medium']: '_m',  # display
    }

    SECRET_KEY = os.getenv('SECRET_KEY', 'secret string')
    MAX_CONTENT_LENGTH = 3 * 1024 * 1024  # file size exceed to 3 Mb will return a 413 error response.

    BOOTSTRAP_SERVE_LOCAL = True

    SQLALCHEMY_TRACK_MODIFICATIONS = False

    AVATARS_SAVE_PATH = os.path.join(PHSHARE_UPLOAD_PATH, 'avatars')
    AVATARS_SIZE_TUPLE = (30, 100, 200)

    MAIL_SERVER = os.getenv('MAIL_SERVER')
    MAIL_PORT = 465
    MAIL_USE_SSL = True
    MAIL_USERNAME = os.getenv('MAIL_USERNAME')
    MAIL_PASSWORD = os.getenv('MAIL_PASSWORD')
    MAIL_DEFAULT_SENDER = ('Phshare Admin', MAIL_USERNAME)

    DROPZONE_ALLOWED_FILE_TYPE = 'image'
    DROPZONE_MAX_FILE_SIZE = 3
    DROPZONE_MAX_FILES = 30
    DROPZONE_ENABLE_CSRF = True

    WHOOSHEE_MIN_STRING_LEN = 1


class DevelopmentConfig(BaseConfig):
    SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://root:zhangshuowen123@10.23.204.127:3306/phshare'
    REDIS_URL = "redis://localhost"



class ProductionConfig(BaseConfig):
    SQLALCHEMY_DATABASE_URI = os.getenv('SQLALCHEMY_DATABASE_URI', 'mysql+pymysql://root:zhangshuowen123@10.23.204.127'
                                                                   ':3306/phshare')


config = {
    'base': BaseConfig,
    'development': DevelopmentConfig,
    # 'testing': TestingConfig,
    'production': ProductionConfig,
}
