Browse Source

Link integration setup instructions from the welcome page (only the ones that don't require authentication: Slack, Pushover, PagerDuty Connect, Telegram)

pull/340/head
Pēteris Caune 5 years ago
parent
commit
dab15c3b8c
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
26 changed files with 81 additions and 58 deletions
  1. +10
    -0
      hc/front/tests/test_add_telegram.py
  2. +4
    -4
      hc/front/urls.py
  3. +22
    -18
      hc/front/views.py
  4. +8
    -0
      static/css/welcome.css
  5. +1
    -1
      templates/base.html
  6. +18
    -4
      templates/front/welcome.html
  7. +1
    -1
      templates/integrations/add_apprise.html
  8. +1
    -1
      templates/integrations/add_discord.html
  9. +1
    -1
      templates/integrations/add_matrix.html
  10. +1
    -1
      templates/integrations/add_mattermost.html
  11. +1
    -1
      templates/integrations/add_msteams.html
  12. +1
    -1
      templates/integrations/add_opsgenie.html
  13. +1
    -1
      templates/integrations/add_pagerteam.html
  14. +1
    -1
      templates/integrations/add_pagertree.html
  15. +1
    -1
      templates/integrations/add_pd.html
  16. +1
    -1
      templates/integrations/add_pdc.html
  17. +1
    -1
      templates/integrations/add_prometheus.html
  18. +1
    -1
      templates/integrations/add_pushbullet.html
  19. +1
    -1
      templates/integrations/add_slack.html
  20. +1
    -1
      templates/integrations/add_sms.html
  21. +1
    -1
      templates/integrations/add_trello.html
  22. +1
    -1
      templates/integrations/add_victorops.html
  23. +1
    -1
      templates/integrations/add_webhook.html
  24. +1
    -1
      templates/integrations/add_whatsapp.html
  25. +0
    -8
      templates/integrations/zendesk_description.html
  26. +0
    -5
      templates/integrations/zendesk_title.html

+ 10
- 0
hc/front/tests/test_add_telegram.py View File

@ -1,9 +1,11 @@
from django.core import signing from django.core import signing
from django.test.utils import override_settings
from hc.api.models import Channel from hc.api.models import Channel
from hc.test import BaseTestCase from hc.test import BaseTestCase
from mock import patch from mock import patch
@override_settings(TELEGRAM_TOKEN="fake-token")
class AddTelegramTestCase(BaseTestCase): class AddTelegramTestCase(BaseTestCase):
url = "/integrations/add_telegram/" url = "/integrations/add_telegram/"
@ -12,6 +14,14 @@ class AddTelegramTestCase(BaseTestCase):
r = self.client.get(self.url) r = self.client.get(self.url)
self.assertContains(r, "start@ExampleBot") 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="[email protected]", password="password")
r = self.client.get(self.url + "?" + payload)
self.assertEqual(r.status_code, 404)
def test_it_shows_confirmation(self): def test_it_shows_confirmation(self):
payload = signing.dumps((123, "group", "My Group")) payload = signing.dumps((123, "group", "My Group"))


+ 4
- 4
hc/front/urls.py View File

