@ -0,0 +1,20 @@ | |||
from hc.test import BaseTestCase | |||
from hc.api.models import Check | |||
class BadgesTestCase(BaseTestCase): | |||
def test_it_shows_badges(self): | |||
self.client.login(username="[email protected]", password="password") | |||
Check.objects.create(user=self.alice, tags="foo a-B_1 baz@") | |||
Check.objects.create(user=self.bob, tags="bobs-tag") | |||
r = self.client.get("/accounts/profile/badges/") | |||
self.assertContains(r, "foo.svg") | |||
self.assertContains(r, "a-B_1.svg") | |||
# Expect badge URLs only for tags that match \w+ | |||
self.assertNotContains(r, "[email protected]") | |||
# Expect only Alice's tags | |||
self.assertNotContains(r, "bobs-tag.svg") |
@ -0,0 +1,24 @@ | |||
from hc.test import BaseTestCase | |||
class NotificationsTestCase(BaseTestCase): | |||
def test_it_saves_reports_allowed_true(self): | |||
self.client.login(username="[email protected]", password="password") | |||
form = {"reports_allowed": "on"} | |||
r = self.client.post("/accounts/profile/notifications/", form) | |||
assert r.status_code == 200 | |||
self.alice.profile.refresh_from_db() | |||
self.assertTrue(self.alice.profile.reports_allowed) | |||
def test_it_saves_reports_allowed_false(self): | |||
self.client.login(username="[email protected]", password="password") | |||
form = {} | |||
r = self.client.post("/accounts/profile/notifications/", form) | |||
assert r.status_code == 200 | |||
self.alice.profile.refresh_from_db() | |||
self.assertFalse(self.alice.profile.reports_allowed) |
@ -123,18 +123,3 @@ class ProfileTestCase(BaseTestCase): | |||
# to user's default team. | |||
self.bobs_profile.refresh_from_db() | |||
self.assertEqual(self.bobs_profile.current_team, self.bobs_profile) | |||
def test_it_shows_badges(self): | |||
self.client.login(username="[email protected]", password="password") | |||
Check.objects.create(user=self.alice, tags="foo a-B_1 baz@") | |||
Check.objects.create(user=self.bob, tags="bobs-tag") | |||
r = self.client.get("/accounts/profile/") | |||
self.assertContains(r, "foo.svg") | |||
self.assertContains(r, "a-B_1.svg") | |||
# Expect badge URLs only for tags that match \w+ | |||
self.assertNotContains(r, "[email protected]") | |||
# Expect only Alice's tags | |||
self.assertNotContains(r, "bobs-tag.svg") |
@ -0,0 +1,63 @@ | |||
{% extends "base.html" %} | |||
{% load compress staticfiles hc_extras %} | |||
{% block title %}Account Settings - {% site_name %}{% endblock %} | |||
{% block content %} | |||
<div class="row"> | |||
<div class="col-sm-12"> | |||
<h1 class="settings-title">Settings</h1> | |||
</div> | |||
</div> | |||
<div class="row"> | |||
<div class="col-sm-3"> | |||
<ul class="nav nav-pills nav-stacked"> | |||
<li><a href="{% url 'hc-profile' %}">Security</a></li> | |||
<li><a href="{% url 'hc-notifications' %}">Notifications</a></li> | |||
<li class="active"><a href="{% url 'hc-badges' %}">Badges</a></li> | |||
</ul> | |||
</div> | |||
<div class="col-sm-9"> | |||
<div class="panel panel-default"> | |||
<div class="panel-body settings-block"> | |||
<h2 class="settings-title">Status Badges</h2> | |||
<p id="badges-description"> | |||
healthchecks.io provides status badges for each of the tags | |||
you have used. The badges have public, but hard-to-guess | |||
URLs. If you wish, you can add them to your READMEs, | |||
dashboards or status pages. | |||
</p> | |||
{% if badge_urls %} | |||
<table class="badges table"> | |||
{% for badge_url in badge_urls %} | |||
<tr> | |||
<td> | |||
<img src="{{ badge_url }}" alt="" /> | |||
</td> | |||
<td> | |||
<code>{{ badge_url }}</code> | |||
</td> | |||
</tr> | |||
{% endfor %} | |||
</table> | |||
{% else %} | |||
<p> | |||
To get started with status badges, add some tags to | |||
your checks! | |||
</p> | |||
{% endif %} | |||
</div> | |||
</div> | |||
</div> | |||
</div> | |||
{% endblock %} | |||
{% block scripts %} | |||
{% compress js %} | |||
<script src="{% static 'js/jquery-2.1.4.min.js' %}"></script> | |||
<script src="{% static 'js/bootstrap.min.js' %}"></script> | |||
{% endcompress %} | |||
{% endblock %} |
@ -0,0 +1,58 @@ | |||
{% extends "base.html" %} | |||
{% load compress staticfiles hc_extras %} | |||
{% block title %}Account Settings - {% site_name %}{% endblock %} | |||
{% block content %} | |||
<div class="row"> | |||
<div class="col-sm-12"> | |||
<h1 class="settings-title">Settings</h1> | |||
</div> | |||
{% if messages %} | |||
<div class="col-sm-12"> | |||
{% for message in messages %} | |||
<p class="alert alert-{{ message.tags }}">{{ message }}</p> | |||
{% endfor %} | |||
</div> | |||
{% endif %} | |||
</div> | |||
<div class="row"> | |||
<div class="col-sm-3"> | |||
<ul class="nav nav-pills nav-stacked"> | |||
<li><a href="{% url 'hc-profile' %}">Account</a></li> | |||
<li class="active"><a href="{% url 'hc-notifications' %}">Notifications</a></li> | |||
<li><a href="{% url 'hc-badges' %}">Badges</a></li> | |||
</ul> | |||
</div> | |||
<div class="col-sm-6"> | |||
<div class="panel panel-default"> | |||
<div class="panel-body settings-block"> | |||
<h2>Monthly Reports</h2> | |||
<form method="post"> | |||
{% csrf_token %} | |||
<label> | |||
<input | |||
name="reports_allowed" | |||
type="checkbox" | |||
{% if profile.reports_allowed %} checked {% endif %}> | |||
Each month send me a summary of my checks | |||
</label> | |||
<button | |||
name="update_reports_allowed" | |||
type="submit" | |||
class="btn btn-default pull-right">Save</button> | |||
</form> | |||
</div> | |||
</div> | |||
</div> | |||
</div> | |||
{% endblock %} | |||
{% block scripts %} | |||
{% compress js %} | |||
<script src="{% static 'js/jquery-2.1.4.min.js' %}"></script> | |||
<script src="{% static 'js/bootstrap.min.js' %}"></script> | |||
{% endcompress %} | |||
{% endblock %} |