diff --git a/hc/api/admin.py b/hc/api/admin.py index b05d48d8..8b4b40d4 100644 --- a/hc/api/admin.py +++ b/hc/api/admin.py @@ -165,30 +165,10 @@ class ChannelsAdmin(admin.ModelAdmin): return obj.user.email if obj.user else None def formatted_kind(self, obj): - if obj.kind == "pd": - return "PagerDuty" - elif obj.kind == "victorops": - return "VictorOps" - elif obj.kind == "pushbullet": - return "Pushbullet" - elif obj.kind == "discord": - return "Discord" - elif obj.kind == "po": - return "Pushover" - elif obj.kind == "webhook": - return "Webhook" - elif obj.kind == "slack": - return "Slack" - elif obj.kind == "hipchat": - return "HipChat" - elif obj.kind == "opsgenie": - return "OpsGenie" - elif obj.kind == "email" and obj.email_verified: - return "Email" - elif obj.kind == "email" and not obj.email_verified: + if obj.kind == "email" and not obj.email_verified: return "Email (unverified)" - else: - raise NotImplementedError("Bad channel kind: %s" % obj.kind) + + return obj.get_kind_display() formatted_kind.short_description = "Kind" formatted_kind.allow_tags = True diff --git a/hc/api/tests/test_admin.py b/hc/api/tests/test_admin.py index 0c4d68c9..7f55787f 100644 --- a/hc/api/tests/test_admin.py +++ b/hc/api/tests/test_admin.py @@ -15,8 +15,17 @@ class ApiAdminTestCase(BaseTestCase): def test_it_shows_channel_list_with_pushbullet(self): self.client.login(username="alice@example.org", password="password") - ch = Channel(user=self.alice, kind="pushbullet", value="test-token") - ch.save() + Channel.objects.create(user=self.alice, kind="pushbullet", + value="test-token") r = self.client.get("/admin/api/channel/") self.assertContains(r, "Pushbullet") + + def test_it_shows_channel_list_with_unverified_email(self): + self.client.login(username="alice@example.org", password="password") + + Channel.objects.create(user=self.alice, kind="email", + value="foo@example.org") + + r = self.client.get("/admin/api/channel/") + self.assertContains(r, "Email (unverified)") diff --git a/templates/front/channels.html b/templates/front/channels.html index e43748ca..41159478 100644 --- a/templates/front/channels.html +++ b/templates/front/channels.html @@ -26,18 +26,7 @@ {% for ch in channels %}