diff --git a/hc/front/tests/test_add_victorops.py b/hc/front/tests/test_add_victorops.py index fc913680..9d7224eb 100644 --- a/hc/front/tests/test_add_victorops.py +++ b/hc/front/tests/test_add_victorops.py @@ -3,7 +3,9 @@ from hc.test import BaseTestCase class AddVictorOpsTestCase(BaseTestCase): - url = "/integrations/add_victorops/" + def setUp(self): + super(AddVictorOpsTestCase, self).setUp() + self.url = "/projects/%s/add_victorops/" % self.project.code def test_instructions_work(self): self.client.login(username="alice@example.org", password="password") @@ -15,7 +17,7 @@ class AddVictorOpsTestCase(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, "victorops") diff --git a/hc/front/urls.py b/hc/front/urls.py index 395c11e3..62c38e08 100644 --- a/hc/front/urls.py +++ b/hc/front/urls.py @@ -33,7 +33,6 @@ channel_urls = [ path("add_pushbullet/", views.add_pushbullet, name="hc-add-pushbullet"), path("add_discord/", views.add_discord, name="hc-add-discord"), path("add_pushover/", views.add_pushover, name="hc-add-pushover"), - path("add_victorops/", views.add_victorops, name="hc-add-victorops"), path("telegram/bot/", views.telegram_bot, name="hc-telegram-webhook"), path("add_telegram/", views.add_telegram, name="hc-add-telegram"), path("add_whatsapp/", views.add_whatsapp, name="hc-add-whatsapp"), @@ -64,6 +63,7 @@ project_urls = [ path("add_pagertree/", views.add_pagertree, name="hc-add-pagertree"), path("add_prometheus/", views.add_prometheus, name="hc-add-prometheus"), 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"), 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 d53bd5fc..d2e9f0b6 100644 --- a/hc/front/views.py +++ b/hc/front/views.py @@ -1295,20 +1295,22 @@ def add_opsgenie(request, code): @login_required -def add_victorops(request): +def add_victorops(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="victorops") + channel = Channel(project=project, kind="victorops") 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_victorops.html", ctx) diff --git a/templates/front/channels.html b/templates/front/channels.html index b007c484..00aee543 100644 --- a/templates/front/channels.html +++ b/templates/front/channels.html @@ -380,7 +380,7 @@

VictorOps

On-call scheduling, alerting, and incident tracking.

- Add Integration + Add Integration {% if enable_whatsapp %} diff --git a/templates/integrations/add_victorops.html b/templates/integrations/add_victorops.html index 8b9ed7aa..7a370582 100644 --- a/templates/integrations/add_victorops.html +++ b/templates/integrations/add_victorops.html @@ -77,7 +77,7 @@

Integration Settings

-
+ {% csrf_token %}