forked from GithubBackups/healthchecks
The "Add Telegram" page shows a project picker. cc: #336
This commit is contained in:
parent
acce0808ce
commit
7060d49306
@ -23,8 +23,9 @@ class AddTelegramTestCase(BaseTestCase):
|
|||||||
payload = signing.dumps((123, "group", "My Group"))
|
payload = signing.dumps((123, "group", "My Group"))
|
||||||
|
|
||||||
self.client.login(username="alice@example.org", password="password")
|
self.client.login(username="alice@example.org", password="password")
|
||||||
r = self.client.post(self.url + "?" + payload, {})
|
form = {"project": str(self.project.code)}
|
||||||
self.assertRedirects(r, "/integrations/")
|
r = self.client.post(self.url + "?" + payload, form)
|
||||||
|
self.assertRedirects(r, self.channels_url)
|
||||||
|
|
||||||
c = Channel.objects.get()
|
c = Channel.objects.get()
|
||||||
self.assertEqual(c.kind, "telegram")
|
self.assertEqual(c.kind, "telegram")
|
||||||
|
@ -1430,7 +1430,8 @@ def add_telegram(request):
|
|||||||
chat_id, chat_type, chat_name = signing.loads(qs, max_age=600)
|
chat_id, chat_type, chat_name = signing.loads(qs, max_age=600)
|
||||||
|
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
channel = Channel(project=request.project, kind="telegram")
|
project = _get_project_for_user(request, request.POST.get("project"))
|
||||||
|
channel = Channel(project=project, kind="telegram")
|
||||||
channel.value = json.dumps(
|
channel.value = json.dumps(
|
||||||
{"id": chat_id, "type": chat_type, "name": chat_name}
|
{"id": chat_id, "type": chat_type, "name": chat_name}
|
||||||
)
|
)
|
||||||
@ -1438,11 +1439,11 @@ def add_telegram(request):
|
|||||||
|
|
||||||
channel.assign_all_checks()
|
channel.assign_all_checks()
|
||||||
messages.success(request, "The Telegram integration has been added!")
|
messages.success(request, "The Telegram integration has been added!")
|
||||||
return redirect("hc-channels")
|
return redirect("hc-p-channels", project.code)
|
||||||
|
|
||||||
ctx = {
|
ctx = {
|
||||||
"page": "channels",
|
"page": "channels",
|
||||||
"project": request.project,
|
"projects": request.profile.projects(),
|
||||||
"chat_id": chat_id,
|
"chat_id": chat_id,
|
||||||
"chat_type": chat_type,
|
"chat_type": chat_type,
|
||||||
"chat_name": chat_name,
|
"chat_name": chat_name,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% load humanize static hc_extras %}
|
{% load compress humanize static hc_extras %}
|
||||||
|
|
||||||
{% block title %}Notification Channels - {% site_name %}{% endblock %}
|
{% block title %}Notification Channels - {% site_name %}{% endblock %}
|
||||||
|
|
||||||
@ -19,18 +19,35 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
a Telegram chat
|
a Telegram chat
|
||||||
{% endif %}
|
{% endif %}
|
||||||
named <strong>{{ chat_name }}</strong>. Sound good?
|
named <strong>{{ chat_name }}</strong>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<form method="post" class="text-center">
|
|
||||||
{% csrf_token %}
|
|
||||||
|
|
||||||
<button type="submit" class="btn btn-lg btn-default">
|
|
||||||
<img class="ai-icon" src="{% static 'img/integrations/telegram.png' %}" alt="Telegram" />
|
|
||||||
Yes, connect Telegram
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<h2>Integration Settings</h2>
|
||||||
|
|
||||||
|
<form id="add-telegram" method="post" class="form-horizontal">
|
||||||
|
{% csrf_token %}
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">Project</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<select name="project" class="selectpicker">
|
||||||
|
{% for project in projects %}
|
||||||
|
<option value="{{ project.code }}">{{ project }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-offset-3 col-sm-8">
|
||||||
|
<button type="submit" class="btn btn-default">
|
||||||
|
<img class="ai-icon" src="{% static 'img/integrations/telegram.png' %}" alt="Telegram" />
|
||||||
|
Connect Telegram
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>If your team uses <a href="https://telegram.org/">Telegram</a>,
|
<p>If your team uses <a href="https://telegram.org/">Telegram</a>,
|
||||||
you can set up {% site_name %} to post status updates directly to an
|
you can set up {% site_name %} to post status updates directly to an
|
||||||
@ -94,3 +111,11 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block scripts %}
|
||||||
|
{% compress js %}
|
||||||
|
<script src="{% static 'js/jquery-2.1.4.min.js' %}"></script>
|
||||||
|
<script src="{% static 'js/bootstrap.min.js' %}"></script>
|
||||||
|
<script src="{% static 'js/bootstrap-select.min.js' %}"></script>
|
||||||
|
{% endcompress %}
|
||||||
|
{% endblock %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user