forked from GithubBackups/healthchecks
Link integration setup instructions from the welcome page (only the ones that don't require authentication: Slack, Pushover, PagerDuty Connect, Telegram)
This commit is contained in:
parent
29e016d0fc
commit
dab15c3b8c
@ -1,9 +1,11 @@
|
||||
from django.core import signing
|
||||
from django.test.utils import override_settings
|
||||
from hc.api.models import Channel
|
||||
from hc.test import BaseTestCase
|
||||
from mock import patch
|
||||
|
||||
|
||||
@override_settings(TELEGRAM_TOKEN="fake-token")
|
||||
class AddTelegramTestCase(BaseTestCase):
|
||||
url = "/integrations/add_telegram/"
|
||||
|
||||
@ -12,6 +14,14 @@ class AddTelegramTestCase(BaseTestCase):
|
||||
r = self.client.get(self.url)
|
||||
self.assertContains(r, "start@ExampleBot")
|
||||
|
||||
@override_settings(TELEGRAM_TOKEN=None)
|
||||
def test_it_requires_token(self):
|
||||
payload = signing.dumps((123, "group", "My Group"))
|
||||
|
||||
self.client.login(username="alice@example.org", password="password")
|
||||
r = self.client.get(self.url + "?" + payload)
|
||||
self.assertEqual(r.status_code, 404)
|
||||
|
||||
def test_it_shows_confirmation(self):
|
||||
payload = signing.dumps((123, "group", "My Group"))
|
||||
|
||||
|
@ -29,11 +29,11 @@ channel_urls = [
|
||||
name="hc-add-pushbullet-complete",
|
||||
),
|
||||
path("add_discord/", views.add_discord_complete, name="hc-add-discord-complete"),
|
||||
path("add_pushover/", views.add_pushover_help),
|
||||
path("telegram/", views.add_telegram_help),
|
||||
path("add_pushover/", views.pushover_help, name="hc-pushover-help"),
|
||||
path("telegram/", views.telegram_help, name="hc-telegram-help"),
|
||||
path("telegram/bot/", views.telegram_bot, name="hc-telegram-webhook"),
|
||||
path("add_pdc/", views.add_pdc_help),
|
||||
path("add_slack/", views.add_slack_help),
|
||||
path("add_pdc/", views.pdc_help, name="hc-pdc-help"),
|
||||
path("add_slack/", views.slack_help, name="hc-slack-help"),
|
||||
path("add_slack_btn/", views.add_slack_complete),
|
||||
path("add_telegram/", views.add_telegram, name="hc-add-telegram"),
|
||||
path("add_trello/settings/", views.trello_settings, name="hc-trello-settings"),
|
||||
|
@ -271,16 +271,18 @@ def index(request):
|
||||
"page": "welcome",
|
||||
"check": check,
|
||||
"ping_url": check.url(),
|
||||
"enable_apprise": settings.APPRISE_ENABLED is True,
|
||||
"enable_discord": settings.DISCORD_CLIENT_ID is not None,
|
||||
"enable_matrix": settings.MATRIX_ACCESS_TOKEN is not None,
|
||||
"enable_pdc": settings.PD_VENDOR_KEY is not None,
|
||||
"enable_pushbullet": settings.PUSHBULLET_CLIENT_ID is not None,
|
||||
"enable_pushover": settings.PUSHOVER_API_TOKEN is not None,
|
||||
"enable_discord": settings.DISCORD_CLIENT_ID is not None,
|
||||
"enable_telegram": settings.TELEGRAM_TOKEN is not None,
|
||||
"enable_sms": settings.TWILIO_AUTH is not None,
|
||||
"enable_whatsapp": settings.TWILIO_USE_WHATSAPP,
|
||||
"enable_trello": settings.TRELLO_APP_KEY is not None,
|
||||
"enable_matrix": settings.MATRIX_ACCESS_TOKEN is not None,
|
||||
"enable_apprise": settings.APPRISE_ENABLED is True,
|
||||
"enable_shell": settings.SHELL_ENABLED is True,
|
||||
"enable_slack_btn": settings.SLACK_CLIENT_ID is not None,
|
||||
"enable_sms": settings.TWILIO_AUTH is not None,
|
||||
"enable_telegram": settings.TELEGRAM_TOKEN is not None,
|
||||
"enable_trello": settings.TRELLO_APP_KEY is not None,
|
||||
"enable_whatsapp": settings.TWILIO_USE_WHATSAPP,
|
||||
"registration_open": settings.REGISTRATION_OPEN,
|
||||
}
|
||||
|
||||
@ -683,18 +685,18 @@ def channels(request, code):
|
||||
"project": project,
|
||||
"profile": project.owner_profile,
|
||||
"channels": channels,
|
||||
"enable_apprise": settings.APPRISE_ENABLED is True,
|
||||
"enable_discord": settings.DISCORD_CLIENT_ID is not None,
|
||||
"enable_matrix": settings.MATRIX_ACCESS_TOKEN is not None,
|
||||
"enable_pdc": settings.PD_VENDOR_KEY is not None,
|
||||
"enable_pushbullet": settings.PUSHBULLET_CLIENT_ID is not None,
|
||||
"enable_pushover": settings.PUSHOVER_API_TOKEN is not None,
|
||||
"enable_discord": settings.DISCORD_CLIENT_ID is not None,
|
||||
"enable_telegram": settings.TELEGRAM_TOKEN is not None,
|
||||
"enable_sms": settings.TWILIO_AUTH is not None,
|
||||
"enable_whatsapp": settings.TWILIO_USE_WHATSAPP,
|
||||
"enable_pdc": settings.PD_VENDOR_KEY is not None,
|
||||
"enable_trello": settings.TRELLO_APP_KEY is not None,
|
||||
"enable_matrix": settings.MATRIX_ACCESS_TOKEN is not None,
|
||||
"enable_apprise": settings.APPRISE_ENABLED is True,
|
||||
"enable_shell": settings.SHELL_ENABLED is True,
|
||||
"enable_slack_btn": settings.SLACK_CLIENT_ID is not None,
|
||||
"enable_sms": settings.TWILIO_AUTH is not None,
|
||||
"enable_telegram": settings.TELEGRAM_TOKEN is not None,
|
||||
"enable_trello": settings.TRELLO_APP_KEY is not None,
|
||||
"enable_whatsapp": settings.TWILIO_USE_WHATSAPP,
|
||||
"use_payments": settings.USE_PAYMENTS,
|
||||
}
|
||||
|
||||
@ -925,7 +927,7 @@ def add_pd(request, code):
|
||||
|
||||
|
||||
@require_setting("PD_VENDOR_KEY")
|
||||
def add_pdc_help(request):
|
||||
def pdc_help(request):
|
||||
ctx = {"page": "channels"}
|
||||
return render(request, "integrations/add_pdc.html", ctx)
|
||||
|
||||
@ -1042,7 +1044,7 @@ def add_slack(request, code):
|
||||
|
||||
|
||||
@require_setting("SLACK_CLIENT_ID")
|
||||
def add_slack_help(request):
|
||||
def slack_help(request):
|
||||
ctx = {"page": "channels"}
|
||||
return render(request, "integrations/add_slack_btn.html", ctx)
|
||||
|
||||
@ -1258,7 +1260,7 @@ def add_discord_complete(request):
|
||||
|
||||
|
||||
@require_setting("PUSHOVER_API_TOKEN")
|
||||
def add_pushover_help(request):
|
||||
def pushover_help(request):
|
||||
ctx = {"page": "channels"}
|
||||
return render(request, "integrations/add_pushover_help.html", ctx)
|
||||
|
||||
@ -1398,7 +1400,8 @@ def telegram_bot(request):
|
||||
return HttpResponse()
|
||||
|
||||
|
||||
def add_telegram_help(request):
|
||||
@require_setting("TELEGRAM_TOKEN")
|
||||
def telegram_help(request):
|
||||
ctx = {
|
||||
"page": "channels",
|
||||
"bot_name": settings.TELEGRAM_BOT_NAME,
|
||||
@ -1407,6 +1410,7 @@ def add_telegram_help(request):
|
||||
return render(request, "integrations/add_telegram.html", ctx)
|
||||
|
||||
|
||||
@require_setting("TELEGRAM_TOKEN")
|
||||
@login_required
|
||||
def add_telegram(request):
|
||||
chat_id, chat_type, chat_name = None, None, None
|
||||
|
@ -72,11 +72,19 @@
|
||||
}
|
||||
|
||||
#welcome-integrations .integration {
|
||||
display: block;
|
||||
color: #333;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 3px;
|
||||
padding: 20px 0;
|
||||
text-align: center;
|
||||
margin-bottom: 30px;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#welcome-integrations a.integration:hover {
|
||||
border-color: #0091EA;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#welcome-integrations img {
|
||||
|
@ -329,10 +329,17 @@
|
||||
</div>
|
||||
|
||||
<div class="col-lg-2 col-md-3 col-sm-4 col-xs-6">
|
||||
{% if enable_slack_btn %}
|
||||
<a href="{% url 'hc-slack-help' %}" class="integration">
|
||||
<img src="{% static 'img/integrations/slack.png' %}" class="icon" alt="" />
|
||||
<h3>Slack<br><small>Chat</small></h3>
|
||||
</a>
|
||||
{% else %}
|
||||
<div class="integration">
|
||||
<img src="{% static 'img/integrations/slack.png' %}" class="icon" alt="" />
|
||||
<h3>Slack<br><small>Chat</small></h3>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if enable_apprise %}
|
||||
@ -384,10 +391,17 @@
|
||||
</div>
|
||||
|
||||
<div class="col-lg-2 col-md-3 col-sm-4 col-xs-6">
|
||||
{% if enable_pdc %}
|
||||
<a href="{% url 'hc-pdc-help' %}" class="integration">
|
||||
<img src="{% static 'img/integrations/pd.png' %}" class="icon" alt="" />
|
||||
<h3>PagerDuty<br><small>Incident Management</small></h3>
|
||||
</a>
|
||||
{% else %}
|
||||
<div class="integration">
|
||||
<img src="{% static 'img/integrations/pd.png' %}" class="icon" alt="" />
|
||||
<h3>PagerDuty<br><small>Incident Management</small></h3>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="col-lg-2 col-md-3 col-sm-4 col-xs-6">
|
||||
@ -422,10 +436,10 @@
|
||||
|
||||
{% if enable_pushover %}
|
||||
<div class="col-lg-2 col-md-3 col-sm-4 col-xs-6">
|
||||
<div class="integration">
|
||||
<a href="{% url 'hc-pushover-help' %}" class="integration">
|
||||
<img src="{% static 'img/integrations/po.png' %}" class="icon" alt="" />
|
||||
<h3>Pushover<br><small>Push Notifications</small></h3>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
@ -449,10 +463,10 @@
|
||||
|
||||
{% if enable_telegram %}
|
||||
<div class="col-lg-2 col-md-3 col-sm-4 col-xs-6">
|
||||
<div class="integration">
|
||||
<a href="{% url 'hc-telegram-help' %}" class="integration">
|
||||
<img src="{% static 'img/integrations/telegram.png' %}" class="icon" alt="" />
|
||||
<h3>Telegram<br><small>Chat</small></h3>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
{% extends "base.html" %}
|
||||
{% load humanize static hc_extras %}
|
||||
|
||||
{% block title %}Add Apprise - {% site_name %}{% endblock %}
|
||||
{% block title %}Apprise Integration for {% site_name %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
|
@ -1,7 +1,7 @@
|
||||
{% extends "base.html" %}
|
||||
{% load humanize static hc_extras %}
|
||||
|
||||
{% block title %}Add Discord - {% site_name %}{% endblock %}
|
||||
{% block title %}Discord Integration for {% site_name %}{% endblock %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
|
@ -1,7 +1,7 @@
|
||||
{% extends "base.html" %}
|
||||
{% load humanize static hc_extras %}
|
||||
|
||||
{% block title %}Add Matrix - {% site_name %}{% endblock %}
|
||||
{% block title %}Matrix Integration for {% site_name %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
|
@ -1,7 +1,7 @@
|
||||
{% extends "base.html" %}
|
||||
{% load humanize static hc_extras %}
|
||||
|
||||
{% block title %}Add Mattermost - {% site_name %}{% endblock %}
|
||||
{% block title %}Mattermost Integration for {% site_name %}{% endblock %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
|
@ -1,7 +1,7 @@
|
||||
{% extends "base.html" %}
|
||||
{% load humanize static hc_extras %}
|
||||
|
||||
{% block title %}Add Microsoft Teams - {% site_name %}{% endblock %}
|
||||
{% block title %}Microsoft Teams Integration for {% site_name %}{% endblock %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
|
@ -1,7 +1,7 @@
|
||||
{% extends "base.html" %}
|
||||
{% load humanize static hc_extras %}
|
||||
|
||||
{% block title %}Add OpsGenie - {% site_name %}{% endblock %}
|
||||
{% block title %}OpsGenie Integration for {% site_name %}{% endblock %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
|
@ -1,7 +1,7 @@
|
||||
{% extends "base.html" %}
|
||||
{% load humanize static hc_extras %}
|
||||
|
||||
{% block title %}Add Pager Team - {% site_name %}{% endblock %}
|
||||
{% block title %}Pager Team Integration for {% site_name %}{% endblock %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
|
@ -1,7 +1,7 @@
|
||||
{% extends "base.html" %}
|
||||
{% load humanize static hc_extras %}
|
||||
|
||||
{% block title %}Add PagerTree - {% site_name %}{% endblock %}
|
||||
{% block title %}PagerTree Integration for {% site_name %}{% endblock %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
|
@ -1,7 +1,7 @@
|
||||
{% extends "base.html" %}
|
||||
{% load compress humanize static hc_extras %}
|
||||
|
||||
{% block title %}Add PagerDuty - {% site_name %}{% endblock %}
|
||||
{% block title %}PagerDuty Integration for {% site_name %}{% endblock %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
|
@ -1,7 +1,7 @@
|
||||
{% extends "base.html" %}
|
||||
{% load humanize static hc_extras %}
|
||||
|
||||
{% block title %}Add PagerDuty - {% site_name %}{% endblock %}
|
||||
{% block title %}PagerDuty Integration for {% site_name %}{% endblock %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
|
@ -1,7 +1,7 @@
|
||||
{% extends "base.html" %}
|
||||
{% load humanize static hc_extras %}
|
||||
|
||||
{% block title %}Add Prometheus - {% site_name %}{% endblock %}
|
||||
{% block title %}Prometheus Integration for {% site_name %}{% endblock %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
|
@ -1,7 +1,7 @@
|
||||
{% extends "base.html" %}
|
||||
{% load humanize static hc_extras %}
|
||||
|
||||
{% block title %}Add Pushbullet - {% site_name %}{% endblock %}
|
||||
{% block title %}Pushbullet Integration for {% site_name %}{% endblock %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
|
@ -1,7 +1,7 @@
|
||||
{% extends "base.html" %}
|
||||
{% load humanize static hc_extras %}
|
||||
|
||||
{% block title %}Add Slack - {% site_name %}{% endblock %}
|
||||
{% block title %}Slack Integration for {% site_name %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
|
@ -1,7 +1,7 @@
|
||||
{% extends "base.html" %}
|
||||
{% load humanize static hc_extras %}
|
||||
|
||||
{% block title %}Notification Channels - {% site_name %}{% endblock %}
|
||||
{% block title %}Add SMS Integration - {% site_name %}{% endblock %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
|
@ -1,7 +1,7 @@
|
||||
{% extends "base.html" %}
|
||||
{% load compress humanize static hc_extras %}
|
||||
|
||||
{% block title %}Add Trello - {% site_name %}{% endblock %}
|
||||
{% block title %}Trello Integration for {% site_name %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
|
@ -1,7 +1,7 @@
|
||||
{% extends "base.html" %}
|
||||
{% load humanize static hc_extras %}
|
||||
|
||||
{% block title %}Add VictorOps - {% site_name %}{% endblock %}
|
||||
{% block title %}VictorOps Integration for {% site_name %}{% endblock %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
|
@ -1,7 +1,7 @@
|
||||
{% extends "base.html" %}
|
||||
{% load compress humanize static hc_extras %}
|
||||
|
||||
{% block title %}Add Webhook - {% site_name %}{% endblock %}
|
||||
{% block title %}Add Webhook Integration - {% site_name %}{% endblock %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
|
@ -1,7 +1,7 @@
|
||||
{% extends "base.html" %}
|
||||
{% load humanize static hc_extras %}
|
||||
|
||||
{% block title %}Notification Channels - {% site_name %}{% endblock %}
|
||||
{% block title %}Add WhatsApp Integration - {% site_name %}{% endblock %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
|
@ -1,8 +0,0 @@
|
||||
{% load humanize %}
|
||||
{% if check.status == "down" %}
|
||||
{{ check.name_then_code }} is down.
|
||||
Last ping was {{ check.last_ping|naturaltime }}.
|
||||
Details: {{ check.details_url }}
|
||||
{% else %}
|
||||
{{ check.name_then_code }} received a ping and is now UP
|
||||
{% endif %}
|
@ -1,5 +0,0 @@
|
||||
{% if check.status == "down" %}
|
||||
{{ check.name_then_code }} is down
|
||||
{% else %}
|
||||
{{ check.name_then_code }} is now UP
|
||||
{% endif %}
|
Loading…
x
Reference in New Issue
Block a user