Browse Source

remove channel doesn't crash

pull/34/head
Di Wu 9 years ago
parent
commit
01a9505cc7
2 changed files with 6 additions and 6 deletions
  1. +1
    -1
      hc/front/tests/test_remove_channel.py
  2. +5
    -5
      hc/front/views.py

+ 1
- 1
hc/front/tests/test_remove_channel.py View File

@ -45,4 +45,4 @@ class RemoveChannelTestCase(BaseTestCase):
self.client.login(username="[email protected]", password="password")
r = self.client.post(url)
assert r.status_code == 404
assert r.status_code == 302

+ 5
- 5
hc/front/views.py 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")


Loading…
Cancel
Save