diff --git a/hc/accounts/tests/test_login.py b/hc/accounts/tests/test_login.py index fba8ca86..92da015c 100644 --- a/hc/accounts/tests/test_login.py +++ b/hc/accounts/tests/test_login.py @@ -2,7 +2,7 @@ from django.contrib.auth.models import User from django.core import mail from django.test import TestCase from hc.api.models import Check - +from django.conf import settings class LoginTestCase(TestCase): @@ -24,7 +24,7 @@ class LoginTestCase(TestCase): # And email sent self.assertEqual(len(mail.outbox), 1) - self.assertEqual(mail.outbox[0].subject, 'Log in to healthchecks.io') + self.assertEqual(mail.outbox[0].subject, 'Log in to {0}'.format(getattr(settings, "SITE_NAME"))) # And check should be associated with the new user check_again = Check.objects.get(code=check.code) diff --git a/hc/accounts/tests/test_profile.py b/hc/accounts/tests/test_profile.py index ba7528cc..3d026c43 100644 --- a/hc/accounts/tests/test_profile.py +++ b/hc/accounts/tests/test_profile.py @@ -3,6 +3,7 @@ from django.core import mail from hc.test import BaseTestCase from hc.accounts.models import Member from hc.api.models import Check +from django.conf import settings class ProfileTestCase(BaseTestCase): @@ -21,7 +22,7 @@ class ProfileTestCase(BaseTestCase): # And an email should have been sent self.assertEqual(len(mail.outbox), 1) - expected_subject = 'Set password on healthchecks.io' + expected_subject = 'Set password on {0}'.format(getattr(settings, "SITE_NAME")) self.assertEqual(mail.outbox[0].subject, expected_subject) def test_it_creates_api_key(self): @@ -74,7 +75,7 @@ class ProfileTestCase(BaseTestCase): # And an email should have been sent subj = ('You have been invited to join' - ' alice@example.org on healthchecks.io') + ' alice@example.org on {0}'.format(getattr(settings, "SITE_NAME"))) self.assertEqual(mail.outbox[0].subject, subj) def test_add_team_member_checks_team_access_allowed_flag(self): diff --git a/hc/api/tests/test_list_checks.py b/hc/api/tests/test_list_checks.py index 5b1bbd3a..e2e5a922 100644 --- a/hc/api/tests/test_list_checks.py +++ b/hc/api/tests/test_list_checks.py @@ -1,6 +1,7 @@ import json from datetime import timedelta as td from django.utils.timezone import now +from django.conf import settings from hc.api.models import Check from hc.test import BaseTestCase @@ -47,7 +48,7 @@ class ListChecksTestCase(BaseTestCase): self.assertEqual(checks["Alice 1"]["last_ping"], self.now.isoformat()) self.assertEqual(checks["Alice 1"]["n_pings"], 1) self.assertEqual(checks["Alice 1"]["status"], "new") - pause_url = "http://localhost:8000/api/v1/checks/%s/pause" % self.a1.code + pause_url = "{0}/api/v1/checks/%s/pause".format(getattr(settings, "SITE_ROOT")) % self.a1.code self.assertEqual(checks["Alice 1"]["pause_url"], pause_url) next_ping = self.now + td(seconds=3600) diff --git a/hc/front/templatetags/hc_extras.py b/hc/front/templatetags/hc_extras.py index 3182cad3..cc1c073e 100644 --- a/hc/front/templatetags/hc_extras.py +++ b/hc/front/templatetags/hc_extras.py @@ -1,4 +1,5 @@ from django import template +from django.conf import settings register = template.Library() @@ -9,6 +10,7 @@ class Unit(object): self.plural = name + "s" self.nsecs = nsecs + MINUTE = Unit("minute", 60) HOUR = Unit("hour", MINUTE.nsecs * 60) DAY = Unit("day", HOUR.nsecs * 24) @@ -32,3 +34,18 @@ def hc_duration(td): result.append("%d %s" % (v, unit.plural)) return " ".join(result) + + +@register.simple_tag +def settings_value(name): + return getattr(settings, name, "") + + +@register.simple_tag +def site_name(): + return settings.SITE_NAME + + +@register.simple_tag +def site_root(): + return settings.SITE_ROOT diff --git a/hc/settings.py b/hc/settings.py index adecc237..025e6c49 100644 --- a/hc/settings.py +++ b/hc/settings.py @@ -121,6 +121,7 @@ USE_L10N = True USE_TZ = True SITE_ROOT = "http://localhost:8000" +SITE_NAME = "healthchecks.io" PING_ENDPOINT = SITE_ROOT + "/ping/" PING_EMAIL_DOMAIN = HOST STATIC_URL = '/static/' diff --git a/templates/accounts/check_token_submit.html b/templates/accounts/check_token_submit.html index 3102b6ae..fc8ae5ef 100644 --- a/templates/accounts/check_token_submit.html +++ b/templates/accounts/check_token_submit.html @@ -1,8 +1,9 @@ +{% load hc_extras %}
-