Skip to content

Commit

Permalink
Merge 0400dd3 into 8fb0855
Browse files Browse the repository at this point in the history
  • Loading branch information
valeria-chemtai committed May 17, 2017
2 parents 8fb0855 + 0400dd3 commit 3a4d9f9
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 2 deletions.
1 change: 1 addition & 0 deletions hc/front/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
urlpatterns = [
url(r'^$', views.index, name="hc-index"),
url(r'^checks/$', views.my_checks, name="hc-checks"),
url(r'^failedchecks/$', views.failedchecks, name="hc-failedchecks"),
url(r'^checks/add/$', views.add_check, name="hc-add-check"),
url(r'^checks/cron_preview/$', views.cron_preview),
url(r'^checks/([\w-]+)/', include(check_urls)),
Expand Down
32 changes: 32 additions & 0 deletions hc/front/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,38 @@ def my_checks(request):
return render(request, "front/my_checks.html", ctx)


def failedchecks(request):
q = Check.objects.filter(user=request.team.user).order_by("created")
checks = list(q)
failed_checks = list()

counter = Counter()
down_tags, grace_tags = set(), set()
for check in checks:
status = check.get_status()
if status == "down":
failed_checks.append(check)
for tag in check.tags_list():
if tag == "":
continue
counter[tag] += 1
down_tags.add(tag)
checks = failed_checks

ctx = {
"page": "failedchecks",
"checks": checks,
"now": timezone.now(),
"tags": counter.most_common(),
"down_tags": down_tags,
"grace_tags": grace_tags,
"ping_endpoint": settings.PING_ENDPOINT,
"timezones": all_timezones
}

return render(request, "front/failed_checks.html", ctx)


def _welcome_check(request):
check = None
if "welcome_code" in request.session:
Expand Down
13 changes: 11 additions & 2 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,17 @@
<div id="navbar" class="navbar-collapse collapse">
<ul id="nav-main-sections" class="nav navbar-nav">
{% if request.user.is_authenticated %}
<li {% if page == 'checks' %} class="active" {% endif %}>
<a href="{% url 'hc-checks' %}">Checks</a>
<li {% if page == 'checks' %} class="dropdown" {% endif %}>
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Checks</a>
<ul class="dropdown-menu">
<li><a href="{% url 'hc-checks' %}">All Checks</a></li>
<li {% if page == 'failedchecks' %} class="active" {% endif %}>
<a href="{% url 'hc-failedchecks' %}">Failed Checks</a>
</li>
</ul>
</li>



<li {% if page == 'channels' %} class="active" {% endif %}>
<a href="{% url 'hc-channels' %}">Integrations</a>
Expand All @@ -100,6 +108,7 @@
<a href="{% url 'hc-about' %}">About</a>
</li>
</ul>
</div>


{% if request.user.is_authenticated %}
Expand Down
13 changes: 13 additions & 0 deletions templates/front/failed_checks.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% extends "front/my_checks.html" %}
{% block check_title %}
<h1>
{% if request.team == request.user.profile %}
Failed Checks
{% else %}
{{ request.team.team_name }}
{% endif %}
</h1>
{% endblock %}

{% block add_check_button %}
{% endblock %}
5 changes: 5 additions & 0 deletions templates/front/my_checks.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
{% block content %}
<div class="row">
<div class="col-sm-12">
{% block check_title %}
<h1>
{% if request.team == request.user.profile %}
My Checks
{% else %}
{{ request.team.team_name }}
{% endif %}
</h1>
{% endblock %}
</div>
{% if tags %}
<div id="my-checks-tags" class="col-sm-12">
Expand All @@ -32,6 +34,7 @@ <h1>

<div class="row">
<div class="col-sm-12">

{% if checks %}
{% include "front/my_checks_mobile.html" %}
{% include "front/my_checks_desktop.html" %}
Expand All @@ -40,6 +43,7 @@ <h1>
{% endif %}
</div>
</div>
{% block add_check_button %}
<div class="row">
<div class="col-sm-12">
<form method="post" action="{% url 'hc-add-check' %}" class="text-center">
Expand All @@ -48,6 +52,7 @@ <h1>
</form>
</div>
</div>
{% endblock %}

<div id="update-name-modal" class="modal">
<div class="modal-dialog">
Expand Down

0 comments on commit 3a4d9f9

Please sign in to comment.