"""
Django settings for mvote project.

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

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

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 = 'r_()$39v!n$l%x4yrs@t$a*qk3b*uf9re$^6jkx=^-x2x)k986'

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

ALLOWED_HOSTS = ['*']
SESSION_SERIALIZER  = 'django.contrib.sessions.serializers.PickleSerializer'


# Application definition

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'mysite',
    'usermanage',
    'easy_thumbnails',
    #'rest_framework',
    'filer',
    'mptt',
    'cart',
    'django.contrib.sites',
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    #'allauth.socialaccount.providers.facebook',
    'allauth.socialaccount.providers.github',
    'allauth.socialaccount.providers.twitter',
    #'paypal.standard.ipn',
    'corsheaders',
)

PAYPAL_TEST = True
PAYPAL_REVEIVER_EMAIL = '1625504587@qq.com'
#SITE_ID = 1
#LOGIN_REDIRECT_URL = '/'
#EMAIL_BACKEND = 'django_mailgun.MailgunBackend'
#MAILGUN_ACCESS_KEY = 'key-7b0a7f258eec3d2006e337709caf17d2'
#MAILGUN_SERVER_NAME = 'sandboxc1f4364d269b4be489924008c6831bdd.mailgun.org'
#AUTHENTICATION_BACKENDS = (
#    'django.contrib.auth.backends.ModelBackend',
#    'allauth.account.auth_backends.AuthenticationBackend',
#)

THUMBNAIL_HIGH_RESOLUTION = True
THUMBNAIL_PROCESSORS = (
    'easy_thumbnails.processors.colorspace',
    'easy_thumbnails.processors.autocrop',
    'filer.thumbnail_processors.scale_and_crop_with_subject_location',
    'easy_thumbnails.processors.filters',
)


FILER_STORAGES = {
    'public': {
        'main': {
            'ENGINE': 'filer.storage.PublicFileSystemStorage',
            'OPTIONS': {
                'location': '/data/mshop/staticfiles/media/filer',
                'base_url': '/media/filer/',
            },
            'UPLOAD_TO': 'filer.utils.generate_filename.randomized',
            'UPLOAD_TO_PREFIX': 'filer_public',
        },
        'thumbnails': {
            'ENGINE': 'filer.storage.PublicFileSystemStorage',
            'OPTIONS': {
                'location': '/data/mshop/staticfiles/media/filer_thumbnails',
                'base_url': '/media/filer_thumbnails/',
            },
        },
    },
    'private': {
        'main': {
            'ENGINE': 'filer.storage.PrivateFileSystemStorage',
            'OPTIONS': {
                'location': '/data/mshop/staticfiles/smedia/filer',
                'base_url': '/smedia/filer/',
            },
            'UPLOAD_TO': 'filer.utils.generate_filename.randomized',
            'UPLOAD_TO_PREFIX': 'filer_public',
        },
        'thumbnails': {
            'ENGINE': 'filer.storage.PrivateFileSystemStorage',
            'OPTIONS': {
                'location': '/data/mshop/staticfiles/smedia/filer_thumbnails',
                'base_url': '/smedia/filer_thumbnails/',
            },
        },
    },
}

DEFAULT_FILER_SERVERS = {
    'private': {
        'main': {
            'ENGINE': 'filer.server.backends.default.DefaultServer',
        },
        'thumbnails': {
            'ENGINE': 'filer.server.backends.default.DefaultServer',
        }
    }
}

MEDIA_URL = '/media/'
MEDIA_ROOT = '/data/mshop/staticfiles/media'


MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    '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',
    'django.middleware.security.SecurityMiddleware',
    'corsheaders.middleware.CorsMiddleware',
    'django.middleware.common.CommonMiddleware',
)

CORS_ALLOW_CREDENTIALS = True
CORS_ORIGIN_ALLOW_ALL = True
CORS_ORIGIN_WHITELIST = (
    '*'
)

CORS_ALLOW_METHODS = (
    'GET',
    'POST',
    'PUT',
    'PATCH',
    'DELETE',
    'OPTIONS'
    'VIEW',
)

CORS_ALLOW_HEADERS = (
    'XMLHttpRequest',
    'X_FILENAME',
    'accept-encoding',
    'authorization',
    'content-type',
    'dnt',
    'origin',
    'user-agent',
    'x-csrftoken',
    'x-requested-with',
    'Pragma',
)

SOCIALACCOUNT_PROVIDERS = {
    'telegram': {
        'TOKEN': 'insert-token-received-from-botfather'
    }
}

ROOT_URLCONF = 'mvote.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        #'DIRS': [os.path.join(BASE_DIR, 'templates')],
        'DIRS': [os.path.join('/data/', 'dist')],
        '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 = 'mvote.wsgi.application'


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

#D-parser-1.1.4-10.el7.x86_64.rpmATABASES = {
#    'default': {
#        'ENGINE': 'django.db.backends.sqlite3',
#        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
#    }
#}

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'mshop',
        'USER': 'root',
        'PASSWORD': 'raffaele',
        'HOST': '192.168.37.143',
        'PORT': '3306',
    }
}



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

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


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

SESSION_EXPIRE_AT_BROWSER_CLOSE = True

STATIC_URL = '/static/'
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static'),
]
STATIC_ROOT = "/data/mshop/staticfiles/"


#USERS_REGISTRATION_OPEN = True
#USERS_VERIFY_EMAIL = True
#USERS_AUTO_LOGIN_ON_ACTIVATION = True
#USERS_EMAIL_CONFIRMATION_TIMEOUT_DAYS = 3
#USERS_PASSWORD_MIN_LENGTH = 5
#USERS_PASSWORD_MAX_LENGTH = None
#USERS_CHECK_PASSWORD_COMPLEXITY = True
#USERS_SPAM_PROTECTION = False
#USERS_VALIDATE_EMAIL_DOMAIN = True
#
#EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
#
#EMAIL_USE_TLS = False
#EMAIL_HOST = 'smtp.mailgun.org'
#EMAIL_PORT = 25
#EMAIL_HOST_USER = 'postmaster@sandboxc1f4364d269b4be489924008c6831bdd.mailgun.org'
#EMAIL_HOST_PASSWORD = 'a6dba19783d2a7f3d796b10db0843bf5-bdd08c82-9e2f11ab'
#DEFAULT_FROM_EMAIL = 'postmaster@sandboxc1f4364d269b4be489924008c6831bdd.mailgun.org'

#EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
#EMAIL_HOST = 'smtp.exmail.qq.com'
#EMAIL_PORT = 465
#EMAIL_HOST_USER = 'raffaele_sama@raffaelesama.club'
#EMAIL_HOST_PASSWORD = 'RaffaeleLucifer5'
#EMAIL_USE_SSL = True 
#DEFAULT_FROM_EMAIL = 'raffaele_sama@raffaelesama.club'

LOGIN_REDIRECT_URL = '/'
EMAIL_USE_SSL = True
EMAIL_HOST = 'smtp.qq.com'
EMAIL_PORT = 465
EMAIL_HOST_USER = '1625504587@qq.com'
EMAIL_HOST_PASSWORD = 'yidzefcuswgebhgd'
DEFAULT_FROM_EMAIL = '1625504587@qq.com'

