from django.shortcuts import render
from listings.models import Listing
from realtors.models import Realtor
from listings.choices import price_choices,bedroom_choices,state_choices
def index(request):
    listings=Listing.objects.order_by('-list_date').filter(is_published=True)[:3]
    context={
        'listings':listings,
        'state_choices':state_choices,
        'bedroom_choices':bedroom_choices,
        'price_choices':price_choices
    }
    return render( request, 'pages/index.html',context)


def about(request):
    #Get all the realtors
    realtors=Realtor.objects.order_by('-hire_date')
    #get mvp. in case its more thabn one seller of the month
    mvp_realtors= Realtor.objects.all().filter(is_mvp=True)
    print('past mvp_realtors')
    context={
        'realtors':realtors,
        'mvp_realtors':mvp_realtors
    }
    return render( request, 'pages/about.html', context)