"""
URL configuration for the Dashboard app's passthrough views.
This module registers URL patterns for the prompt passthrough sub-application
of the dashboard. Its api, the providers list, is in the web console's api, at
``/api/web/dashboard/passthrough/``: see :mod:`.api.urls`. Registration is conditional on the
``SMARTER_APP_DASHBOARD_PASSTHROUGH_PROMPT_ENABLE`` setting: when disabled, no routes are
registered and an informational log message is emitted.
Attributes:
app_name (str): The Django application namespace, taken from
:data:`~smarter.apps.dashboard.views.passthrough.const.namespace`.
urlpatterns (list): The list of URL patterns registered for this app.
Empty when ``smarter_settings.app_dashboard_passthrough_prompt_enable`` is
``False``.
Classes:
PassthroughReverseNames: Convenience class that centralises the
``reverse()`` name strings used by this URL configuration.
Example:
Include these URLs from a parent URL configuration::
from django.urls import path
urlpatterns = [
path("passthrough/", include("smarter.apps.dashboard.views.passthrough.urls")),
]
"""
from django.urls import path
from smarter.common.conf import smarter_settings
from smarter.common.mixins.helper_mixin import SmarterReadyState
from smarter.common.utils import to_snake_case
from smarter.lib import logging
from .const import namespace
from .view import PromptPassthroughView
app_name = namespace
logger = logging.getSmarterLogger(__name__)
[docs]
class PassthroughReverseNames:
"""A class to hold the namespace for the passthrough views in the dashboard app."""
namespace = namespace
view = to_snake_case(PromptPassthroughView.__name__)
urlpatterns = []
if smarter_settings.app_dashboard_passthrough_prompt_enable:
urlpatterns = [
path("", PromptPassthroughView.as_view(), name=PassthroughReverseNames.view),
]
logger.debug(
"%s app passthrough url endpoint is %s. Set env 'SMARTER_APP_DASHBOARD_PASSTHROUGH_PROMPT_ENABLE' to 'false' to disable.",
app_name,
SmarterReadyState.READY,
)
else:
logger.info(
"%s app passthrough url endpoint is %s. Set env 'SMARTER_APP_DASHBOARD_PASSTHROUGH_PROMPT_ENABLE' to 'true' to enable.",
app_name,
SmarterReadyState.NOT_READY,
)