# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'elided'

MAILMAN_ARCHIVER_KEY = 'elided'

DEBUG = False

# The SITE_ID is the 0-based index of the Django site.  Often, site 0 is
# literally 'example.com' and your site which you add via the Django admin
# web UI is 1 but if you have, or had in the past, multiple sites, it may
# be different.
SITE_ID = 1

ADMINS = (
     ('Mailman Admin', 'mailman@localhost'),
)

# Hosts/domain names that are valid for this site; required if DEBUG is False
# See https://docs.djangoproject.com/en/1.9/ref/settings/#allowed-hosts
#ALLOWED_HOSTS = ['*']
ALLOWED_HOSTS = ['localhost',
                 '127.0.0.1',
                 'your.domain',
                 'your IP',
                ]

# And for BrowserID too, see
# http://django-browserid.rtfd.org/page/user/settings.html#django.conf.settings.BROWSERID_AUDIENCES
BROWSERID_AUDIENCES = [ "http://localhost",
                        "http://localhost:8000",
                        "http://127.0.0.1:8000",
                        "http://your.domain",
                        "https://localhost",
                        "https://localhost:8000",
                        "https://127.0.0.1:8000",
                        "https://your.domain",
                      ]


## Email confirmation / address activation
# Add a from-address for email-confirmation:
# EMAIL_CONFIRMATION_FROM = 'postmaster@example.org'
EMAIL_CONFIRMATION_FROM = 'you@your.domain'

# This is set to console in settings.py
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

MAILMAN_ARCHIVER_FROM = ('127.0.0.1',
                         '::1',
                         '::ffff:127.0.0.1',
                         'your_IP',
                        )

# The following overrides settings.py by commenting out
    # 'django_mailman3.lib.auth.fedora',
    # 'allauth.socialaccount.providers.openid',
    #'allauth.socialaccount.providers.twitter',
    #'allauth.socialaccount.providers.stackexchange',
# and uncommenting
#    'allauth.socialaccount.providers.facebook',
# YMMV
INSTALLED_APPS = (
    'hyperkitty',
    'postorius',
    'django_mailman3',
    # Uncomment the next line to enable the admin:
    'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
    # 'django.contrib.admindocs',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'rest_framework',
    'django_gravatar',
    'compressor',
    'haystack',
    'django_extensions',
    'django_q',
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    # 'django_mailman3.lib.auth.fedora',
    # 'allauth.socialaccount.providers.openid',
    'allauth.socialaccount.providers.github',
    'allauth.socialaccount.providers.gitlab',
    'allauth.socialaccount.providers.google',
    'allauth.socialaccount.providers.facebook',
    #'allauth.socialaccount.providers.twitter',
    #'allauth.socialaccount.providers.stackexchange',
)

DATABASES = {
    'default': {
        # 'ENGINE': 'django.db.backends.mysql', # Last part is one of 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'mailman',  # Example, change as needed
        # 'USER': 'mailman',
        'USER': 'elided',
        'PASSWORD': 'elided',
        'HOST': '127.0.0.1',   # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
        'PORT': '',            # Set to empty string for default.
    }
}


# Cache: use the local memcached server
CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
        'LOCATION': '127.0.0.1:11211',
    }
}


# If you're behind a proxy, use the X-Forwarded-Host header
# See https://docs.djangoproject.com/en/1.8/ref/settings/#use-x-forwarded-host
USE_X_FORWARDED_HOST = True
# And if your proxy does your SSL encoding for you, set SECURE_PROXY_SSL_HEADER
# see https://docs.djangoproject.com/en/1.5/ref/settings/#secure-proxy-ssl-header
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

# Use SSL when logged in. You need to enable the SSLRedirect middleware for
# this feature to work.
USE_SSL = True

TIME_ZONE = 'America/Los_Angeles'

SOCIALACCOUNT_PROVIDERS = {
    #'openid': {
    #    'SERVERS': [
    #        dict(id='yahoo',
    #             name='Yahoo',
    #             openid_url='http://me.yahoo.com'),
    #    ],
    #},
    'google': {
        'SCOPE': ['profile', 'email'],
        'AUTH_PARAMS': {'access_type': 'online'},
    },
    'facebook': {
       'METHOD': 'oauth2',
       'SCOPE': ['email'],
       'FIELDS': [
           'email',
           'name',
           'first_name',
           'last_name',
           'locale',
           'timezone',
           ],
       'VERSION': 'v2.12',
    },
    'gitlab': {
        'SCOPE': ['read_user'],
    },
}

COMPRESS_PRECOMPILERS = (
   ('text/x-scss', 'sass -t compressed {infile} {outfile}'),
   ('text/x-sass', 'sass -t compressed {infile} {outfile}'),
)
COMPRESS_OFFLINE = True
COMPRESS_ENABLED = True

# From Address for emails sent to users
DEFAULT_FROM_EMAIL = 'you@your.domain'
# From Address for emails sent to admins
SERVER_EMAIL = 'you@your.domain'
# Compatibility with Bootstrap 3
from django.contrib.messages import constants as messages
MESSAGE_TAGS = {
    messages.ERROR: 'danger'
}

POSTORIUS_TEMPLATE_BASE_URL = 'https://your.domain'

# maxking: Disable the funny thing hyperkitty does with Async task
# where a new one isn't scheduled if one already exists in
# in the queue. This *should* help with emails having bad
# thread_order but. So threads created after today (1-Mar 2019)
# should ideally not have bad thread order if my theory works.
HYPERKITTY_DISABLE_SINGLETON_TASKS = True

