109 lines
4.0 KiB
Python
109 lines
4.0 KiB
Python
from django.urls import path, include
|
|
from rest_framework.routers import DefaultRouter
|
|
from . import api_views
|
|
|
|
# Router für ViewSets
|
|
router = DefaultRouter()
|
|
router.register(r'products', api_views.ProductViewSet, basename='api-product')
|
|
router.register(r'categories', api_views.CategoryViewSet, basename='api-category')
|
|
router.register(r'reviews', api_views.ReviewViewSet, basename='api-review')
|
|
router.register(r'wishlist', api_views.WishlistViewSet, basename='api-wishlist')
|
|
router.register(r'custom-orders', api_views.CustomOrderViewSet, basename='api-custom-order')
|
|
router.register(r'gallery', api_views.GalleryImageViewSet, basename='api-gallery')
|
|
router.register(r'cart', api_views.CartViewSet, basename='api-cart')
|
|
router.register(r'search', api_views.SearchViewSet, basename='api-search')
|
|
|
|
# API URL Patterns
|
|
urlpatterns = [
|
|
# Router URLs
|
|
path('', include(router.urls)),
|
|
|
|
# Zusätzliche API Endpoints
|
|
path('products/<int:pk>/add-to-wishlist/',
|
|
api_views.ProductViewSet.as_view({'post': 'add_to_wishlist'}),
|
|
name='api-product-add-to-wishlist'),
|
|
|
|
path('products/<int:pk>/remove-from-wishlist/',
|
|
api_views.ProductViewSet.as_view({'post': 'remove_from_wishlist'}),
|
|
name='api-product-remove-from-wishlist'),
|
|
|
|
path('products/featured/',
|
|
api_views.ProductViewSet.as_view({'get': 'featured'}),
|
|
name='api-products-featured'),
|
|
|
|
path('products/on-sale/',
|
|
api_views.ProductViewSet.as_view({'get': 'on_sale'}),
|
|
name='api-products-on-sale'),
|
|
|
|
path('products/low-stock/',
|
|
api_views.ProductViewSet.as_view({'get': 'low_stock'}),
|
|
name='api-products-low-stock'),
|
|
|
|
path('products/stats/',
|
|
api_views.ProductViewSet.as_view({'get': 'stats'}),
|
|
name='api-products-stats'),
|
|
|
|
path('categories/<int:pk>/products/',
|
|
api_views.CategoryViewSet.as_view({'get': 'products'}),
|
|
name='api-category-products'),
|
|
|
|
path('reviews/my-reviews/',
|
|
api_views.ReviewViewSet.as_view({'get': 'my_reviews'}),
|
|
name='api-my-reviews'),
|
|
|
|
path('wishlist/add-product/',
|
|
api_views.WishlistViewSet.as_view({'post': 'add_product'}),
|
|
name='api-wishlist-add-product'),
|
|
|
|
path('wishlist/remove-product/',
|
|
api_views.WishlistViewSet.as_view({'post': 'remove_product'}),
|
|
name='api-wishlist-remove-product'),
|
|
|
|
path('custom-orders/<int:pk>/update-status/',
|
|
api_views.CustomOrderViewSet.as_view({'post': 'update_status'}),
|
|
name='api-custom-order-update-status'),
|
|
|
|
path('gallery/featured/',
|
|
api_views.GalleryImageViewSet.as_view({'get': 'featured'}),
|
|
name='api-gallery-featured'),
|
|
|
|
path('gallery/by-product/',
|
|
api_views.GalleryImageViewSet.as_view({'get': 'by_product'}),
|
|
name='api-gallery-by-product'),
|
|
|
|
path('cart/get/',
|
|
api_views.CartViewSet.as_view({'get': 'get_cart'}),
|
|
name='api-cart-get'),
|
|
|
|
path('cart/add-item/',
|
|
api_views.CartViewSet.as_view({'post': 'add_item'}),
|
|
name='api-cart-add-item'),
|
|
|
|
path('cart/update-quantity/',
|
|
api_views.CartViewSet.as_view({'post': 'update_quantity'}),
|
|
name='api-cart-update-quantity'),
|
|
|
|
path('cart/remove-item/',
|
|
api_views.CartViewSet.as_view({'post': 'remove_item'}),
|
|
name='api-cart-remove-item'),
|
|
|
|
path('cart/clear/',
|
|
api_views.CartViewSet.as_view({'post': 'clear_cart'}),
|
|
name='api-cart-clear'),
|
|
|
|
path('search/products/',
|
|
api_views.SearchViewSet.as_view({'get': 'products'}),
|
|
name='api-search-products'),
|
|
]
|
|
|
|
# API Root
|
|
api_root = {
|
|
'products': 'api:product-list',
|
|
'categories': 'api:category-list',
|
|
'reviews': 'api:review-list',
|
|
'wishlist': 'api:wishlist-list',
|
|
'custom-orders': 'api:custom-order-list',
|
|
'gallery': 'api:gallery-list',
|
|
'cart': 'api:cart-list',
|
|
'search': 'api:search-list',
|
|
} |