from django.shortcuts import render
from django.http import HttpResponse
from django.db.models import F
from django.views.decorators.csrf import csrf_exempt

from .models import Movie, Person


def home(request):
    context = {"sections": Movie.objects.home_pick()}
    return render(request, "home.html", context)


def search(request, prefix, query):
    context = {"movies": Movie.objects.get_movies(prefix, query)}
    return render(request, "search.html", context)


def about(request):
    context = {}
    return render(request, "about.html", context)


def bugs(request):
    context = {}
    return render(request, "bugs.html", context)


def movie(request, id):
    context = {"movie": Movie.objects.get_movie_by_id(id)}
    return render(request, "movie.html", context)
