I have it rendering a schedule:
Using the following bit of code:
Code: Select all
..... # Create the listings data.
chandata = []
for channel in schedule.models.Channel.objects.order_by('alias'):
chan = {'name':channel.alias, 'icon':channel.icon}
programs = []
for program in channel.program_set.filter(
stop__gt=schstart + tablestep).filter(
start__lt=schstop).order_by('start'):
programs.append(
{'progobj':program, 'colspan':program.colspan(
tablestep, schstart, schstop)})
#TODO Need to do some schedule overlap checking and stuff.....
#TODO this assumes that they are just back to back
chan['programs'] = programs
chandata.append(chan)
datadict['chandata'] = chandata
return render_to_response('schedule/index.html', datadict)
So, here's what I want to add... and have yet to figure out a good, efficient way to pull it off:
I want to add both filter and exclude abilities to the table, while maintaining the basic table structure.
So, Imagine that I click on a "filter" link for "The Voice" - from there I want the server to render a new table, showing only "The Voice" shows. Now, if I just stuck with the same time frame and channels it'd be pretty easy... but also pretty useless.
So, when the table renders, I want the following to happen: I want the time scale to be able to break up into time portions that matter, I want the programs to compress, and I want channels with no matches to drop out... all in a decently clean and cheap algorithm, generating something like this:
I'm having trouble figuring a good way to code this up. I guess maybe I just have to live with it being fairly expensive... every time I come at it, I end up in a place where I need to cycle over the array a couple times; first building up a table that's bigger than it needs to be, then compressing it down and truncating it to a reasonable length.
Anyone have any brilliant ideas of how I should approach it?