from django.shortcuts import render
from .models import Property
from transaction.models import Transaction
from django.shortcuts import get_object_or_404

# Create your views here.

def property_index(request, property_id):
  data = {}
  # Grab active property linked to the user
  property = get_object_or_404(Property,id=property_id)
  transactions = Transaction.objects.filter(property=property).order_by('-checkin')
  data['property'] = property
  data['transactions_active'] = transactions.filter(status=True)
  data['transactions_completed'] = transactions.filter(status=False)
  data['title'] = 'Parkings for #' + property_id
  return render(request, 'property/index.html', data)