@ -29,11 +29,11 @@ channel_urls = [
name="hc-add-pushbullet-complete", name="hc-add-pushbullet-complete",
), ),
path("add_discord/", views.add_discord_complete, name="hc-add-discord-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("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_slack_btn/", views.add_slack_complete),
path("add_telegram/", views.add_telegram, name="hc-add-telegram"), path("add_telegram/", views.add_telegram, name="hc-add-telegram"),
path("add_trello/settings/", views.trello_settings, name="hc-trello-settings"), path("add_trello/settings/", views.trello_settings, name="hc-trello-settings"),


+ 22
- 18
hc/front/views.py View File

@ -271,16 +271,18 @@ def index(request):
"page": "welcome", "page": "welcome",
"check": check, "check": check,
"ping_url": check.url(), "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_pushbullet": settings.PUSHBULLET_CLIENT_ID is not None,
"enable_pushover": settings.PUSHOVER_API_TOKEN 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_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_sms": settings.TWILIO_AUTH is not None,
"enable_whatsapp": settings.TWILIO_USE_WHATSAPP,
"enable_telegram": settings.TELEGRAM_TOKEN is not None,
"enable_trello": settings.TRELLO_APP_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_whatsapp": settings.TWILIO_USE_WHATSAPP,
"registration_open": settings.REGISTRATION_OPEN, "registration_open": settings.REGISTRATION_OPEN,
} }
@ -683,18 +685,18 @@ def channels(request, code):
"project": project, "project": project,
"profile": project.owner_profile, "profile": project.owner_profile,
"channels": channels, "channels": channels,
"enable_pushbullet": settings.PUSHBULLET_CLIENT_ID is not None,
"enable_pushover": settings.PUSHOVER_API_TOKEN is not None,
"enable_apprise": settings.APPRISE_ENABLED is True,
"enable_discord": settings.DISCORD_CLIENT_ID 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_matrix": settings.MATRIX_ACCESS_TOKEN is not None,
"enable_apprise": settings.APPRISE_ENABLED is True,
"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_shell": settings.SHELL_ENABLED is True, "enable_shell": settings.SHELL_ENABLED is True,
"enable_slack_btn": settings.SLACK_CLIENT_ID is not None, "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, "use_payments": settings.USE_PAYMENTS,
} }
@ -925,7 +927,7 @@ def add_pd(request, code):
@require_setting("PD_VENDOR_KEY") @require_setting("PD_VENDOR_KEY")
def add_pdc_help(request):
def pdc_help(request):
ctx = {"page": "channels"} ctx = {"page": "channels"}
return render(request, "integrations/add_pdc.html", ctx) return render(request, "integrations/add_pdc.html", ctx)
@ -1042,7 +1044,7 @@ def add_slack(request, code):
@require_setting("SLACK_CLIENT_ID") @require_setting("SLACK_CLIENT_ID")
def add_slack_help(request):
def slack_help(request):
ctx = {"page": "channels"} ctx = {"page": "channels"}
return render(request, "integrations/add_slack_btn.html", ctx) return render(request, "integrations/add_slack_btn.html", ctx)
@ -1258,7 +1260,7 @@ def add_discord_complete(request):
@require_setting("PUSHOVER_API_TOKEN") @require_setting("PUSHOVER_API_TOKEN")
def add_pushover_help(request):
def pushover_help(request):
ctx = {"page": "channels"} ctx = {"page": "channels"}
return render(request, "integrations/add_pushover_help.html", ctx) return render(request, "integrations/add_pushover_help.html", ctx)
@ -1398,7 +1400,8 @@ def telegram_bot(request):
return HttpResponse() return HttpResponse()
def add_telegram_help(request):
@require_setting("TELEGRAM_TOKEN")
def telegram_help(request):
ctx = { ctx = {
"page": "channels", "page": "channels",
"bot_name": settings.TELEGRAM_BOT_NAME, "bot_name": settings.TELEGRAM_BOT_NAME,
@ -1407,6 +1410,7 @@ def add_telegram_help(request):
return render(request, "integrations/add_telegram.html", ctx) return render(request, "integrations/add_telegram.html", ctx)
@require_setting("TELEGRAM_TOKEN")
@login_required @login_required
def add_telegram(request): def add_telegram(request):
chat_id, chat_type, chat_name = None, None, None chat_id, chat_type, chat_name = None, None, None


+ 8
- 0
static/css/welcome.css View File

@ -72,11 +72,19 @@
} }
#welcome-integrations .integration { #welcome-integrations .integration {
display: block;
color: #333;
border: 1px solid #ddd; border: 1px solid #ddd;
border-radius: 3px; border-radius: 3px;
padding: 20px 0; padding: 20px 0;
text-align: center; text-align: center;
margin-bottom: 30px; margin-bottom: 30px;
text-decoration: none;
}
#welcome-integrations a.integration:hover {
border-color: #0091EA;
text-decoration: none;
} }
#welcome-integrations img { #welcome-integrations img {


+ 1
- 1
templates/base.html View File

@ -67,7 +67,7 @@
<span class="icon-bar"></span> <span class="icon-bar"></span>
</button> </button>
<a id="base-url" class="navbar-brand" href="{% url 'hc-index' %}">
<a id="base-url" class="navbar-brand" href="{% url 'hc-index' %}">
{% if request.user.is_authenticated and project %} {% if request.user.is_authenticated and project %}
{{ project }} {{ project }}
<span class="caret"></span> <span class="caret"></span>


+ 18
- 4
templates/front/welcome.html View File

