def _get_channel_for_user(request, code):
    ' Return specified channel if current user has access to it. '
    assert request.user.is_authenticated
    channel = get_object_or_404(Channel.objects.select_related('project'), code=code)
    if request.user.is_superuser:
        return (channel, True)
    if (request.user.id == channel.project.owner_id):
        return (channel, True)
    membership = get_object_or_404(Member, project=channel.project, user=request.user)
    return (channel, membership.rw)
Return specified channel if current user has access to it.
def _get_channel_for_user(request, code):
    '  '
    assert request.user.is_authenticated
    channel = get_object_or_404(Channel.objects.select_related('project'), code=code)
    if request.user.is_superuser:
        return (channel, True)
    if (request.user.id == channel.project.owner_id):
        return (channel, True)
    membership = get_object_or_404(Member, project=channel.project, user=request.user)
    return (channel, membership.rw)