diff --git a/hc/front/tests/test_add_pagertree.py b/hc/front/tests/test_add_pagertree.py index 4ebe6e8a..a9ebec46 100644 --- a/hc/front/tests/test_add_pagertree.py +++ b/hc/front/tests/test_add_pagertree.py @@ -3,7 +3,9 @@ from hc.test import BaseTestCase class AddPagerTreeTestCase(BaseTestCase): - url = "/integrations/add_pagertree/" + def setUp(self): + super(AddPagerTreeTestCase, self).setUp() + self.url = "/projects/%s/add_pagertree/" % self.project.code def test_instructions_work(self): self.client.login(username="alice@example.org", password="password") @@ -15,7 +17,7 @@ class AddPagerTreeTestCase(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, "pagertree") diff --git a/hc/front/urls.py b/hc/front/urls.py index 14557c1f..a1a1c018 100644 --- a/hc/front/urls.py +++ b/hc/front/urls.py @@ -28,7 +28,6 @@ channel_urls = [ 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_pagertree/", views.add_pagertree, name="hc-add-pagertree"), path("add_slack/", views.add_slack, name="hc-add-slack"), path("add_slack_btn/", views.add_slack_btn, name="hc-add-slack-btn"), path("add_pushbullet/", views.add_pushbullet, name="hc-add-pushbullet"), @@ -64,6 +63,7 @@ project_urls = [ path("add_msteams/", views.add_msteams, name="hc-add-msteams"), 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_webhook/", views.add_webhook, name="hc-add-webhook"), path("badges/", views.badges, name="hc-badges"), path("checks/", views.my_checks, name="hc-checks"), diff --git a/hc/front/views.py b/hc/front/views.py index 47c828d6..3d97491c 100644 --- a/hc/front/views.py +++ b/hc/front/views.py @@ -977,20 +977,22 @@ def add_pdc(request, state=None): @login_required -def add_pagertree(request): +def add_pagertree(request, code): + project = _get_project_for_user(request, code) + if request.method == "POST": form = AddUrlForm(request.POST) if form.is_valid(): - channel = Channel(project=request.project, kind="pagertree") + channel = Channel(project=project, kind="pagertree") 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 = AddUrlForm() - ctx = {"page": "channels", "project": request.project, "form": form} + ctx = {"page": "channels", "project": project, "form": form} return render(request, "integrations/add_pagertree.html", ctx) diff --git a/templates/front/channels.html b/templates/front/channels.html index 7c639f9a..eb3273fd 100644 --- a/templates/front/channels.html +++ b/templates/front/channels.html @@ -288,7 +288,7 @@

PagerTree

DevOps Incident Management - On-Call Schedules, Alerts, & Notifications

- Add Integration + Add Integration
  • diff --git a/templates/integrations/add_pagertree.html b/templates/integrations/add_pagertree.html index e3ebef2c..059363fd 100644 --- a/templates/integrations/add_pagertree.html +++ b/templates/integrations/add_pagertree.html @@ -72,7 +72,7 @@

    Integration Settings

    -
    + {% csrf_token %}