forked from GithubBackups/healthchecks
Project code in URL for the "Add Trello" page. cc: #336
This commit is contained in:
parent
26757c6785
commit
dee189be33
@ -5,8 +5,10 @@ from hc.api.models import Channel
|
|||||||
from hc.test import BaseTestCase
|
from hc.test import BaseTestCase
|
||||||
|
|
||||||
|
|
||||||
class AddPagerTreeTestCase(BaseTestCase):
|
class AddTrelloTestCase(BaseTestCase):
|
||||||
url = "/integrations/add_trello/"
|
def setUp(self):
|
||||||
|
super(AddTrelloTestCase, self).setUp()
|
||||||
|
self.url = "/projects/%s/add_trello/" % self.project.code
|
||||||
|
|
||||||
@override_settings(TRELLO_APP_KEY="foo")
|
@override_settings(TRELLO_APP_KEY="foo")
|
||||||
def test_instructions_work(self):
|
def test_instructions_work(self):
|
||||||
@ -29,7 +31,7 @@ class AddPagerTreeTestCase(BaseTestCase):
|
|||||||
|
|
||||||
self.client.login(username="alice@example.org", password="password")
|
self.client.login(username="alice@example.org", password="password")
|
||||||
r = self.client.post(self.url, form)
|
r = self.client.post(self.url, form)
|
||||||
self.assertRedirects(r, "/integrations/")
|
self.assertRedirects(r, self.channels_url)
|
||||||
|
|
||||||
c = Channel.objects.get()
|
c = Channel.objects.get()
|
||||||
self.assertEqual(c.kind, "trello")
|
self.assertEqual(c.kind, "trello")
|
||||||
|
@ -35,7 +35,6 @@ channel_urls = [
|
|||||||
path("add_pushover/", views.add_pushover_help),
|
path("add_pushover/", views.add_pushover_help),
|
||||||
path("telegram/bot/", views.telegram_bot, name="hc-telegram-webhook"),
|
path("telegram/bot/", views.telegram_bot, name="hc-telegram-webhook"),
|
||||||
path("add_telegram/", views.add_telegram, name="hc-add-telegram"),
|
path("add_telegram/", views.add_telegram, name="hc-add-telegram"),
|
||||||
path("add_trello/", views.add_trello, name="hc-add-trello"),
|
|
||||||
path("add_trello/settings/", views.trello_settings, name="hc-trello-settings"),
|
path("add_trello/settings/", views.trello_settings, name="hc-trello-settings"),
|
||||||
path("<uuid:code>/checks/", views.channel_checks, name="hc-channel-checks"),
|
path("<uuid:code>/checks/", views.channel_checks, name="hc-channel-checks"),
|
||||||
path("<uuid:code>/name/", views.update_channel_name, name="hc-channel-name"),
|
path("<uuid:code>/name/", views.update_channel_name, name="hc-channel-name"),
|
||||||
@ -69,6 +68,7 @@ project_urls = [
|
|||||||
path("add_pushover/", views.add_pushover, name="hc-add-pushover"),
|
path("add_pushover/", views.add_pushover, name="hc-add-pushover"),
|
||||||
path("add_shell/", views.add_shell, name="hc-add-shell"),
|
path("add_shell/", views.add_shell, name="hc-add-shell"),
|
||||||
path("add_sms/", views.add_sms, name="hc-add-sms"),
|
path("add_sms/", views.add_sms, name="hc-add-sms"),
|
||||||
|
path("add_trello/", views.add_trello, name="hc-add-trello"),
|
||||||
path("add_victorops/", views.add_victorops, name="hc-add-victorops"),
|
path("add_victorops/", views.add_victorops, name="hc-add-victorops"),
|
||||||
path("add_webhook/", views.add_webhook, name="hc-add-webhook"),
|
path("add_webhook/", views.add_webhook, name="hc-add-webhook"),
|
||||||
path("add_whatsapp/", views.add_whatsapp, name="hc-add-whatsapp"),
|
path("add_whatsapp/", views.add_whatsapp, name="hc-add-whatsapp"),
|
||||||
|
@ -1477,18 +1477,20 @@ def add_whatsapp(request, code):
|
|||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def add_trello(request):
|
def add_trello(request, code):
|
||||||
if settings.TRELLO_APP_KEY is None:
|
if settings.TRELLO_APP_KEY is None:
|
||||||
raise Http404("trello integration is not available")
|
raise Http404("trello integration is not available")
|
||||||
|
|
||||||
|
project = _get_project_for_user(request, code)
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
channel = Channel(project=request.project, kind="trello")
|
channel = Channel(project=project, kind="trello")
|
||||||
channel.value = request.POST["settings"]
|
channel.value = request.POST["settings"]
|
||||||
channel.save()
|
channel.save()
|
||||||
|
|
||||||
channel.assign_all_checks()
|
channel.assign_all_checks()
|
||||||
return redirect("hc-channels")
|
return redirect("hc-p-channels", project.code)
|
||||||
|
|
||||||
|
return_url = settings.SITE_ROOT + reverse("hc-add-trello", args=[project.code])
|
||||||
authorize_url = "https://trello.com/1/authorize?" + urlencode(
|
authorize_url = "https://trello.com/1/authorize?" + urlencode(
|
||||||
{
|
{
|
||||||
"expiration": "never",
|
"expiration": "never",
|
||||||
@ -1496,13 +1498,13 @@ def add_trello(request):
|
|||||||
"scope": "read,write",
|
"scope": "read,write",
|
||||||
"response_type": "token",
|
"response_type": "token",
|
||||||
"key": settings.TRELLO_APP_KEY,
|
"key": settings.TRELLO_APP_KEY,
|
||||||
"return_url": settings.SITE_ROOT + reverse("hc-add-trello"),
|
"return_url": return_url,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx = {
|
ctx = {
|
||||||
"page": "channels",
|
"page": "channels",
|
||||||
"project": request.project,
|
"project": project,
|
||||||
"authorize_url": authorize_url,
|
"authorize_url": authorize_url,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,7 +352,7 @@
|
|||||||
|
|
||||||
<h2>Trello</h2>
|
<h2>Trello</h2>
|
||||||
<p>Create a Trello card when a check goes down.</p>
|
<p>Create a Trello card when a check goes down.</p>
|
||||||
<a href="{% url 'hc-add-trello' %}" class="btn btn-primary">Add Integration</a>
|
<a href="{% url 'hc-add-trello' project.code %}" class="btn btn-primary">Add Integration</a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user