From 8b01acefe28f2cd8587f49f7bcc54e5a2247b6d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Fri, 17 Aug 2018 18:20:15 +0300 Subject: [PATCH] Show 20 most recent pings by default. --- hc/front/views.py | 19 +++++++++++-------- templates/front/log.html | 11 ++++------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/hc/front/views.py b/hc/front/views.py index c82e0fff..656e7ea3 100644 --- a/hc/front/views.py +++ b/hc/front/views.py @@ -208,7 +208,7 @@ def update_name(request, code): check.tags = form.cleaned_data["tags"] check.save() - if request.META.get("HTTP_REFERER", "").endswith("/log/"): + if "/log/" in request.META.get("HTTP_REFERER", ""): return redirect("hc-log", code) return redirect("hc-checks") @@ -245,7 +245,7 @@ def update_timeout(request, code): check.save() - if request.META.get("HTTP_REFERER", "").endswith("/log/"): + if "/log/" in request.META.get("HTTP_REFERER", ""): return redirect("hc-log", code) return redirect("hc-checks") @@ -305,7 +305,7 @@ def pause(request, code): check.status = "paused" check.save() - if request.META.get("HTTP_REFERER", "").endswith("/log/"): + if "/log/" in request.META.get("HTTP_REFERER", ""): return redirect("hc-log", code) return redirect("hc-checks") @@ -329,11 +329,15 @@ def log(request, code): if check.user != request.team.user: return HttpResponseForbidden() - limit = request.team.ping_log_limit + limit = 20 + team_limit = request.team.ping_log_limit + if "full_log" in request.GET: + limit = team_limit + pings = Ping.objects.filter(owner=check).order_by("-id")[:limit + 1] pings = list(pings) - num_pings = len(pings) + can_load_more = len(pings) > limit pings = pings[:limit] alerts = [] @@ -355,9 +359,8 @@ def log(request, code): "ping_endpoint": settings.PING_ENDPOINT, "channels": channels, "events": events, - "num_pings": min(num_pings, limit), - "limit": limit, - "show_limit_notice": num_pings > limit and settings.USE_PAYMENTS + "num_showing": len(pings), + "can_load_more": can_load_more } return render(request, "front/log.html", ctx) diff --git a/templates/front/log.html b/templates/front/log.html index e5652a58..58a1da1e 100644 --- a/templates/front/log.html +++ b/templates/front/log.html @@ -259,13 +259,10 @@ {% endfor %} - {% if show_limit_notice and limit < 1000 %} -

- Showing last {{ limit }} pings. - Want to see more? - - Upgrade your account! - + {% if can_load_more %} +

+ Showing {{ num_showing }} most recent pings. + Load More…

{% endif %}