feat: implement shopping cart feature with user authentication support
All checks were successful
Build and Push Docker Image / build (push) Successful in 42s
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:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user