Files
shoppy/web/urls.py
T
2026-03-17 14:03:51 +01:00

75 lines
2.6 KiB
Python

from django.conf.urls.i18n import i18n_patterns
from django.contrib.auth.decorators import login_required
from django.urls import path
from django.utils.text import gettext_lazy as _
from web.views.components import (
cart,
cart_dropdown,
list_customer_addresses_component,
list_products,
list_wishlisted_products,
update_customer_address,
user_info_component,
wishlist_button,
change_password_component,
)
from web.views.web import (
add_cart_item,
add_to_wishlist,
cart_detail,
category_view,
delete_cart_item,
delete_from_wishlist,
index,
manifest,
order_detail,
orders,
product_detail,
wishlist,
)
app_name = 'web'
i18n_resolvers = i18n_patterns(
path('', index, name='index'),
path(_('wishlist'), login_required(wishlist, login_url=_('/login/')), name='wishlist'),
path(_('categories/<str:slug>/'), category_view, name='category_view'),
path(_('products/<int:pk>/<str:slug>/'), product_detail, name='product_detail'),
path(_('cart/'), cart_detail, name='cart_detail'),
path(_('orders/'), login_required(orders, login_url=_('/login/')), name='orders'),
path(_('order/<str:uuid>/'), order_detail, name='order'),
)
urlpatterns = [
# components
path('web/components/products/', list_products, name='list_products'),
path('web/components/wishlist/', list_wishlisted_products, name='list_wishlisted_products'),
path('web/components/cart-dropdown/', cart_dropdown, name='cart_dropdown'),
path('web/components/cart/', cart, name='cart'),
path('web/components/wishlist-button/<int:pk>/', wishlist_button, name='wishlist_button'),
path(
'web/components/user-info/',
login_required(user_info_component, login_url=_('/login/')),
name='user_info_component',
),
path(
'web/components/change-password/',
login_required(change_password_component, login_url=_('/login/')),
name='change_password_component',
),
# api
path('web/add-cart-item/', add_cart_item, name='add_cart_item'),
path('web/delete-cart-item/<int:pk>/', delete_cart_item, name='delete_cart_item'),
path('web/add-to-wishlist/', add_to_wishlist, name='add_to_wishlist'),
path('web/delete-from-wishlist/<int:pk>/', delete_from_wishlist, name='delete_from_wishlist'),
path('web/customer-address/<int:pk>/', update_customer_address, name='update_customer_address'),
path('web/customer-addresses/', list_customer_addresses_component, name='list_customer_addresses_component'),
# manifest
path('manifest.json', manifest, name='manifest_json'),
]
for resolver in i18n_resolvers:
urlpatterns += resolver.url_patterns