from django.shortcuts import render, redirect
from django.contrib import messages
from .forms import BookingForm

def home(request):
    if request.method == 'POST':
        form = BookingForm(request.POST)
        if form.is_valid():
            form.save()
            messages.success(request, 'Thank you! Your booking request has been received. We will contact you shortly.')
            return redirect('home')
    else:
        form = BookingForm()

    context = {
        'form': form,
    }
    return render(request, 'core/index.html', context)