feat: add favorites feature for users
All checks were successful
Build and Push Docker Image / build (push) Successful in 51s

- Implemented `Favorite` model with unique user-item constraint and timestamped records
- Added `favorites:index` and `favorites:toggle` views with AJAX support for toggling favorites
- Built templates and front-end assets for the favorites page and integration with item grids
- Extended header with favorites link and dynamic counter
- Added tests covering models, views, and templates for the favorites functionality
- Updated admin to enable management of favorites via Django admin interface
This commit is contained in:
2026-05-10 20:06:12 +02:00
parent 812065a34b
commit 29d8302a4f
30 changed files with 1042 additions and 65 deletions

View File

@@ -0,0 +1,39 @@
{% extends "_layouts/base.html" %}
{% load static %}
{% block title %}Избранное{% endblock %}
{% block add_css %}
<link rel="stylesheet" href="{% static "css/catalog.css" %}">
<link rel="stylesheet" href="{% static "css/favorites.css" %}">
{% endblock %}
{% block content %}
{% include "_fragments/header.html" with active="favorites" %}
{% include '_fragments/breadcrumbs.html' with url_1='/' text_1='Главная' url_2='/favorites/' text_2='Избранное' %}
<main class="container favorites-page" data-favorites-page>
<section class="favorites-hero">
<p class="favorites-kicker">Личный список</p>
<div class="favorites-hero__row">
<div>
<h1 class="favorites-title">Избранные товары</h1>
<p class="favorites-description">
Здесь собраны товары, которые вы хотите сохранить для быстрого возврата к ним позже.
</p>
</div>
<div class="favorites-counter">
<span class="favorites-counter__value" data-favorites-count-value>{{ favorite_count }}</span>
<span class="favorites-counter__label" data-favorites-count-label>товаров</span>
</div>
</div>
</section>
<section class="favorites-list" aria-label="Список избранных товаров">
{% include "_fragments/item-grid.html" with items=items empty_message="В избранном пока нет товаров." favorites_grid=True %}
</section>
</main>
{% include "_fragments/footer.html" %}
{% endblock %}