from django.utils.translation import gettext_lazy as _

from evibes.settings.base import getenv

CONSTANCE_BACKEND = "constance.backends.database.DatabaseBackend"  # Or "constance.backends.redis.RedisBackend"

CONSTANCE_ADDITIONAL_FIELDS = {
    "json": ["django.forms.fields.JSONField", {
        "required": False,
        "widget": "core.widgets.JSONTableWidget",
    }],
}

CONSTANCE_CONFIG = {
    "PROJECT_NAME": (getenv("EVIBES_PROJECT_NAME"), _("Name of the project")),
    "FRONTEND_DOMAIN": (getenv("EVIBES_FRONTEND_DOMAIN"), _("Frontend domain name")),
    "BASE_DOMAIN": (getenv("EVIBES_BASE_DOMAIN"), _("Base domain name")),
    "COMPANY_NAME": (getenv("COMPANY_NAME"), _("Name of the company")),
    "COMPANY_ADDRESS": (getenv("COMPANY_ADDRESS"), _("Address of the company")),
    "COMPANY_PHONE_NUMBER": (getenv("COMPANY_PHONE_NUMBER"), _("Phone number of the company")),
    "STOCKS_ARE_SINGLE": (getenv("STOCKS_ARE_SINGLE", True),
                          _("Designates whether every product has one stock or not")),
    "EMAIL_HOST": (getenv("EMAIL_HOST", "smtp.404.org"), _("SMTP host")),
    "EMAIL_PORT": (int(getenv("EMAIL_PORT", "465")), _("SMTP port")),
    "EMAIL_USE_TLS": (bool(int(getenv("EMAIL_USE_TLS", 0))), _("Use TLS (Specify 0 for No and 1 for Yes)")),
    "EMAIL_USE_SSL": (bool(int(getenv("EMAIL_USE_SSL", 1))), _("Use SSL (Specify 0 for No and 1 for Yes)")),
    "EMAIL_HOST_USER": (getenv("EMAIL_HOST_USER", "no-user@fix.this"), _("SMTP username")),
    "EMAIL_HOST_PASSWORD": (getenv("EMAIL_HOST_PASSWORD", "SUPERsecretPASSWORD"), _("SMTP password")),
    "EMAIL_FROM": (getenv("EMAIL_FROM", "eVibes"), _("Mail from option")),
    "PAYMENT_GATEWAY_URL": (getenv("PAYMENT_GATEWAY_URL", "http://404.org"), _("Payment gateway URL")),
    "PAYMENT_GATEWAY_TOKEN": (getenv("PAYMENT_GATEWAY_TOKEN", "example token"), _("Payment gateway token")),
    "PAYMENT_GATEWAY_MINIMUM": (getenv("PAYMENT_GATEWAY_MINIMUM", 5.0), _("Payment gateway minimum amount")),
    "PAYMENT_GATEWAY_MAXIMUM": (getenv("PAYMENT_GATEWAY_MAXIMUM", 500.0), _("Payment gateway maximum amount")),
    "EXCHANGE_RATE_API_KEY": (getenv("EXCHANGE_RATE_API_KEY", "example token"), _("Exchange rate API key")),
    "NOMINATIM_URL": (getenv("NOMINATIM_URL", ""), _("OpenStreetMap Nominatim API URL")),
    "OPENAI_API_KEY": (getenv("OPENAI_API_KEY", "example key"), _("OpenAI API Key")),
    "ABSTRACT_API_KEY": (
        getenv("ABSTRACT_API_KEY", "example key"),
        _("Abstract API Key, if empty - no Abstract features provided"),
    ),
    "HTTP_PROXY": (getenv("DJANGO_HTTP_PROXY", "http://username:password@proxy_address:port"), _("HTTP Proxy")),
    "DISABLED_COMMERCE": (getenv("DISABLED_COMMERCE", False), _("Disable buy functionality")),
    "ADVERTISEMENT_DATA": (
        getenv("EVIBES_ADVERTISEMENT_DATA", ""),
        _("An entity for storing advertisiment data"),
        "json",
    ),
    "ANALYTICS_DATA": (
        getenv("EVIBES_ANALYTICS_DATA", ""),
        _("An entity for storing analytics data"),
        "json",
    ),
}

EXPOSABLE_KEYS = [
    "PROJECT_NAME",
    "BASE_DOMAIN",
    "COMPANY_NAME",
    "COMPANY_ADDRESS",
    "COMPANY_PHONE_NUMBER",
    "EMAIL_HOST_USER",
    "EMAIL_FROM",
    "PAYMENT_GATEWAY_MINIMUM",
    "PAYMENT_GATEWAY_MAXIMUM",
    "ADVERTISIMENT_DATA",
    "ANALYTICS_DATA",
]
