# Path: livestream/models.py
# class Stream(models.Model):
#     ''' This is the model for each live stream event nothing really special
#     except for the iframe field maybe. It contains the loaded iframe for 
#     each stream event and is marked as safe. Maybe we change this or add
#     support for streams directly loaded into Projekktor'''
#     title = models.CharField("Stream-Titel",max_length=200)
#     slug = AutoSlugField(populate_from='title',unique=True)
#     startDate = models.DateTimeField("Start der Veranstaltung")
#     endDate = models.DateTimeField("Ende der Veranstaltung")
#     description = models.TextField("Beschreibung")
#     link = models.URLField("Link",blank=True,verify_exists=False)
#     rtmpLink = models.URLField("RTMP Link",blank=True,verify_exists=False)
#     audioOnlyLink = models.URLField("Audio-only Link",blank=True,verify_exists=False)
#     iframe = models.TextField("iFrame des Streams")
#     published = models.BooleanField()
#     created = models.DateTimeField(auto_now_add=True)
#     modified = models.DateTimeField(auto_now=True)
#     def __unicode__(self):
#         return self.title
#     def get_absolute_url(self):
#         return "/stream/%s/" % self.slug
#     def display_iFrameSafeField(self): 
#         return mark_safe(self.iframe)


from django.shortcuts import render_to_response, get_object_or_404, redirect
from django import forms
from django.template import RequestContext
from django.http import HttpResponseRedirect, HttpResponse
from django.core.urlresolvers import reverse
from livestream.models import Stream
import datetime




def current(request):
    ''' This view gets all streams that are scheduled to be live right now
    if there are no streams it redirects to the liste view. The upcoming_streams_list
    is used to show upcoming events in a side bar (see the template)'''
    stream_list = Stream.objects.filter(published=True,startDate__lt=datetime.datetime.now, endDate__gt=datetime.datetime.now).order_by('-startDate')

# Path: livestream/models.py
# class Stream(models.Model):
#     ''' This is the model for each live stream event nothing really special
#     except for the iframe field maybe. It contains the loaded iframe for 
#     each stream event and is marked as safe. Maybe we change this or add
#     support for streams directly loaded into Projekktor'''
#     title = models.CharField("Stream-Titel",max_length=200)
#     slug = AutoSlugField(populate_from='title',unique=True)
#     startDate = models.DateTimeField("Start der Veranstaltung")
#     endDate = models.DateTimeField("Ende der Veranstaltung")
#     description = models.TextField("Beschreibung")
#     link = models.URLField("Link",blank=True,verify_exists=False)
#     rtmpLink = models.URLField("RTMP Link",blank=True,verify_exists=False)
#     audioOnlyLink = models.URLField("Audio-only Link",blank=True,verify_exists=False)
#     iframe = models.TextField("iFrame des Streams")
#     published = models.BooleanField()
#     created = models.DateTimeField(auto_now_add=True)
#     modified = models.DateTimeField(auto_now=True)
#     def __unicode__(self):
#         return self.title
#     def get_absolute_url(self):
#         return "/stream/%s/" % self.slug
#     def display_iFrameSafeField(self): 
#         return mark_safe(self.iframe)


# Path: livestream/views.py
from django.shortcuts import render_to_response, get_object_or_404, redirect
from django import forms
from django.template import RequestContext
from django.http import HttpResponseRedirect, HttpResponse
from django.core.urlresolvers import reverse
from livestream.models import Stream
import datetime





def current(request):
    ''' This view gets all streams that are scheduled to be live right now
    if there are no streams it redirects to the liste view. The upcoming_streams_list
    is used to show upcoming events in a side bar (see the template)'''
    stream_list = Stream.objects.filter(published=True,startDate__lt=datetime.datetime.now, endDate__gt=datetime.datetime.now).order_by('-startDate')

    upcoming_streams_list = Stream.objects.filter(published=True,endDate__gt=datetime.datetime.now).order_by('-startDate')[:5]