Initial commit

This commit is contained in:
Alex
2026-10-07 19:57:07 +00:00
commit 6e6035c789
131 changed files with 23101 additions and 0 deletions
@@ -0,0 +1,26 @@
{% extends "base.html" %}
{% block title %}Ошибка распределения{% endblock %}
{% block content %}
<div class="page-header">
<h1>Ошибка распределения</h1>
</div>
<div class="alert alert-danger">
<h4 class="alert-heading">Ошибка при распределении Resource</h4>
<p><strong>{{ error }}</strong></p>
<hr>
<p class="mb-0">Пожалуйста, проверьте выбранные параметры и попробуйте снова.</p>
</div>
<div class="mt-4">
<a href="{{ url_for('resource_detail', resource_id=resource_id) }}" class="btn btn-primary">
Назад к Resource
</a>
<a href="{{ url_for('resources_list') }}" class="btn btn-secondary">
К пулу ресурсов
</a>
</div>
{% endblock %}
+33
View File
@@ -0,0 +1,33 @@
{% extends "base.html" %}
{% block title %}Resource allocated{% endblock %}
{% block content %}
<div class="page-header">
<h1>Resource успешно распределено!</h1>
</div>
<div class="alert alert-success">
<h4 class="alert-heading">Успех!</h4>
<p>Resource было успешно распределено.</p>
<hr>
<h5>Детали:</h5>
<ul>
<li>Resource ID: {{ resource_id }}</li>
<li>System: {{ allocation.system.name if allocation.system else 'N/A' }}</li>
<li>Guardian: {{ allocation.guardian.name if allocation.guardian else 'Общая часть' }}</li>
<li>Количество: <strong>{{ allocation.quantity }}</strong></li>
<li>Дата: {{ allocation.allocation_date.strftime('%Y-%m-%d') if allocation.allocation_date else 'N/A' }}</li>
</ul>
</div>
<div class="mt-4">
<a href="{{ url_for('resource_detail', resource_id=resource_id) }}" class="btn btn-primary">
К Resource
</a>
<a href="{{ url_for('resources_list') }}" class="btn btn-secondary">
К пулу ресурсов
</a>
</div>
{% endblock %}
+154
View File
@@ -0,0 +1,154 @@
{% extends "base.html" %}
{% block title %}Resource #{{ resource.id }}{% endblock %}
{% block content %}
<div class="page-header">
<h1>Resource #{{ resource.id }}</h1>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ url_for('home') }}">Главная</a></li>
<li class="breadcrumb-item"><a href="{{ url_for('resources_list') }}">Ресурсы</a></li>
<li class="breadcrumb-item active">#{{ resource.id }}</li>
</ol>
</nav>
</div>
<div class="row">
<div class="col-md-3">
<div class="card">
<div class="card-header bg-primary text-white">Получено</div>
<div class="card-body">
<h2 class="card-title">{{ resource.quantity }}</h2>
<p class="card-text">{{ resource.module.name if resource.module else 'N/A' }}</p>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card">
<div class="card-header bg-info text-white">Распределено</div>
<div class="card-body">
<h2 class="card-title">{{ allocations|length }}</h2>
<p class="card-text">Операций</p>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card">
<div class="card-header bg-success text-white">Остаток</div>
<div class="card-body">
<h2 class="card-title text-success">{{ remaining }}</h2>
<p class="card-text">Свободно</p>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card">
<div class="card-header bg-secondary text-white">Происхождение</div>
<div class="card-body">
<p class="card-text"><strong>Invoice:</strong> {{ resource.invoice_number or 'N/A' }}</p>
<p class="card-text"><strong>Specification:</strong> {{ resource.specification_number or 'N/A' }}</p>
</div>
</div>
</div>
</div>
<div class="section-title">Распределения (ResourceAllocations)</div>
<p class="text-muted">Resource находится в общем пуле проекта. Распределение выполняется через ResourceAllocation.</p>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>ID</th>
<th>System</th>
<th>Guardian</th>
<th>Количество</th>
<th>Дата</th>
<th>Описание</th>
</tr>
</thead>
<tbody>
{% for data in allocations %}
<tr>
<td>{{ data.allocation.id }}</td>
<td>{{ data.system.name if data.system else 'N/A' }}</td>
<td>
{% if data.is_common %}
<span class="badge bg-info">Общая часть</span>
{% else %}
<a href="{{ url_for('guardian_detail', guardian_id=data.guardian.id) }}">{{ data.guardian.name if data.guardian else 'N/A' }}</a>
{% endif %}
</td>
<td><strong>{{ data.allocation.quantity }}</strong></td>
<td>{{ data.allocation.allocation_date.strftime('%Y-%m-%d') if data.allocation.allocation_date else 'N/A' }}</td>
<td>{{ data.allocation.description or 'N/A' }}</td>
</tr>
{% else %}
<tr>
<td colspan="6" class="text-center">Нет распределений</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% if remaining > 0 %}
<div class="section-title">Распределить Resource</div>
<div class="card">
<div class="card-header">Новое распределение</div>
<div class="card-body">
<form action="{{ url_for('allocate_resource', resource_id=resource.id) }}" method="GET">
<div class="mb-3">
<label class="form-label">Свободно: <strong>{{ remaining }}</strong></label>
</div>
<div class="mb-3">
<label class="form-label" for="system_id">Система:</label>
<select class="form-select" name="system_id" id="system_id" required>
<option value="">-- Выберите систему --</option>
{% for system in resource.project.systems %}
<option value="{{ system.id }}">{{ system.name }} ({{ system.customer.name if system.customer else 'N/A' }})</option>
{% else %}
<option disabled>Нет систем в проекте</option>
{% endfor %}
</select>
</div>
<div class="mb-3">
<label class="form-label" for="guardian_id">Guardian (опционально):</label>
<select class="form-select" name="guardian_id" id="guardian_id">
<option value="">Общая часть (NULL)</option>
{% for system in resource.project.systems %}
{% for guardian in system.guardians %}
<option value="{{ guardian.id }}">{{ guardian.name }}</option>
{% endfor %}
{% else %}
<option disabled>Нет Guardian для выбора</option>
{% endfor %}
</select>
<small class="form-text text-muted">Оставьте пустым для распределения в общую часть</small>
</div>
<div class="mb-3">
<label class="form-label" for="quantity">Количество:</label>
<input type="number" class="form-control" name="quantity" id="quantity" min="1" max="{{ remaining }}" required>
</div>
<button type="submit" class="btn btn-primary">Распределить</button>
</form>
</div>
</div>
{% else %}
<div class="alert alert-warning">
Нет свободного ресурса для распределения.
</div>
{% endif %}
<div class="mt-4">
<a href="{{ url_for('resources_list', project_id=resource.project_id) }}" class="btn btn-secondary">
К пулу ресурсов
</a>
</div>
{% endblock %}
+83
View File
@@ -0,0 +1,83 @@
{% extends "base.html" %}
{% block title %}Ресурсы - Pool{% endblock %}
{% block content %}
<div class="page-header">
<h1>Общий пул ресурсов</h1>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ url_for('home') }}">Главная</a></li>
<li class="breadcrumb-item active">Ресурсы</li>
</ol>
</nav>
</div>
{% if project_id %}
<div class="alert alert-info">
Фильтр: Проект #{{ project_id }}
<a href="{{ url_for('resources_list') }}" class="btn btn-sm btn-link">Показать все</a>
</div>
{% endif %}
<div class="section-title">Сводка ресурсов</div>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>ID</th>
<th>Module</th>
<th>Получено</th>
<th>Распределено</th>
<th>Свободно</th>
<th>Invoice</th>
<th>Specification</th>
<th>Действие</th>
</tr>
</thead>
<tbody>
{% for resource in resources %}
<tr>
<td><a href="{{ url_for('resource_detail', resource_id=resource.id) }}">{{ resource.id }}</a></td>
<td>{{ resource.module.name if resource.module else 'N/A' }}</td>
<td>{{ resource.quantity }}</td>
<td>
{% set allocated = resource.resource_allocations|sum(attribute='quantity', default=0) %}
{{ allocated }}
</td>
<td>
{% set allocated = resource.resource_allocations|sum(attribute='quantity', default=0) %}
{% set remaining = resource.quantity - allocated %}
<span class="badge {% if remaining <= 0 %}bg-danger{% elif remaining < 100 %}bg-warning{% else %}bg-success{% endif %}">
{{ remaining }}
</span>
</td>
<td>{{ resource.invoice_number if resource.invoice_number else 'N/A' }}</td>
<td>{{ resource.specification_number if resource.specification_number else 'N/A' }}</td>
<td>
<a href="{{ url_for('resource_detail', resource_id=resource.id) }}" class="btn btn-sm btn-primary">
Открыть
</a>
</td>
</tr>
{% else %}
<tr>
<td colspan="8" class="text-center">Нет ресурсов</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="mt-4">
<a href="{{ url_for('projects_list') }}" class="btn btn-secondary">
К проектам
</a>
{% if not project_id %}
<a href="{{ url_for('seed_demo_data') }}" class="btn btn-success">
Seed demo data
</a>
{% endif %}
</div>
{% endblock %}