Ejemplo n.º 1
0
def timeline_previous_events_json(request, earlier_than):
    """
    Returns a list of 25 events older than earlier_than (a event pk) in json
    format.
    """
    before = datetime.fromtimestamp(float(earlier_than))
    events = Event.objects.filter(date__lt=before) \
                          .order_by('-date')[:25]
    data = map(
        lambda e: {
            'pk': e.pk,
            'date': utcunixtimestamp(e.date),
            'message': e.get_message_for_display(),
            'task': e.get_task_for_display(),
            'comment': linebreaksbr(e.comment),
        }, events)

    new_earlier_than = -1  # signal end of data
    if events.count() > 0:
        new_earlier_than = utcunixtimestamp(events[events.count() - 1].date)

    return HttpResponse(
        simplejson.dumps({
            'events': data,
            'new_earlier_than': new_earlier_than,
        }))
Ejemplo n.º 2
0
def timeline_latest_events_json(request, start_after):
    """
    Returns a list of events newer than start_after (a event pk) in json format.
    """
    after = datetime.fromtimestamp(float(start_after))
    events = Event.objects.filter(date__gt=after) \
                          .order_by('date')
    data = map(
        lambda e: {
            'pk': e.pk,
            'date': utcunixtimestamp(e.date),
            'message': e.get_message_for_display(),
            'task': e.get_task_for_display(),
            'comment': linebreaksbr(e.comment),
        }, events)

    new_start_after = start_after
    if events.count() > 0:
        new_start_after = utcunixtimestamp(events[events.count() - 1].date)

    return HttpResponse(
        simplejson.dumps({
            'events': data,
            'new_start_after': new_start_after,
        }))
Ejemplo n.º 3
0
def timeline_index(request, template_name='timeline/index.html'):
    events = Event.objects.order_by('-date')[:50]

    new_start_after = datetime.now()
    if events.count() > 0:
        new_start_after = utcunixtimestamp(events[0].date)

    new_earlier_than = 0
    if events.count() > 0:
        new_earlier_than = utcunixtimestamp(events[events.count() - 1].date)

    return render_to_response(template_name, {
        'events': events,
        'new_start_after': new_start_after,
        'new_earlier_than': new_earlier_than
    },
                              context_instance=RequestContext(request))
Ejemplo n.º 4
0
def timeline_index(request,
                   template_name='timeline/index.html'):
    events = Event.objects.order_by('-date')[:50]

    new_start_after = datetime.now()
    if events.count() > 0:
        new_start_after = utcunixtimestamp(events[0].date)

    new_earlier_than = 0
    if events.count() > 0:
        new_earlier_than = utcunixtimestamp(events[events.count()-1].date)

    return render_to_response(template_name,
                              {'events': events,
                               'new_start_after': new_start_after,
                               'new_earlier_than': new_earlier_than},
                              context_instance=RequestContext(request))
Ejemplo n.º 5
0
def timeline_latest_events_json(request, start_after):
    """
    Returns a list of events newer than start_after (a event pk) in json format.
    """
    after = datetime.fromtimestamp(float(start_after))
    events = Event.objects.filter(date__gt=after) \
                          .order_by('date')
    data = map(lambda e: {
        'pk': e.pk, 'date': utcunixtimestamp(e.date),
        'message': e.get_message_for_display(),
        'task': e.get_task_for_display(),
        'comment': linebreaksbr(e.comment),
    }, events)

    new_start_after = start_after
    if events.count() > 0:
        new_start_after = utcunixtimestamp(events[events.count()-1].date)

    return HttpResponse(simplejson.dumps({
        'events': data,
        'new_start_after': new_start_after,
    }))
Ejemplo n.º 6
0
def timeline_previous_events_json(request, earlier_than):
    """
    Returns a list of 25 events older than earlier_than (a event pk) in json
    format.
    """
    before = datetime.fromtimestamp(float(earlier_than))
    events = Event.objects.filter(date__lt=before) \
                          .order_by('-date')[:25]
    data = map(lambda e: {
        'pk': e.pk, 'date': utcunixtimestamp(e.date),
        'message': e.get_message_for_display(),
        'task': e.get_task_for_display(),
        'comment': linebreaksbr(e.comment),
    }, events)

    new_earlier_than = -1 # signal end of data
    if events.count() > 0:
        new_earlier_than = utcunixtimestamp(events[events.count()-1].date)

    return HttpResponse(simplejson.dumps({
        'events': data,
        'new_earlier_than': new_earlier_than,
    }))