# Copy from https://gitea.hostea.org/Hostea/dashboard/src/branch/master/dashboard/local_settings.example.py

"""
Django settings for dashboard project.

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

For more information on this file, see
https://docs.djangoproject.com/en/4.0/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.0/ref/settings/
"""
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
# A new SECRET_KEY can be generated by running the following command:
# openssl rand -hex  32
SECRET_KEY = "{{ hosteadashboard_secret_key }}"

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

CSRF_TRUSTED_ORIGINS = [
  'https://{{ hosteadashboard_host }}',
]

USE_X_FORWARDED_HOST = True
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

ALLOWED_HOSTS = [
  'localhost',
  '{{ hosteadashboard_host }}',
  'hosteadashboard.{{ domain }}',
  'gitea.{{ domain }}', # so gitea can send requests... but that should be a configuration using the hostgroup on which hosteadashboard is installed 
]

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

DATABASES = {
    "default": {
        "ENGINE": "django.db.backends.postgresql",
        "NAME": "{{ hosteadashboard_db_name }}",
        "USER": "{{ hosteadashboard_db_user }}",
        "PASSWORD": "{{ hosteadashboard_db_password }}",
        "HOST": "localhost",
        "PORT": "5432",
    }
}

## django-payments configuration

PAYMENT_HOST = "https://{{ hosteadashboard_host }}"
PAYMENT_VARIANTS = {
    "stripe": (
        "payments.stripe.StripeProvider",  # please don't change this
        {
            "secret_key": "{{ hosteadashboard_stripe_secret_key }}",
            "public_key": "{{ hosteadashboard_stripe_public_key }}",
        },
    )
}


### Dashbaord specific configuration options

HOSTEA = {
    "INSTANCE_MAINTAINER_CONTACT": "{{ hosteadashboard_instance_maintainer_contact }}",
    "ACCOUNTS": {
        "MAX_VERIFICATION_TOLERANCE_PERIOD": 60 * 60 * 24,  # in seconds
        "SUDO_TTL": 60 * 5,
    },
    "META": {
        "GITEA_INSTANCE": "https://{{ hostea_gitea }}",  # meta Gitea insatnce
	"GITEA_ADMIN_USER": "{{ gitea_user }}",
	"GITEA_ADMIN_PASSWORD": "{{ gitea_password }}",
        "GITEA_ORG_NAME": "{{ hostea_user }}",  # Organisation name on Hostea meta instance
        # Repository dedicated for handling support
        # ref: https://gitea.hostea.org/Hostea/july-mvp/issues/17
        "SUPPORT_REPOSITORY": "{{ hosteadashboard_support_repository }}",
	"WOODPECKER_HOST": "{{ woodpecker_host }}",
    },
    "INFRA": {
        "HOSTEA_REPO": {
            # where to clone the repository
            "PATH": "/srv/hosteadashboard/fleet",
            # Git remote URI of the repository
            "REMOTE": "git@{{ hostea_gitea }}:/{{ hostea_user }}/{{ hostea_project }}",
            # SSH key that can push to the Git repository remote mentioned above
            "SSH_KEY": "/srv/hostea/deploy",
        },
	"HOSTEA_DOMAIN": "{{ hostea_fleet_domain }}",
    },
}

# Please see EMAIL_* configuration options:
# https://docs.djangoproject.com/en/4.1/ref/settings/#email-host
EMAIL_HOST = "localhost"
EMAIL_USE_TLS = False
EMAIL_USE_SSL = False
EMAIL_PORT = 25
EMAIL_HOST_USER = None
EMAIL_HOST_PASSWORD = None
DEFAULT_FROM_EMAIL = '{{ hosteadashboard_from_email }}'

#
# https://github.com/Rhumbix/django-request-logging
#
# LOGGING = {
#     'version': 1,
#     'disable_existing_loggers': False,
#     'handlers': {
#         'console': {
#             'class': 'logging.StreamHandler',
#         },
#     },
#     'loggers': {
#         'django.request': {
#             'handlers': ['console'],
#             'level': 'DEBUG',  # change debug level as appropiate
#             'propagate': False,
#         },
#     },
# }
#
# MIDDLEWARE += ['request_logging.middleware.LoggingMiddleware']
#
# ../venv/bin/pip3 install django-request-logging
#
