remove channel doesn't crash

This commit is contained in:
Di Wu 2016-01-19 06:07:18 -08:00
parent 96b41ded9b
commit 01a9505cc7
2 changed files with 6 additions and 6 deletions

View File

@ -45,4 +45,4 @@ class RemoveChannelTestCase(BaseTestCase):
self.client.login(username="alice@example.org", password="password")
r = self.client.post(url)
assert r.status_code == 404
assert r.status_code == 302

View File

@ -336,11 +336,11 @@ def verify_email(request, code, token):
def remove_channel(request, code):
assert request.method == "POST"
channel = get_object_or_404(Channel, code=code)
if channel.user != request.user:
return HttpResponseForbidden()
channel.delete()
channel = Channel.objects.filter(code=code).first()
if channel:
if channel.user != request.user:
return HttpResponseForbidden()
channel.delete()
return redirect("hc-channels")