from django.contrib.auth.decorators import login_required from django.shortcuts import render from contacts.models import Contact from core.registry import collect_dashboard_context from leads.models import Lead @login_required def home(request): context = { "lead_count": Lead.objects.filter(status=Lead.Status.NEW).count(), "open_pipeline": Lead.objects.filter( status__in=[Lead.Status.NEW, Lead.Status.CONTACTED] ).count(), "contact_count": Contact.objects.count(), "recent_leads": Lead.objects.select_related("contact", "attribution").all()[:8], } context.update(collect_dashboard_context(request)) return render(request, "dashboard/home.html", context)