# Generated using bugsink-create-conf --template=recommended
# This is the configuration for the recommended setup for Bugsink in production.

from bugsink.settings.default import *  # noqa
from bugsink.utils import deduce_allowed_hosts

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = "{{ secret_key }}"



# Note: the recommended setup uses a reverse proxy (i.e. Nginx) in front of the Django server. This is why we trust the
# X-Forwarded-Proto and X-Forwarded-Host headers. If you do not use a reverse proxy, you should remove these settings.
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')  # Note: slightly redundant, Gunicorn also does this.
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True


# In the recommended setup, the database is SQLite. The single (unix) user is named `bugsink` and we put the database in
# its home directory:
DATABASES["default"]["NAME"] = '/home/bugsink/db.sqlite3'
DATABASES["snappea"]["NAME"] = '/home/bugsink/snappea.sqlite3'


# The time-zone here is the default for display purposes (when no project/user configuration is used).
# You can change this at any time since datetime information is stored as UTC in the database.
# https://docs.djangoproject.com/en/4.2/ref/settings/#std-setting-TIME_ZONE
TIME_ZONE = 'UTC'  # alternatively, e.g. 'Europe/Amsterdam'


# In the recommended (production) setup, we use Snappea for background tasks.
SNAPPEA = {
    "TASK_ALWAYS_EAGER": False,
    "NUM_WORKERS": 4,

    "PID_FILE": "/home/bugsink/snappea/snappea.pid",
    "WAKEUP_CALLS_DIR": "/home/bugsink/snappea/wakeup",
}


# EMAIL_HOST = ...
# EMAIL_HOST_USER = ...
# EMAIL_HOST_PASSWORD = ...
# EMAIL_PORT = ...
# EMAIL_USE_TLS = ...

SERVER_EMAIL = DEFAULT_FROM_EMAIL = "Bugsink <bugsink@example.org>"

# constants for "create by" (user/team/project) settings
CB_ANYBODY = "CB_ANYBODY"
CB_MEMBERS = "CB_MEMBERS"
CB_ADMINS = "CB_ADMINS"
CB_NOBODY = "CB_NOBODY"


BUGSINK = {
    # The URL where the Bugsink instance is hosted. This is used in the email notifications and to construct DSNs.
    "BASE_URL": "https://{{ host }}",  # no trailing slash

    # you can customize this as e.g. "My Bugsink" or "Bugsink for My Company"
    "SITE_TITLE": "Bugsink",  

    # Settings for Users, Teams and Projects
    "SINGLE_USER": False,

    "USER_REGISTRATION": CB_MEMBERS,  # who can register new users. default: members, i.e. any user can invite others
    "USER_REGISTRATION_VERIFY_EMAIL": True,
    "USER_REGISTRATION_VERIFY_EMAIL_EXPIRY": 3 * 24 * 60 * 60,  # 7 days

    # if True, there is only one team, and all projects are in that team
    "SINGLE_TEAM": False,
    "TEAM_CREATION": CB_MEMBERS,  # who can create new teams. default: members, which means "any member of the site"

    # In the recommended setup, we do not digest events immediately, but instead offload this to Snappea. This ensures a
    # more response and reliable server when there are peak loads in the events.
    "DIGEST_IMMEDIATELY": False,

    # "MAX_EVENT_SIZE": _MEBIBYTE,
    # "MAX_EVENT_COMPRESSED_SIZE": 200 * _KIBIBYTE,
    # "MAX_ENVELOPE_SIZE": 100 * _MEBIBYTE,
    # "MAX_ENVELOPE_COMPRESSED_SIZE": 20 * _MEBIBYTE,

    "INGEST_STORE_BASE_DIR": "/home/bugsink/ingestion",
}

ALLOWED_HOSTS = deduce_allowed_hosts(BUGSINK["BASE_URL"])

# Alternatively, you can set the ALLOWED_HOSTS manually:
# ALLOWED_HOSTS = ["{{ host }}"]
