Ejemplo n.º 1
0
def handle_componentStatus(request):
    logger = logging.getLogger("webapp")
    logger.info("run handle_componentStatus run")

    if request.method == "POST":

        form = ComponentStatusForm(request.POST)

        if form.is_valid():
            t = ComponentStatus()
            t.name = form.cleaned_data["name"]

            t.save()

            return HttpResponseRedirect("/componentstatuss/")

    else:
        form = ComponentStatusForm()
    return render(
        request, "component/generic_detail.html", {"form": form, "action": "/componentstatus/", "http_method": "POST"}
    )
Ejemplo n.º 2
0
def edit_componentStatus(request, componentStatusid=None):
    logger = logging.getLogger("webapp")
    logger.info("run edit_componentStatus run")

    if componentStatusid:
        t = ComponentStatus.objects.get(id=int(componentStatusid))

        if request.method == "POST":
            # update record with submitted values

            logger.info("run submit_edit run")
            form = ComponentStatusForm(request.POST, instance=t)

            if form.is_valid():
                logger.info("updating ComponentStatus")
                logger.info(form.cleaned_data)
                t.name = form.cleaned_data["name"]

                t.save()

                return HttpResponseRedirect("/componentstatuss/")

            return render(
                request,
                "component/generic_detail.html",
                {"form": form, "action": "/componentstatus/" + componentStatusid + "/", "http_method": "POST"},
            )
        else:
            # load record to allow edition

            form = ComponentStatusForm(instance=t)
            return render(
                request,
                "component/generic_detail.html",
                {"form": form, "action": "/componentstatus/" + componentStatusid + "/", "http_method": "POST"},
            )
    else:
        return HttpResponseRedirect("/componentStatuss/")