from django.shortcuts import render
from .models import Job

def home(request):
    # Create dummy jobs if none exist
    if not Job.objects.exists():
        Job.objects.create(title="Software Engineer", company_name="Tech Corp", location="San Francisco, CA", description="Job description here")
        Job.objects.create(title="Product Manager", company_name="Innovate Inc", location="New York, NY", description="Job description here")
        Job.objects.create(title="Data Scientist", company_name="Data Driven LLC", location="Austin, TX", description="Job description here")

    jobs = Job.objects.all()
    context = {
        'jobs': jobs
    }
    return render(request, 'core/index.html', context)