# -*- coding: utf-8 -*-
import logging
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.template.response import TemplateResponse
from models import SimpleProduct, ComplexProduct

logger = logging.getLogger('ccbasket')

def home(request):
    return render_to_response('shop/home.html', {
        
    }, context_instance=RequestContext(request))


def product(request, pk, model=SimpleProduct, template='shop/product.html'):
    product = model.objects.get(pk=pk)
    
    return render_to_response(template, {
        'product': product
    }, context_instance=RequestContext(request))

def index(request):
    
    simple_products = SimpleProduct.objects.all()
    complex_products = ComplexProduct.objects.all()

    products = []

    for product in simple_products:
        products.append(product)

    for product in complex_products:
        products.append(product)

    return render_to_response('shop/index.html', {
        'products': products,
    }, context_instance=RequestContext(request))
