diff --git a/hc/front/tests/test_add_pd.py b/hc/front/tests/test_add_pd.py index b2a8dc87..f0c3db6b 100644 --- a/hc/front/tests/test_add_pd.py +++ b/hc/front/tests/test_add_pd.py @@ -3,7 +3,9 @@ from hc.test import BaseTestCase class AddPdTestCase(BaseTestCase): - url = "/integrations/add_pd/" + def setUp(self): + super(AddPdTestCase, self).setUp() + self.url = "/projects/%s/add_pd/" % self.project.code def test_instructions_work(self): self.client.login(username="alice@example.org", password="password") @@ -16,7 +18,7 @@ class AddPdTestCase(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.kind, "pd") diff --git a/hc/front/urls.py b/hc/front/urls.py index 1f0784b9..bc31e8e1 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_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"), path("add_slack/", views.add_slack, name="hc-add-slack"), @@ -59,6 +58,7 @@ project_urls = [ path("add_opsgenie/", views.add_opsgenie, name="hc-add-opsgenie"), path("add_pagerteam/", views.add_pagerteam, name="hc-add-pagerteam"), path("add_pagertree/", views.add_pagertree, name="hc-add-pagertree"), + path("add_pd/", views.add_pd, name="hc-add-pd"), 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"), diff --git a/hc/front/views.py b/hc/front/views.py index b4526fcc..c592a4ac 100644 --- a/hc/front/views.py +++ b/hc/front/views.py @@ -921,16 +921,18 @@ def _get_validated_code(request, session_key, key="code"): @login_required -def add_pd(request): +def add_pd(request, code): + project = _get_project_for_user(request, code) + if request.method == "POST": form = AddPdForm(request.POST) if form.is_valid(): - channel = Channel(project=request.project, kind="pd") + channel = Channel(project=project, kind="pd") channel.value = form.cleaned_data["value"] channel.save() channel.assign_all_checks() - return redirect("hc-channels") + return redirect("hc-p-channels", project.code) else: form = AddPdForm() diff --git a/templates/front/channels.html b/templates/front/channels.html index 2a37943b..a05cd25d 100644 --- a/templates/front/channels.html +++ b/templates/front/channels.html @@ -259,7 +259,7 @@ {% if enable_pdc %} Add Integration {% else %} - Add Integration + Add Integration {% endif %} diff --git a/templates/integrations/add_pd.html b/templates/integrations/add_pd.html index 0484fdde..41152c62 100644 --- a/templates/integrations/add_pd.html +++ b/templates/integrations/add_pd.html @@ -63,7 +63,7 @@

Integration Settings

-
+ {% csrf_token %}