@ -329,10 +329,17 @@
</div> </div>
<div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"> <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"> <div class="integration">
<img src="{% static 'img/integrations/slack.png' %}" class="icon" alt="" /> <img src="{% static 'img/integrations/slack.png' %}" class="icon" alt="" />
<h3>Slack<br><small>Chat</small></h3> <h3>Slack<br><small>Chat</small></h3>
</div> </div>
{% endif %}
</div> </div>
{% if enable_apprise %} {% if enable_apprise %}
@ -384,10 +391,17 @@
</div> </div>
<div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"> <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"> <div class="integration">
<img src="{% static 'img/integrations/pd.png' %}" class="icon" alt="" /> <img src="{% static 'img/integrations/pd.png' %}" class="icon" alt="" />
<h3>PagerDuty<br><small>Incident Management</small></h3> <h3>PagerDuty<br><small>Incident Management</small></h3>
</div> </div>
{% endif %}
</div> </div>
<div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"> <div class="col-lg-2 col-md-3 col-sm-4 col-xs-6">
@ -422,10 +436,10 @@
{% if enable_pushover %} {% if enable_pushover %}
<div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"> <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="" /> <img src="{% static 'img/integrations/po.png' %}" class="icon" alt="" />
<h3>Pushover<br><small>Push Notifications</small></h3> <h3>Pushover<br><small>Push Notifications</small></h3>
</div>
</a>
</div> </div>
{% endif %} {% endif %}
@ -449,10 +463,10 @@
{% if enable_telegram %} {% if enable_telegram %}
<div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"> <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="" /> <img src="{% static 'img/integrations/telegram.png' %}" class="icon" alt="" />
<h3>Telegram<br><small>Chat</small></h3> <h3>Telegram<br><small>Chat</small></h3>
</div>
</a>
</div> </div>
{% endif %} {% endif %}


+ 1
- 1
templates/integrations/add_apprise.html View File

@ -1,7 +1,7 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load humanize static hc_extras %} {% load humanize static hc_extras %}
{% block title %}Add Apprise - {% site_name %}{% endblock %}
{% block title %}Apprise Integration for {% site_name %}{% endblock %}
{% block content %} {% block content %}
<div class="row"> <div class="row">


+ 1
- 1
templates/integrations/add_discord.html View File

@ -1,7 +1,7 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load humanize static hc_extras %} {% load humanize static hc_extras %}
{% block title %}Add Discord - {% site_name %}{% endblock %}
{% block title %}Discord Integration for {% site_name %}{% endblock %}
{% block content %} {% block content %}


+ 1
- 1
templates/integrations/add_matrix.html View File

@ -1,7 +1,7 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load humanize static hc_extras %} {% load humanize static hc_extras %}
{% block title %}Add Matrix - {% site_name %}{% endblock %}
{% block title %}Matrix Integration for {% site_name %}{% endblock %}
{% block content %} {% block content %}
<div class="row"> <div class="row">


+ 1
- 1
templates/integrations/add_mattermost.html View File

@ -1,7 +1,7 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load humanize static hc_extras %} {% load humanize static hc_extras %}
{% block title %}Add Mattermost - {% site_name %}{% endblock %}
{% block title %}Mattermost Integration for {% site_name %}{% endblock %}
{% block content %} {% block content %}


+ 1
- 1
templates/integrations/add_msteams.html View File

@ -1,7 +1,7 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load humanize static hc_extras %} {% load humanize static hc_extras %}
{% block title %}Add Microsoft Teams - {% site_name %}{% endblock %}
{% block title %}Microsoft Teams Integration for {% site_name %}{% endblock %}
{% block content %} {% block content %}


+ 1
- 1
templates/integrations/add_opsgenie.html View File

@ -1,7 +1,7 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load humanize static hc_extras %} {% load humanize static hc_extras %}
{% block title %}Add OpsGenie - {% site_name %}{% endblock %}
{% block title %}OpsGenie Integration for {% site_name %}{% endblock %}
{% block content %} {% block content %}


+ 1
- 1
templates/integrations/add_pagerteam.html View File

@ -1,7 +1,7 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load humanize static hc_extras %} {% load humanize static hc_extras %}
{% block title %}Add Pager Team - {% site_name %}{% endblock %}
{% block title %}Pager Team Integration for {% site_name %}{% endblock %}
{% block content %} {% block content %}


