<s> from django . shortcuts import render_to_response , get_object_or_404 , redirect <EOL> from django import forms <EOL> from django . template import RequestContext <EOL> from django . http import HttpResponseRedirect , HttpResponse <EOL> from django . core . urlresolvers import reverse <EOL> from livestream . models import Stream <EOL> import datetime <EOL> def current ( request ) : <EOL> '''<STR_LIT>''' <EOL> stream_list = Stream . objects . filter ( published = True , startDate__lt = datetime . datetime . now , endDate__gt = datetime . datetime . now ) . order_by ( '<STR_LIT>' ) <EOL> upcoming_streams_list = Stream . objects . filter ( published = True , endDate__gt = datetime . datetime . now ) . order_by ( '<STR_LIT>' ) [ : <NUM_LIT:5> ] <EOL> if not stream_list : <EOL> return redirect ( list ) <EOL> else : <EOL> return render_to_response ( '<STR_LIT>' , { '<STR_LIT>' : stream_list , '<STR_LIT>' : upcoming_streams_list } , <EOL> context_instance = RequestContext ( request ) ) <EOL> def list ( request ) : <EOL> '''<STR_LIT>''' <EOL> stream_list = Stream . objects . filter ( published = True , endDate__gt = datetime . datetime . now ) . order_by ( '<STR_LIT>' ) <EOL> return render_to_response ( '<STR_LIT>' , { '<STR_LIT>' : stream_list } , <EOL> context_instance = RequestContext ( request ) ) <EOL> def detail ( request , slug ) : <EOL> '''<STR_LIT>''' <EOL> stream = get_object_or_404 ( Stream , slug = slug ) <EOL> upcoming_streams_list = Stream . objects . filter ( published = True , endDate__gt = datetime . datetime . now ) . order_by ( '<STR_LIT>' ) [ : <NUM_LIT:5> ] <EOL> return render_to_response ( '<STR_LIT>' , { '<STR_LIT>' : stream , '<STR_LIT>' : upcoming_streams_list } , <EOL> context_instance = RequestContext ( request ) ) </s>
