feat: implement shopping cart feature with user authentication support
All checks were successful
Build and Push Docker Image / build (push) Successful in 42s

- Added `Cart` and `CartItem` models with migrations for managing user-specific carts and items
- Developed services for cart-related operations: adding, removing, and updating cart items
- Built specialized templates (`cart.html`) and styled them with new CSS assets (`cart.css`)
- Enabled real-time UI updates via AJAX in shopping cart interactions (`cart.js`)
- Modified header to dynamically display cart link with user authentication awareness
- Added Leaflet-based interactive map to the contacts page and integrated CSS/JS dependencies
- Expanded tests for cart functionality, item detail page cart integration, and contacts page maps
This commit is contained in:
2026-05-15 23:18:16 +02:00
parent d2126e0fba
commit 52cbc1c2b3
22 changed files with 1317 additions and 18 deletions

View File

@@ -61,7 +61,28 @@
{% endif %}
<div class="product-summary__actions">
<button class="product-summary__button product-summary__button--primary" type="button">В корзину</button>
{% if item.id in cart_item_ids %}
<a class="product-summary__button product-summary__button--primary product-summary__button--link" href="{% url 'orders:cart' %}">
Перейти в корзину
</a>
{% elif request.user.is_authenticated %}
<form method="post" action="{% url 'orders:add' %}" class="product-summary__cart-form">
{% csrf_token %}
<input type="hidden" name="item_id" value="{{ item.id }}">
<input type="hidden" name="next" value="{{ request.get_full_path }}">
<button class="product-summary__button product-summary__button--primary" type="submit" {% if not item.is_available %}disabled{% endif %}>
В корзину
</button>
</form>
{% else %}
<a
class="product-summary__button product-summary__button--primary product-summary__button--link"
href="{% url 'users:login' %}?next={{ request.get_full_path|urlencode }}"
{% if not item.is_available %}aria-disabled="true"{% endif %}
>
В корзину
</a>
{% endif %}
<button class="product-summary__button product-summary__button--secondary" type="button">Купить</button>
</div>
</section>