36347-vm/core/views.py
2025-11-27 07:52:19 +00:00

35 lines
1.3 KiB
Python

import os
import platform
from django import get_version as django_version
from django.shortcuts import render
from django.utils import timezone
from .models import MachineModel, SparePart, ServiceIntervention
def index(request):
"""Render the landing screen with dashboard stats."""
host_name = request.get_host().lower()
agent_brand = "AppWizzy" if host_name == "appwizzy.com" else "Flatlogic"
now = timezone.now()
context = {
"project_name": "Nespresso Repair Assistant",
"agent_brand": agent_brand,
"django_version": django_version(),
"python_version": platform.python_version(),
"current_time": now,
"host_name": host_name,
"project_description": os.getenv("PROJECT_DESCRIPTION", "A guided tool for Nespresso machine repairs."),
"project_image_url": os.getenv("PROJECT_IMAGE_URL", ""),
"intervention_count": ServiceIntervention.objects.count(),
"spare_part_count": SparePart.objects.count(),
"machine_model_count": MachineModel.objects.count(),
"pending_interventions": ServiceIntervention.objects.filter(status='PENDING').count(),
}
return render(request, "core/index.html", context)
def article_detail(request):
return render(request, "core/article_detail.html")