diff --git a/hc/front/tests/test_add_shell.py b/hc/front/tests/test_add_shell.py index 01cd70b2..e12b957b 100644 --- a/hc/front/tests/test_add_shell.py +++ b/hc/front/tests/test_add_shell.py @@ -5,7 +5,9 @@ from hc.test import BaseTestCase @override_settings(SHELL_ENABLED=True) class AddShellTestCase(BaseTestCase): - url = "/integrations/add_shell/" + def setUp(self): + super(AddShellTestCase, self).setUp() + self.url = "/projects/%s/add_shell/" % self.project.code @override_settings(SHELL_ENABLED=False) def test_it_is_disabled_by_default(self): @@ -23,7 +25,7 @@ class AddShellTestCase(BaseTestCase): self.client.login(username="alice@example.org", password="password") r = self.client.post(self.url, form) - self.assertRedirects(r, "/integrations/") + self.assertRedirects(r, self.channels_url) c = Channel.objects.get() self.assertEqual(c.project, self.project) diff --git a/hc/front/urls.py b/hc/front/urls.py index 89101c9a..1f0784b9 100644 --- a/hc/front/urls.py +++ b/hc/front/urls.py @@ -24,7 +24,6 @@ check_urls = [ channel_urls = [ path("", views.channels, name="hc-channels"), - path("add_shell/", views.add_shell, name="hc-add-shell"), path("add_pd/", views.add_pd, name="hc-add-pd"), path("add_pdc/", views.add_pdc, name="hc-add-pdc"), path("add_pdc//", views.add_pdc, name="hc-add-pdc-state"), @@ -61,6 +60,7 @@ project_urls = [ path("add_pagerteam/", views.add_pagerteam, name="hc-add-pagerteam"), path("add_pagertree/", views.add_pagertree, name="hc-add-pagertree"), path("add_prometheus/", views.add_prometheus, name="hc-add-prometheus"), + path("add_shell/", views.add_shell, name="hc-add-shell"), path("add_sms/", views.add_sms, name="hc-add-sms"), path("add_victorops/", views.add_victorops, name="hc-add-victorops"), path("add_webhook/", views.add_webhook, name="hc-add-webhook"), diff --git a/hc/front/views.py b/hc/front/views.py index 7190c787..b4526fcc 100644 --- a/hc/front/views.py +++ b/hc/front/views.py @@ -876,25 +876,26 @@ def add_webhook(request, code): @login_required -def add_shell(request): +def add_shell(request, code): if not settings.SHELL_ENABLED: raise Http404("shell integration is not available") + project = _get_project_for_user(request, code) if request.method == "POST": form = AddShellForm(request.POST) if form.is_valid(): - channel = Channel(project=request.project, kind="shell") + channel = Channel(project=project, kind="shell") channel.value = form.get_value() channel.save() channel.assign_all_checks() - return redirect("hc-channels") + return redirect("hc-p-channels", project.code) else: form = AddShellForm() ctx = { "page": "channels", - "project": request.project, + "project": project, "form": form, "now": timezone.now().replace(microsecond=0).isoformat(), } diff --git a/templates/front/channels.html b/templates/front/channels.html index 1ffcf99c..2a37943b 100644 --- a/templates/front/channels.html +++ b/templates/front/channels.html @@ -319,7 +319,7 @@

Shell Command

Execute a local shell command when a check goes up or down.

- Add Integration + Add Integration {% endif %}