Show the number of remaining available checks under "Add Check" button

when 10 or less remaining.
This commit is contained in:
Pēteris Caune 2018-05-30 14:52:11 +03:00
parent 7ced981d45
commit 6bf6ab6479
No known key found for this signature in database
GPG Key ID: E28D7679E9A9EDE2
3 changed files with 17 additions and 6 deletions

View File

@ -71,7 +71,7 @@ def my_checks(request):
"tags": pairs, "tags": pairs,
"ping_endpoint": settings.PING_ENDPOINT, "ping_endpoint": settings.PING_ENDPOINT,
"timezones": all_timezones, "timezones": all_timezones,
"can_add_more": len(checks) < request.team.check_limit, "num_available": request.team.check_limit - len(checks),
"sort": request.profile.sort "sort": request.profile.sort
} }

View File

@ -163,3 +163,9 @@
border-top: 1px solid #ddd; border-top: 1px solid #ddd;
} }
.add-check-note {
color: #888;
text-align: center;
margin-top: 10px;
font-size: 12px;
}

View File

@ -36,11 +36,16 @@
</div> </div>
<div class="row"> <div class="row">
<div class="col-sm-12"> <div class="col-sm-12">
{% if can_add_more %} {% if num_available > 0 %}
<form method="post" action="{% url 'hc-add-check' %}" class="text-center"> <form method="post" action="{% url 'hc-add-check' %}" class="text-center">
{% csrf_token %} {% csrf_token %}
<input type="submit" class="btn btn-primary btn-lg" value="Add Check"> <input type="submit" class="btn btn-primary btn-lg" value="Add Check">
</form> </form>
{% if num_available <= 10 %}
<div class="add-check-note">
({{ checks|length }} in use, {{ num_available }} available)
</div>
{% endif %}
{% else %} {% else %}
<div class="alert alert-info"> <div class="alert alert-info">
<strong>Check limit reached.</strong> <strong>Check limit reached.</strong>