
def user(request):
    from django.template import RequestContext
    from models import Ticket,Queue
    from django.db.models import Q

    if not request.user.is_authenticated():
        return {}
    new  = len(Ticket.objects.filter(status=0))
    open = len(Ticket.objects.filter(~Q(status=0) & Q(done=False)))
    my   = len(Ticket.objects.filter(Q(resp=request.user.id) & ~Q(status=5)))
    queues = Queue.objects.all()

    return {'new' : new, 'open' : open, 'my' : my, 'queues': queues}
