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: