@login_required
@require_POST
def switch_channel(request, code, channel_code):
    check = _get_rw_check_for_user(request, code)
    channel = get_object_or_404(Channel, code=channel_code)
    if (channel.project_id != check.project_id):
        return HttpResponseBadRequest()
    if (request.POST.get('state') == 'on'):
        channel.checks.add(check)
    else:
        channel.checks.remove(check)
    return HttpResponse()
@login_required
@require_POST
def switch_channel(request, code, channel_code):
    check = _get_rw_check_for_user(request, code)
    channel = get_object_or_404(Channel, code=channel_code)
    if (channel.project_id != check.project_id):
        return HttpResponseBadRequest()
    if (request.POST.get('state') == 'on'):
        channel.checks.add(check)
    else:
        channel.checks.remove(check)
    return HttpResponse()