diff --git a/hc/accounts/views.py b/hc/accounts/views.py index fb1d1c79..d463a95f 100644 --- a/hc/accounts/views.py +++ b/hc/accounts/views.py @@ -39,7 +39,6 @@ NEXT_WHITELIST = ( "hc-checks", "hc-details", "hc-log", - "hc-channels", "hc-p-channels", "hc-add-slack", "hc-add-pushover", diff --git a/hc/front/tests/test_channels.py b/hc/front/tests/test_channels.py index 08ddf903..d6ea3113 100644 --- a/hc/front/tests/test_channels.py +++ b/hc/front/tests/test_channels.py @@ -17,7 +17,7 @@ class ChannelsTestCase(BaseTestCase): ch.save() self.client.login(username="alice@example.org", password="password") - r = self.client.get("/integrations/") + r = self.client.get(self.channels_url) self.assertContains(r, "foo-team", status_code=200) self.assertContains(r, "#bar") @@ -38,7 +38,7 @@ class ChannelsTestCase(BaseTestCase): ch.save() self.client.login(username="alice@example.org", password="password") - r = self.client.get("/integrations/") + r = self.client.get(self.channels_url) self.assertEqual(r.status_code, 200) # These are inside a modal: @@ -52,7 +52,7 @@ class ChannelsTestCase(BaseTestCase): ch.save() self.client.login(username="alice@example.org", password="password") - r = self.client.get("/integrations/") + r = self.client.get(self.channels_url) self.assertEqual(r.status_code, 200) self.assertContains(r, "(normal priority)") @@ -69,7 +69,7 @@ class ChannelsTestCase(BaseTestCase): n.save() self.client.login(username="alice@example.org", password="password") - r = self.client.get("/integrations/") + r = self.client.get(self.channels_url) self.assertEqual(r.status_code, 200) self.assertContains(r, "Disabled") @@ -79,7 +79,7 @@ class ChannelsTestCase(BaseTestCase): channel.save() self.client.login(username="alice@example.org", password="password") - r = self.client.get("/integrations/") + r = self.client.get(self.channels_url) self.assertEqual(r.status_code, 200) self.assertContains(r, "Unconfirmed") @@ -91,7 +91,7 @@ class ChannelsTestCase(BaseTestCase): channel.save() self.client.login(username="alice@example.org", password="password") - r = self.client.get("/integrations/") + r = self.client.get(self.channels_url) self.assertEqual(r.status_code, 200) self.assertContains(r, "(down only)") @@ -103,7 +103,7 @@ class ChannelsTestCase(BaseTestCase): channel.save() self.client.login(username="alice@example.org", password="password") - r = self.client.get("/integrations/") + r = self.client.get(self.channels_url) self.assertEqual(r.status_code, 200) self.assertContains(r, "(up only)") @@ -113,22 +113,14 @@ class ChannelsTestCase(BaseTestCase): ch.save() self.client.login(username="alice@example.org", password="password") - r = self.client.get("/integrations/") + r = self.client.get(self.channels_url) self.assertEqual(r.status_code, 200) self.assertContains(r, "SMS to +123") - def test_it_requires_current_project(self): - self.profile.current_project = None - self.profile.save() - - self.client.login(username="alice@example.org", password="password") - r = self.client.get("/integrations/") - self.assertRedirects(r, "/") - def test_it_shows_channel_issues_indicator(self): Channel.objects.create(kind="sms", project=self.project, last_error="x") self.client.login(username="alice@example.org", password="password") - r = self.client.get("/integrations/") + r = self.client.get(self.channels_url) self.assertContains(r, "broken-channels", status_code=200) diff --git a/hc/front/urls.py b/hc/front/urls.py index f54e6fa2..c1970f10 100644 --- a/hc/front/urls.py +++ b/hc/front/urls.py @@ -23,7 +23,6 @@ check_urls = [ ] channel_urls = [ - path("", views.channels, name="hc-channels"), path( "add_pushbullet/", views.add_pushbullet_complete, diff --git a/hc/front/views.py b/hc/front/views.py index 404a4618..434e1c7a 100644 --- a/hc/front/views.py +++ b/hc/front/views.py @@ -21,7 +21,6 @@ from django.shortcuts import get_object_or_404, redirect, render from django.template.loader import get_template, render_to_string from django.urls import reverse from django.utils import timezone -from django.utils.crypto import get_random_string from django.views.decorators.csrf import csrf_exempt from django.views.decorators.http import require_POST from hc.accounts.models import Project @@ -648,14 +647,8 @@ def badges(request, code): @login_required -def channels(request, code=None): - if code: - project = _get_project_for_user(request, code) - else: - project = request.project - if project is None: - # This can happen when the user deletes their only project. - return redirect("hc-index") +def channels(request, code): + project = _get_project_for_user(request, code) if request.method == "POST": code = request.POST["channel"] @@ -913,24 +906,6 @@ def add_shell(request, code): return render(request, "integrations/add_shell.html", ctx) -def _prepare_state(request, session_key): - state = get_random_string() - request.session[session_key] = state - return state - - -def _get_validated_code(request, session_key, key="code"): - if session_key not in request.session: - return None - - session_state = request.session.pop(session_key) - request_state = request.GET.get("state") - if session_state is None or session_state != request_state: - return None - - return request.GET.get(key) - - @login_required def add_pd(request, code): project = _get_project_for_user(request, code)