Add initial Django project structure with cleaning app

- Created .gitignore to exclude Python-generated files and virtual environments.
- Added .python-version to specify Python version 3.13.
- Implemented models for Client, Brigade, Service, Order, and CompletedWork.
- Created Django admin configurations for managing models.
- Added management command to seed the database with test data.
- Created initial migrations for the models.
- Developed views and templates for listing and detailing orders, clients, and brigades.
- Set up URL routing for the cleaning app.
- Configured Django settings and WSGI/ASGI entry points.
- Added basic test structure in tests.py.
- Included project metadata in pyproject.toml and uv.lock.
This commit is contained in:
Dmitry
2026-05-16 16:09:37 +03:00
commit 97591a71ea
30 changed files with 867 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
from django.shortcuts import render, get_object_or_404, redirect
from django.http import HttpResponse
from django.utils import timezone
from .models import Brigade, Order, Client
def index(request):
return redirect('cleaning:order_list')
def order_list(request):
orders = Order.objects.order_by('date')
return render(request, 'cleaning/order_list.html', {'orders': orders})
def order_detail(request, order_id):
order = get_object_or_404(Order.objects.prefetch_related('completedwork_set__service'), pk=order_id)
return render(request, 'cleaning/order_detail.html', {'order': order})
# def brigade_detail(request, pk):
# brigade = get_object_or_404(Brigade, pk=pk)
# return render(request, 'cleaning/brigade_detail.html', {'brigade': brigade})
def brigade_detail(request, pk):
brigade = get_object_or_404(Brigade, pk=pk)
today = timezone.now().date()
active = brigade.orders.filter(date__gte=today).order_by('date') # type: ignore
completed = brigade.orders.filter(date__lt=today).order_by('-date') # type: ignore
return render(request, 'cleaning/brigade_detail.html', {
'brigade': brigade,
'active': active,
'completed': completed,
})
def client_detail(request, pk):
client = get_object_or_404(Client, pk=pk)
orders = client.orders.order_by('date') # type: ignore
return render(request, 'cleaning/client_detail.html', {'client': client})