From d5bae3d3d80718cbf9dedb270db8329588f5ce84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Mon, 20 May 2019 12:20:12 +0300 Subject: [PATCH] Fix the "Integrations" page for when the user has no active project --- CHANGELOG.md | 1 + hc/front/tests/test_channels.py | 8 ++++++++ hc/front/views.py | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 493f50c9..76713dc7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ All notable changes to this project will be documented in this file. ### Bug Fixes - Fix badges for tags containing special characters (#240, #237) +- Fix the "Integrations" page for when the user has no active project ## 1.7.0 - 2019-05-02 diff --git a/hc/front/tests/test_channels.py b/hc/front/tests/test_channels.py index e6e95991..ba68545f 100644 --- a/hc/front/tests/test_channels.py +++ b/hc/front/tests/test_channels.py @@ -106,3 +106,11 @@ class ChannelsTestCase(BaseTestCase): 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, "/") diff --git a/hc/front/views.py b/hc/front/views.py index 6a5bce7e..d9fa5837 100644 --- a/hc/front/views.py +++ b/hc/front/views.py @@ -560,6 +560,11 @@ def badges(request, code): @login_required def channels(request): + + if not request.project: + # This can happen when the user deletes their only project. + return redirect("hc-index") + if request.method == "POST": code = request.POST["channel"] try: