"""
URL configuration for sandwitches project.

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/5.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""

from django.contrib import admin
from django.urls import path, include
from . import views
from .api import api
from django.conf.urls.i18n import i18n_patterns


import os
import sys


urlpatterns = [
    path("i18n/", include("django.conf.urls.i18n")),
    path("signup/", views.signup, name="signup"),
    path("admin/", admin.site.urls),
    path("api/", api.urls),
    path("media/<path:file_path>", views.media, name="media"),
    path("", views.index, name="index"),
]

urlpatterns += i18n_patterns(
    path("recipes/<slug:slug>/", views.recipe_detail, name="recipe_detail"),
    path("setup/", views.setup, name="setup"),
    path("recipes/<int:pk>/rate/", views.recipe_rate, name="recipe_rate"),
    prefix_default_language=True,
)

if "test" not in sys.argv or "PYTEST_VERSION" in os.environ:
    from debug_toolbar.toolbar import debug_toolbar_urls

    urlpatterns = [
        *urlpatterns,
    ] + debug_toolbar_urls()
