Files
octopus/myproject/pos/urls.py
Andrey Smakotin eac778b06d Add Redis-based persistence for POS cart and customer selection
Implemented Redis caching with 2-hour TTL for POS session data:

Backend changes:
- Added Redis cache configuration in settings.py
- Created save_cart() endpoint to persist cart state
- Added cart and customer loading from Redis in pos_terminal()
- Validates cart items (products/kits) still exist in DB
- Added REDIS_HOST, REDIS_PORT, REDIS_DB to .env

Frontend changes:
- Added saveCartToRedis() with 500ms debounce
- Cart auto-saves on add/remove/quantity change
- Added cart initialization from Redis on page load
- Enhanced customer button with two-line display and reset button
- Red X button appears only for non-system customers

Features:
- Cart persists across page reloads (2 hour TTL)
- Customer selection persists (2 hour TTL)
- Independent cart per user+warehouse combination
- Automatic cleanup of deleted items
- Debounced saves to reduce server load

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 09:55:03 +03:00

28 lines
1.9 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
from django.urls import path
from . import views
app_name = 'pos'
urlpatterns = [
# POS терминал: главная страница (рендер HTML) [GET]
path('', views.pos_terminal, name='terminal'),
# Установить текущий склад для POS (сохранение в сессии) [POST]
path('api/set-warehouse/<int:warehouse_id>/', views.set_warehouse, name='set-warehouse'),
# Установить текущего клиента для POS (сохранение в Redis с TTL 2 часа) [POST]
path('api/set-customer/<int:customer_id>/', views.set_customer, name='set-customer'),
# Сохранить корзину POS (сохранение в Redis с TTL 2 часа) [POST]
path('api/save-cart/', views.save_cart, name='save-cart'),
# Получить товары и комплекты (пагинация, поиск, сортировка) [GET]
path('api/items/', views.get_items_api, name='items-api'),
# Получить список активных витрин [GET]
path('api/get-showcases/', views.get_showcases_api, name='get-showcases-api'),
# Получить актуальные витринные временные комплекты [GET]
path('api/showcase-kits/', views.get_showcase_kits_api, name='showcase-kits-api'),
# Получить детали комплекта для редактирования [GET]
path('api/product-kits/<int:kit_id>/', views.get_product_kit_details, name='get-product-kit-details'),
# Обновить временный комплект (состав, фото, цены) [POST]
path('api/product-kits/<int:kit_id>/update/', views.update_product_kit, name='update-product-kit'),
# Создать временный комплект и зарезервировать на витрину [POST]
path('api/create-temp-kit/', views.create_temp_kit_to_showcase, name='create-temp-kit-api'),
]