mezzanine_events/views.py
def event_grid(request, year, month):
    """
    Classic grid view of the occurrences for a given month.
    """
    year, month = int(year), int(month)
    current_month = datetime(year, month, 1)
    cal = Calendar(firstweekday=6).monthdatescalendar(year, month)  # Start on Sunday
    days_in_month = max(dt.day for dt in cal[-1])
    first_day = datetime.combine(cal[0][0], datetime.min.time())
    first_day = make_aware(first_day)
    last_day = datetime.combine(cal[-1][-1], datetime.max.time())
    last_day = make_aware(last_day)

    form = GridFilterForm(request.GET)
    occurrences = Occurrence.objects.published().select_related("event")
    if form.is_valid():
        occurrences = form.filter(occurrences)
    occurrence_tuples = occurrences.all_occurrences(first_day, last_day)

    by_day = dict((dt, list(occ)) for dt, occ in groupby(occurrence_tuples, get_date))
    context = {
        "today": today(),
        "filter_form": form,
        "filter_form_url": request.path,
        "current_month": current_month,
        "prev_month": current_month + timedelta(days=-1),
        "next_month": current_month + timedelta(days=+days_in_month),
        "calendar": [[(dt, by_day.get(dt, [])) for dt in week] for week in cal],
    }
    return render(request, "mezzanine_events/event_grid.html", context)

    Classic grid view of the occurrences for a given month.
    
Classic grid view of the occurrences for a given month.
Classic grid view of the occurrences for a given month .
def event_grid(request, year, month):
    year, month = int(year), int(month)
    current_month = datetime(year, month, 1)
    cal = Calendar(firstweekday=6).monthdatescalendar(year, month)  
    days_in_month = max(dt.day for dt in cal[-1])
    first_day = datetime.combine(cal[0][0], datetime.min.time())
    first_day = make_aware(first_day)
    last_day = datetime.combine(cal[-1][-1], datetime.max.time())
    last_day = make_aware(last_day)
    form = GridFilterForm(request.GET)
    occurrences = Occurrence.objects.published().select_related("event")
    if form.is_valid():
        occurrences = form.filter(occurrences)
    occurrence_tuples = occurrences.all_occurrences(first_day, last_day)
    by_day = dict((dt, list(occ)) for dt, occ in groupby(occurrence_tuples, get_date))
    context = {
        "today": today(),
        "filter_form": form,
        "filter_form_url": request.path,
        "current_month": current_month,
        "prev_month": current_month + timedelta(days=-1),
        "next_month": current_month + timedelta(days=+days_in_month),
        "calendar": [[(dt, by_day.get(dt, [])) for dt in week] for week in cal],
    }
    return render(request, "mezzanine_events/event_grid.html", context)
def event_grid ( request , year , month ) : year , month = int ( year ) , int ( month ) current_month = datetime ( year , month , 1 ) cal = Calendar ( firstweekday = 6 ) . monthdatescalendar ( year , month ) days_in_month = max ( dt . day for dt in cal [ - 1 ] ) first_day = datetime . combine ( cal [ 0 ] [ 0 ] , datetime . min . time ( ) ) first_day = make_aware ( first_day ) last_day = datetime . combine ( cal [ - 1 ] [ - 1 ] , datetime . max . time ( ) ) last_day = make_aware ( last_day ) form = GridFilterForm ( request . GET ) occurrences = Occurrence . objects . published ( ) . select_related ( "event" ) if form . is_valid ( ) : occurrences = form . filter ( occurrences ) occurrence_tuples = occurrences . all_occurrences ( first_day , last_day ) by_day = dict ( ( dt , list ( occ ) ) for dt , occ in groupby ( occurrence_tuples , get_date ) ) context = { "today" : today ( ) , "filter_form" : form , "filter_form_url" : request . path , "current_month" : current_month , "prev_month" : current_month + timedelta ( days = - 1 ) , "next_month" : current_month + timedelta ( days = + days_in_month ) , "calendar" : [ [ ( dt , by_day . get ( dt , [ ] ) ) for dt in week ] for week in cal ] , } return render ( request , "mezzanine_events/event_grid.html" , context )
Classic grid view of the occurrences for a given month.
Classic grid view of the occurrences for a given month .
"""
    Classic grid view of the occurrences for a given month.
    """ # Start on Sunday
request
year
month