# Create your views here.
from django.shortcuts import render_to_response
from models import *
from settings import TWITTER_ID
import twitter


def index(request):
    tApi = twitter.Api()
    statuses = tApi.GetUserTimeline(TWITTER_ID)
    boxes = SliderBox.objects.all()
    menuHeads = MenuHeading.objects.all()
    menus = []
    for m in menuHeads:
        d = {
            'name': m.name,
            'items': [{'name': item.name, 'url': item.url} for item in m.menuitem_set.all()]
        }
        menus.append(d)
    return render_to_response("noel/index.html", {
        'tweets': statuses[0:5],
        'boxes': boxes,
        'menus': menus
    })


      
