Ejemplo n.º 1
0
def get_listable_events_all(offset,span):
    """
    Get upcoming events for a given number of weeks, including those not 
    yet meant to be shown publically.
    """
    begin = begin_week(datetime.today())+timedelta(days=7*offset)
    end = begin + timedelta(days=7*span)
    events = Event.objects.order_by('start').filter(finish__gte=begin)
    return (begin.date(),end.date(),events)
Ejemplo n.º 2
0
def events_list(request):
    if request.user.is_staff:
        begin,end,events = get_listable_events_all(0,10)
    else:
        begin,end,events = get_listable_events(0,10)

    lookup = defaultdict(lambda: [])
    for event in events:
       lookup[begin_week(event.start)].append(event)

    lookup = map(lambda (begin,events): (Week(begin),events),sorted(lookup.items()))
    return render_to_response('events/list.html', {
        'breadcrumbs': [('/','home'),('/events/','events')],
        'events':lookup,
        'future':future_events()
    },context_instance=RequestContext(request,{},[path_processor]))
Ejemplo n.º 3
0
def calendar(request,delta):
    '''
    Main Calendar view for website
    presents a Table of events for the current week, and 4 successors
    '''
    offset = int(delta)
    if request.user.is_staff:
        begin,end,events = get_listable_events_all(offset,4)
    else:
        begin,end,events = get_listable_events(offset,4)

    # lookup :: BEGIN_WEEK -> DAY -> EVENT
    lookup = defaultdict(lambda: defaultdict(lambda:[]))
    for event in events:
        for event_date in event.days():
            lookup[begin_week(event_date)][event_date.weekday()].append(event)

    # tidy information
    iter,events = begin,[]
    while iter <= end:
        week = lookup[iter]
        week_vals = []
        for i in range(0,7):
            iter_date = iter+timedelta(i)
            if (iter==begin and i==0) or iter_date.day==1:
                val = month(iter_date.month)
            else:
                val = ""
            week_vals.append((val+" "+str(iter_date.day),lookup[iter][i]))
        events.append((safe_week_for(iter),week_vals))
        iter += a_week

    return render_to_response('events/calendar.html',{
        'breadcrumbs': [('/','home'),('/events/','events'),('/events/calendar/','calendar')],
        'events':events,
        'current':date.today(),
        'prev':offset-1,
        'next':offset+1,
        'future':future_events(),
    },context_instance=RequestContext(request,{},[path_processor]))
Ejemplo n.º 4
0
def get_listable_events(offset,span):
    begin = begin_week(datetime.today())+timedelta(days=7*offset)
    end = begin + timedelta(days=7*span)
    events = Event.objects.order_by('start').filter(finish__gte=begin).exclude(displayFrom__gte=datetime.now())
    return (begin.date(),end.date(),events)