feat: add color, discount price, and new item attributes to catalog and update UI
All checks were successful
Build and Push Docker Image / build (push) Successful in 25s

- Introduced `Color` model with admin and added a color field to items
- Added `discount_price` and `is_new` fields to the `Item` model with necessary migrations
- Updated pricing logic to display original and discount prices in templates
- Enhanced product detail and item card templates with color swatches and metadata
- Added sidebar sections for sales and new items with paginated mini-cards
- Updated styles to support discount pricing, swatches, and sidebar mini-cards
- Extended catalog views to filter by sales or new items and updated filtering logic
This commit is contained in:
2026-05-25 18:10:32 +02:00
parent 81e30f853d
commit c42d32c76b
8 changed files with 342 additions and 38 deletions

View File

@@ -34,6 +34,12 @@
{% if selected_subcategory.id != None %}
<input type="hidden" name="subcategory" value="{{ selected_subcategory.id }}">
{% endif %}
{% if filter_sale %}
<input type="hidden" name="sale" value="1">
{% endif %}
{% if filter_new %}
<input type="hidden" name="new" value="1">
{% endif %}
<section class="a-section cost-section">
<h2>Стоимость</h2>
<div
@@ -86,13 +92,57 @@
<section class="a-section material-section">
<h2>Материал</h2>
</section>
<section class="a-section promotions-section">
<h2>Акции</h2>
</section>
<section class="a-section new-section">
<h2>Новинки</h2>
</section>
</form>
<section class="a-section promotions-section">
<h2>
<a href="{{ sale_all_url }}" class="sidebar-section-link{% if filter_sale %} active{% endif %}">Акции</a>
</h2>
{% for sale_item in sidebar_sale_items %}
<div class="sidebar-mini-card">
{% with img=sale_item.primary_image %}
{% if img %}
<a href="{% url 'detail' sale_item.category.slug sale_item.slug %}" class="sidebar-mini-card__img-link">
<img src="{{ img.image.url }}" alt="{{ img.alt|default:sale_item.name }}">
</a>
{% endif %}
{% endwith %}
<div class="sidebar-mini-card__body">
<a href="{% url 'detail' sale_item.category.slug sale_item.slug %}" class="sidebar-mini-card__name">{{ sale_item.name }}</a>
<span class="sidebar-mini-card__price">{{ sale_item.display_price }} руб.</span>
</div>
</div>
{% empty %}
<p class="categories-empty">Акций пока нет.</p>
{% endfor %}
{% if sidebar_sale_items %}
<a href="{{ sale_all_url }}" class="sidebar-more-link">Ещё</a>
{% endif %}
</section>
<section class="a-section new-section">
<h2>
<a href="{{ new_all_url }}" class="sidebar-section-link{% if filter_new %} active{% endif %}">Новинки</a>
</h2>
{% for new_item in sidebar_new_items %}
<div class="sidebar-mini-card">
{% with img=new_item.primary_image %}
{% if img %}
<a href="{% url 'detail' new_item.category.slug new_item.slug %}" class="sidebar-mini-card__img-link">
<img src="{{ img.image.url }}" alt="{{ img.alt|default:new_item.name }}">
</a>
{% endif %}
{% endwith %}
<div class="sidebar-mini-card__body">
<a href="{% url 'detail' new_item.category.slug new_item.slug %}" class="sidebar-mini-card__name">{{ new_item.name }}</a>
<span class="sidebar-mini-card__price">{{ new_item.display_price }} руб.</span>
</div>
</div>
{% empty %}
<p class="categories-empty">Новинок пока нет.</p>
{% endfor %}
{% if sidebar_new_items %}
<a href="{{ new_all_url }}" class="sidebar-more-link">Ещё</a>
{% endif %}
</section>
</aside>