Exemple #1
0
def all_flow_toggles(request):
    if request.method == 'POST':
        form = FlowToggleForm(request.POST)
        if form.is_valid():
            return form.save()
        else:
            errors = _form_errors(form)
            raise kbapi.BadRequestError(errors)

    return models.FlowToggle.objects.all()
Exemple #2
0
def all_flow_toggles(request):
    if request.method == "POST":
        form = FlowToggleForm(request.POST)
        if form.is_valid():
            return form.save()
        else:
            errors = _form_errors(form)
            raise kbapi.BadRequestError(errors)

    return models.FlowToggle.objects.all()
Exemple #3
0
def get_flow_toggle(request, flow_toggle_id):
    toggle = get_object_or_404(models.FlowToggle, id=flow_toggle_id)

    if request.method == 'DELETE':
        toggle.delete()
        return RESULT_OK

    elif request.method == 'POST':
        form = FlowToggleForm(request.POST, instance=toggle)
        if form.is_valid():
            toggle = form.save()
        else:
            errors = _form_errors(form)
            raise kbapi.BadRequestError(errors)

    return protolib.ToProto(toggle, full=True)
Exemple #4
0
def get_flow_toggle(request, flow_toggle_id):
    toggle = get_object_or_404(models.FlowToggle, id=flow_toggle_id)

    if request.method == "DELETE":
        toggle.delete()
        return RESULT_OK

    elif request.method == "POST":
        form = FlowToggleForm(request.POST, instance=toggle)
        if form.is_valid():
            toggle = form.save()
        else:
            errors = _form_errors(form)
            raise kbapi.BadRequestError(errors)

    return protolib.ToProto(toggle, full=True)