Log page shows notice about reached ping log limit.

This commit is contained in:
Pēteris Caune 2016-01-11 12:27:57 +02:00
parent 68fe11a41b
commit 57b813677a
3 changed files with 22 additions and 5 deletions

View File

@ -8,7 +8,8 @@ from hc.api.models import Channel, Check
@admin.register(Profile)
class ProfileAdmin(admin.ModelAdmin):
list_display = ("id", "email", "reports_allowed", "next_report_date")
list_display = ("id", "email", "reports_allowed", "next_report_date",
"ping_log_limit")
search_fields = ["user__email"]
def email(self, obj):

View File

@ -215,19 +215,24 @@ def log(request, code):
# Fill in "missed ping" placeholders:
expected_date = older.created + check.timeout
limit = 0
while expected_date + check.grace < newer.created and limit < 10:
n_blanks = 0
while expected_date + check.grace < newer.created and n_blanks < 10:
wrapped.append({"placeholder_date": expected_date})
expected_date = expected_date + check.timeout
limit += 1
n_blanks += 1
# Prepare early flag for next ping to come
early = older.created + check.timeout > newer.created + check.grace
reached_limit = len(pings) > limit
wrapped.reverse()
ctx = {
"check": check,
"pings": wrapped
"pings": wrapped,
"num_pings": len(pings),
"limit": limit,
"show_limit_notice": reached_limit and settings.USE_PAYMENTS
}
return render(request, "front/log.html", ctx)

View File

@ -87,6 +87,17 @@
{% endif %}
{% endfor %}
</table>
{% if show_limit_notice and limit < 10000 %}
<p class="alert alert-info">
<strong>Showing last {{ limit }} pings.</strong>
Want to see more?
<a href="{% url 'hc-pricing' %}">
Upgrade your account!
</a>
</p>
{% endif %}
</div>
{% else %}
<div class="alert alert-info">Log is empty. This check has not received any pings yet.</div>