74 lines
2.3 KiB
Python
74 lines
2.3 KiB
Python
from django.urls import path
|
|
from django.conf.urls.i18n import i18n_patterns
|
|
from django.contrib.auth.decorators import login_required
|
|
from django.utils.text import gettext_lazy as _
|
|
from web.views.components import (
|
|
cart,
|
|
cart_dropdown,
|
|
list_products,
|
|
wishlist_button,
|
|
list_wishlisted_products,
|
|
)
|
|
from web.views.users import login, logout, my_account, register, reset_password
|
|
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,
|
|
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(_("order/<str:uuid>/"), order_detail, name="order"),
|
|
# users
|
|
path(_("login/"), login, name="login"),
|
|
path(_("logout/"), logout, name="logout"),
|
|
path(_("register/"), register, name="register"),
|
|
path(_("reset-password/"), reset_password, name="reset-password"),
|
|
path(_("my-account/"), my_account, name="my_account"),
|
|
)
|
|
|
|
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",
|
|
),
|
|
# 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",
|
|
),
|
|
# manifest
|
|
path("manifest.json", manifest, name="manifest_json"),
|
|
]
|
|
|
|
for resolver in i18n_resolvers:
|
|
urlpatterns += resolver.url_patterns
|