Exemple #1
0
def index(request):

    errors = Error.objects.all()

    # Filter by user email
    if request.GET.get('user', None):
        errors_pks = [e.error.pk for e in Event.objects.filter(logged_in_user_email=request.GET.get('user'))]
        errors = errors.filter(pk__in=errors_pks)

    errors = errors.order_by("-last_event")

    page = request.GET.get('page', 1)
    paginator = Paginator(errors, 20)
    try:
        errors = paginator.page(page)
    except PageNotAnInteger:
        errors = paginator.page(1)
    except EmptyPage:
        errors = paginator.page(paginator.num_pages)

    return render(request, "centaur/index.html", {"errors": errors})
Exemple #2
0
def error(request, error_id, limit=200):
    error = get_object_or_404(Error, pk=error_id)
    events = error.events.all().order_by("-created")[:limit]

    series = [
        timestamp(event.created.replace(minute=0, second=0, microsecond=0))
        for event in events
    ]

    page = request.GET.get('page', 1)
    paginator = Paginator(events, 1)
    try:
        events = paginator.page(page)
    except PageNotAnInteger:
        events = paginator.page(1)
    except EmptyPage:
        events = paginator.page(paginator.num_pages)

    return render(request, "centaur/error.html", {
        "error": error,
        "events": events,
        "series": series,
    })