Browse Source

Log page shows notice about reached ping log limit.

pull/29/head
Pēteris Caune 9 years ago
parent
commit
57b813677a
3 changed files with 22 additions and 5 deletions
  1. +2
    -1
      hc/accounts/admin.py
  2. +9
    -4
      hc/front/views.py
  3. +11
    -0
      templates/front/log.html

+ 2
- 1
hc/accounts/admin.py View File

@ -8,7 +8,8 @@ from hc.api.models import Channel, Check
@admin.register(Profile) @admin.register(Profile)
class ProfileAdmin(admin.ModelAdmin): 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"] search_fields = ["user__email"]
def email(self, obj): def email(self, obj):


+ 9
- 4
hc/front/views.py View File

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


+ 11
- 0
templates/front/log.html View File

@ -87,6 +87,17 @@
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</table> </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> </div>
{% else %} {% else %}
<div class="alert alert-info">Log is empty. This check has not received any pings yet.</div> <div class="alert alert-info">Log is empty. This check has not received any pings yet.</div>


Loading…
Cancel
Save