Browse Source

Remove last references of the hc-channels route.

pull/340/head
Pēteris Caune 5 years ago
parent
commit
318934697f
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
4 changed files with 11 additions and 46 deletions
  1. +0
    -1
      hc/accounts/views.py
  2. +9
    -17
      hc/front/tests/test_channels.py
  3. +0
    -1
      hc/front/urls.py
  4. +2
    -27
      hc/front/views.py

+ 0
- 1
hc/accounts/views.py View File

@ -39,7 +39,6 @@ NEXT_WHITELIST = (
"hc-checks",
"hc-details",
"hc-log",
"hc-channels",
"hc-p-channels",
"hc-add-slack",
"hc-add-pushover",


+ 9
- 17
hc/front/tests/test_channels.py View File

@ -17,7 +17,7 @@ class ChannelsTestCase(BaseTestCase):
ch.save()
self.client.login(username="[email protected]", 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="[email protected]", 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="[email protected]", 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="[email protected]", 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="[email protected]", 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="[email protected]", 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="[email protected]", 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="[email protected]", 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="[email protected]", 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="[email protected]", password="password")
r = self.client.get("/integrations/")
r = self.client.get(self.channels_url)
self.assertContains(r, "broken-channels", status_code=200)

+ 0
- 1
hc/front/urls.py View File

@ -23,7 +23,6 @@ check_urls = [
]
channel_urls = [
path("", views.channels, name="hc-channels"),
path(
"add_pushbullet/",
views.add_pushbullet_complete,


+ 2
- 27
hc/front/views.py View File

@ -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)


Loading…
Cancel
Save