def render_day(self, values, d, tracks, session_counters): from boost_consulting.utils.dom import tag as _, xml_snippet tracks = tracks or [Track('')] return xml_snippet( _.table( _class="schedule", summary="%s Schedule for %s" % (values.conference, d.strftime('%A, %B %d')) )[ _.caption[ d.strftime('%A, %B %d') ] , _.thead[ _.tr[ # time header _.th(scope="col" , width="%s%%" % (28 / len(tracks)) )['time'] # track headers , [ _.th( scope="col", width="%s%%" % (86 / len(tracks)) )[ _.strong[t.name] ] for t in tracks ] ] ] # </THEAD> , self.render_day_body(values, d, tracks, session_counters) ] )
def render_day_body( self, values, d, tracks, session_counters ): from boost_consulting.utils.dom import tag as _ body = _.tbody tracks = tracks or [Track('')] # Keeps track of active sessions in each track active = {} sessions = Session.objects \ .filter(start__start__gte=day_to_datetime(d)) for b in time_segments(values.conference,d): row = _.tr[ _.th(scope="row")[ format_time_range(b.start,b.finish) ] ] body <<= row if isinstance(b, Break): row <<= _.td(_class="break", colspan=len(tracks))['Break'] elif isinstance(b, TimeBlock): error = {} for s in sessions.filter(start=b): if s.track: existing = active.get(s.track) if existing: error[s.track] = (_.br, '*** overlapping with %s ***' % existing[0]) active[s.track] = s, s.duration else: if active: error[tracks[0]] = ( _.br , '*** overlapping with %s ***' % ', '.join([str(a[0]) for a in active.values()]) ) active = dict([ (t,(s,s.duration)) for t in tracks ]) for ti,t in enumerate(tracks): try: current,remaining = active[t] except: cell = _.td(valign="top")['nothing scheduled'] row <<= cell if not active: cell(colspan=len(tracks)) break else: continue if current.start == b: link_target = _.a(id='schedule.'+current.slug()) if current.schedule_note: title = current.title, ' ', current.schedule_note else: title = current.title session_counters[current.track] += 1 get_name = lambda p: p.full_name() continued = '' else: link_target = '' title = current.short_title get_name = lambda p: p.last_name # title = u'...%s...' % current.short_title continued = _.em[' (continued)'] cell_class = current.track and 'ud'[ti%2] or 'notrack' cell_class += str(1+session_counters[current.track]%2) if error.get(t): cell_class += ' error' error_msg = error.get(t,'') cell = _.td(valign="top", _class=cell_class)[ link_target # A sequence of presenter name, comma # pairs... except we make the first one a # colon. Then we reverse them to put the colon # at the end , [ ( _.a(href=values.presenter_base+p.slug()) [ _.span(_class="name")[get_name(p)] ] , (n and [', '] or [': '])[0] ) # Read the names in reverse alphabetical # order so they come out right in the end. for n, p in enumerate(current.presenters.order_by('-last_name', '-first_name')) ][::-1] # reverse , _.a(href=values.session_base+current.slug())[title] , continued , error_msg ] row <<= cell remaining -= (b.finish - b.start).seconds/60 if current.track: if remaining <= 0: del active[t] else: active[t] = current,remaining else: if remaining <= 0: active = {} else: active = dict([ (track,(current,remaining)) for track in tracks ]) cell(colspan = len(tracks)) break return body