Пример #1
0
def add_samplingpoint(request):
    template_name = "samplingpoints.html"
    if request.method == "POST":  # If the form has been submitted...
        form = SamplingPointForm(request.POST)  # A form bound to the POST data
        if form.is_valid():  # All validation rules pass
            # saving the form data is not cleaned
            form.save()
            return message(request, "Sampling Point Added", link="/samplingpoints")
    else:
        form = SamplingPointForm()  # An unbound form

    return render_to_response(request, template_name, {"form": form})
Пример #2
0
def edit_samplingpoints(request, pk):
    template_name = "samplingpoints.html"
    point = get_object_or_404(SamplingPoint, pk=pk)
    if request.method == "POST":  # If the form has been submitted...
        form = SamplingPointForm(request.POST, instance=point)  # A form bound to the POST data
        if form.is_valid():  # All validation rules pass
            # saving the form data is not cleaned
            form.save()
            return message(request, "Sampling Point Updated", link="/samplingpoints")
    else:
        form = SamplingPointForm(instance=point)  # An unbound form

    return render_to_response(request, template_name, {"form": form, "point": point})