def test_flattens_date(self):
        from datetime import datetime, timedelta
        now = datetime.now()
        cap = datetime.now() + timedelta(days=4)
        results = generate_datetime_radius(now, 2, (0, 30))
        for i in results:
            self.assertEqual((i.hour, i.minute), (0, 30))

        results = generate_datetime_radius(now, 2)
        for i in results:
            self.assertEqual((i.hour, i.minute), (0, 0))
 def test_in_order(self):
     from datetime import datetime, timedelta
     from copy import copy
     now = datetime.now()
     results = generate_datetime_radius(now, 2)
     original_results = copy(results)
     results.sort()
     self.assertEqual(results, original_results)
def event_detail_context(request, slug, year=None, month=None, day=None):
    when = get_when_or_now(year, month, day) 
    event = get_object_or_404(Event, date__exact=when, slug=slug)
    ctxt = {
        'when':when,
        'event':event,
        'week':generate_datetime_radius(when, 3) 
    }
    return ctxt
def events_for_day_context(request, year=None, month=None, day=None):
    when = get_when_or_now(year, month, day).date()
    events = Event.objects.filter(date=when)
    ctxt = {
        'when':when,
        'events':events,
        'day':when,
        'week':generate_datetime_radius(when, 3) 
    }
    return ctxt
def events_for_location_context(request, slug):
    when = datetime.datetime.now()
    location = get_object_or_404(Location, slug=slug)
    events = Event.objects.filter(location=location)
    ctxt = {
        'when':when,
        'events':events,
        'location':location,
        'week':generate_datetime_radius(when, 3) 
    }
    return ctxt
Example #6
0
def events_for_location_context(request, slug):
    when = datetime.datetime.now()
    location = get_object_or_404(Location, slug=slug)
    events = Event.objects.filter(location=location)
    ctxt = {"when": when, "events": events, "location": location, "week": generate_datetime_radius(when, 3)}
    return ctxt
Example #7
0
def events_for_day_context(request, year=None, month=None, day=None):
    when = get_when_or_now(year, month, day)
    events = Event.objects.filter(date=when)
    ctxt = {"when": when, "events": events, "day": when, "week": generate_datetime_radius(when, 3)}
    return ctxt
 def test_length_works(self):
     from datetime import datetime, timedelta
     now = datetime.now()
     for i in range(0, 4):
         results = generate_datetime_radius(now, i)
         self.assertEqual(1 + i*2, len(results))