Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions contentcuration/contentcuration/viewsets/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,9 @@ def remove_self(self, request, pk=None):
if not channel_id:
return HttpResponseBadRequest("Channel ID is required.")

channel = Channel.objects.get(id=channel_id)
if not channel:
try:
channel = Channel.objects.get(id=channel_id)
except Channel.DoesNotExist:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: Good fix. The previous code had a logic error — Django's .get() raises DoesNotExist rather than returning None, so the old if not channel: check was unreachable dead code. The try/except correctly handles the exception and makes the 404 path actually work.

return HttpResponseNotFound("Channel not found {}".format(channel_id))

if request.user != user and not request.user.can_edit(channel_id):
Expand Down
Loading