+ 1
- 1
templates/integrations/add_pagertree.html View File

@ -1,7 +1,7 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load humanize static hc_extras %} {% load humanize static hc_extras %}
{% block title %}Add PagerTree - {% site_name %}{% endblock %}
{% block title %}PagerTree Integration for {% site_name %}{% endblock %}
{% block content %} {% block content %}


+ 1
- 1
templates/integrations/add_pd.html View File

@ -1,7 +1,7 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load compress humanize static hc_extras %} {% load compress humanize static hc_extras %}
{% block title %}Add PagerDuty - {% site_name %}{% endblock %}
{% block title %}PagerDuty Integration for {% site_name %}{% endblock %}
{% block content %} {% block content %}


+ 1
- 1
templates/integrations/add_pdc.html View File

@ -1,7 +1,7 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load humanize static hc_extras %} {% load humanize static hc_extras %}
{% block title %}Add PagerDuty - {% site_name %}{% endblock %}
{% block title %}PagerDuty Integration for {% site_name %}{% endblock %}
{% block content %} {% block content %}


+ 1
- 1
templates/integrations/add_prometheus.html View File

@ -1,7 +1,7 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load humanize static hc_extras %} {% load humanize static hc_extras %}
{% block title %}Add Prometheus - {% site_name %}{% endblock %}
{% block title %}Prometheus Integration for {% site_name %}{% endblock %}
{% block content %} {% block content %}


+ 1
- 1
templates/integrations/add_pushbullet.html View File

@ -1,7 +1,7 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load humanize static hc_extras %} {% load humanize static hc_extras %}
{% block title %}Add Pushbullet - {% site_name %}{% endblock %}
{% block title %}Pushbullet Integration for {% site_name %}{% endblock %}
{% block content %} {% block content %}


+ 1
- 1
templates/integrations/add_slack.html View File

@ -1,7 +1,7 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load humanize static hc_extras %} {% load humanize static hc_extras %}
{% block title %}Add Slack - {% site_name %}{% endblock %}
{% block title %}Slack Integration for {% site_name %}{% endblock %}
{% block content %} {% block content %}
<div class="row"> <div class="row">


+ 1
- 1
templates/integrations/add_sms.html View File

@ -1,7 +1,7 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load humanize static hc_extras %} {% load humanize static hc_extras %}
{% block title %}Notification Channels - {% site_name %}{% endblock %}
{% block title %}Add SMS Integration - {% site_name %}{% endblock %}
{% block content %} {% block content %}


+ 1
- 1
templates/integrations/add_trello.html View File

@ -1,7 +1,7 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load compress humanize static hc_extras %} {% load compress humanize static hc_extras %}
{% block title %}Add Trello - {% site_name %}{% endblock %}
{% block title %}Trello Integration for {% site_name %}{% endblock %}
{% block content %} {% block content %}
<div class="row"> <div class="row">


+ 1
- 1
templates/integrations/add_victorops.html View File

@ -1,7 +1,7 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load humanize static hc_extras %} {% load humanize static hc_extras %}
{% block title %}Add VictorOps - {% site_name %}{% endblock %}
{% block title %}VictorOps Integration for {% site_name %}{% endblock %}
{% block content %} {% block content %}


+ 1
- 1
templates/integrations/add_webhook.html View File

@ -1,7 +1,7 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load compress humanize static hc_extras %} {% load compress humanize static hc_extras %}
{% block title %}Add Webhook - {% site_name %}{% endblock %}
{% block title %}Add Webhook Integration - {% site_name %}{% endblock %}
{% block content %} {% block content %}


+ 1
- 1
templates/integrations/add_whatsapp.html View File

@ -1,7 +1,7 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load humanize static hc_extras %} {% load humanize static hc_extras %}
{% block title %}Notification Channels - {% site_name %}{% endblock %}
{% block title %}Add WhatsApp Integration - {% site_name %}{% endblock %}
{% block content %} {% block content %}


+ 0
- 8
templates/integrations/zendesk_description.html View File

@ -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 %}

+ 0
- 5
templates/integrations/zendesk_title.html View File

@ -1,5 +0,0 @@
{% if check.status == "down" %}
{{ check.name_then_code }} is down
{% else %}
{{ check.name_then_code }} is now UP
{% endif %}

Loading…
Cancel
Save