Add full CRUD interface for Showcase management

Implemented complete web interface for managing showcases (display areas for ready-made bouquets) with:

**Backend:**
- ShowcaseForm with validation (unique name per warehouse)
- ShowcaseListView with filtering by warehouse and status
- ShowcaseCreateView, ShowcaseUpdateView with success messages
- ShowcaseDeleteView with active reservation validation
- URL routes: list, create, edit, delete

**Frontend:**
- List page with warehouse grouping, active reservations count
- Responsive table with filters (warehouse, status)
- Create/edit form with Bootstrap styling
- Delete confirmation with active reservations check
- Breadcrumb navigation

**Features:**
 One warehouse can have multiple showcases (ForeignKey relationship)
 Unique showcase names within each warehouse
 Display active reservation counts for each showcase
 Prevent deletion if showcase has active reservations
 Auto-select default warehouse when creating showcase
 Navigation link added to main navbar between "Касса" and "Склад"
 Active state highlighting in navigation

**Files created:**
- inventory/forms_showcase.py (ShowcaseForm)
- inventory/views/showcase.py (4 CBV views)
- inventory/templates/inventory/showcase/ (list, form, delete templates)

**Files modified:**
- inventory/urls.py (added showcase routes)
- inventory/forms.py (added Showcase import)
- templates/navbar.html (added "Витрины" link)

URL structure:
/inventory/showcases/ - list
/inventory/showcases/create/ - create
/inventory/showcases/<id>/edit/ - edit
/inventory/showcases/<id>/delete/ - delete

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-20 10:52:53 +03:00
parent 07c8819936
commit 766ca3c87c
8 changed files with 710 additions and 2 deletions

View File

@@ -0,0 +1,151 @@
{% extends "base.html" %}
{% block title %}{{ title }}{% endblock %}
{% block content %}
<div class="container-fluid">
<!-- Header -->
<div class="row mb-4">
<div class="col-12">
<h1 class="mb-2">
<i class="bi bi-flower1 text-primary me-2"></i>{{ form_title }}
</h1>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{% url 'inventory:inventory-home' %}">Склад</a></li>
<li class="breadcrumb-item"><a href="{% url 'inventory:showcase-list' %}">Витрины</a></li>
<li class="breadcrumb-item active">{{ form_title }}</li>
</ol>
</nav>
</div>
</div>
<!-- Form -->
<div class="row">
<div class="col-lg-8">
<div class="card">
<div class="card-body">
<form method="post" novalidate>
{% csrf_token %}
{% if form.non_field_errors %}
<div class="alert alert-danger">
{{ form.non_field_errors }}
</div>
{% endif %}
<!-- Name -->
<div class="mb-3">
<label for="{{ form.name.id_for_label }}" class="form-label fw-semibold">
{{ form.name.label }}
<span class="text-danger">*</span>
</label>
{{ form.name }}
{% if form.name.errors %}
<div class="invalid-feedback d-block">
{{ form.name.errors }}
</div>
{% endif %}
{% if form.name.help_text %}
<small class="form-text text-muted">{{ form.name.help_text }}</small>
{% endif %}
</div>
<!-- Warehouse -->
<div class="mb-3">
<label for="{{ form.warehouse.id_for_label }}" class="form-label fw-semibold">
{{ form.warehouse.label }}
<span class="text-danger">*</span>
</label>
{{ form.warehouse }}
{% if form.warehouse.errors %}
<div class="invalid-feedback d-block">
{{ form.warehouse.errors }}
</div>
{% endif %}
{% if form.warehouse.help_text %}
<small class="form-text text-muted">{{ form.warehouse.help_text }}</small>
{% endif %}
</div>
<!-- Description -->
<div class="mb-3">
<label for="{{ form.description.id_for_label }}" class="form-label fw-semibold">
{{ form.description.label }}
</label>
{{ form.description }}
{% if form.description.errors %}
<div class="invalid-feedback d-block">
{{ form.description.errors }}
</div>
{% endif %}
{% if form.description.help_text %}
<small class="form-text text-muted">{{ form.description.help_text }}</small>
{% endif %}
</div>
<!-- Is Active -->
<div class="mb-4">
<div class="form-check">
{{ form.is_active }}
<label class="form-check-label" for="{{ form.is_active.id_for_label }}">
{{ form.is_active.label }}
</label>
{% if form.is_active.help_text %}
<div><small class="form-text text-muted">{{ form.is_active.help_text }}</small></div>
{% endif %}
</div>
{% if form.is_active.errors %}
<div class="invalid-feedback d-block">
{{ form.is_active.errors }}
</div>
{% endif %}
</div>
<!-- Buttons -->
<div class="d-flex gap-2">
<button type="submit" class="btn btn-primary">
<i class="bi bi-check-circle me-1"></i>{{ submit_text }}
</button>
<a href="{% url 'inventory:showcase-list' %}" class="btn btn-secondary">
<i class="bi bi-x-circle me-1"></i>Отмена
</a>
</div>
</form>
</div>
</div>
</div>
<!-- Info Card (for edit mode) -->
{% if object %}
<div class="col-lg-4">
<div class="card">
<div class="card-header bg-light">
<h6 class="mb-0">Информация о витрине</h6>
</div>
<div class="card-body">
<dl class="row mb-0">
<dt class="col-sm-6">Создана:</dt>
<dd class="col-sm-6 text-end">{{ object.created_at|date:"d.m.Y H:i" }}</dd>
<dt class="col-sm-6">Обновлена:</dt>
<dd class="col-sm-6 text-end">{{ object.updated_at|date:"d.m.Y H:i" }}</dd>
{% if active_reservations_count is not None %}
<dt class="col-sm-6">Активные резервы:</dt>
<dd class="col-sm-6 text-end">
{% if active_reservations_count > 0 %}
<span class="badge bg-info">{{ active_reservations_count }}</span>
{% else %}
<span class="text-muted"></span>
{% endif %}
</dd>
{% endif %}
</dl>
</div>
</div>
</div>
{% endif %}
</div>
</div>
{% endblock %}