示例#1
0
def handleGezinAdd(request):
    # Default mode is "view"
    formState = "ADD"
    
    # On cancel redirect to list
    cancelRedirect = "/leden"
    
    # Check if form has been submitted
    if (request.method == "POST"):
        # A form bound to the POST data
        gezinForm = GezinForm(request.POST)
        # Check if validations pass
        if (gezinForm.is_valid()):
            # Form is valid
            gezinForm.save()
            return HttpResponseRedirect("./%d/" % (gezinForm.instance.idgezin))
        else:
            formState = "MODIFY"
    else:
        # No POST data
        gezinForm = GezinForm()
    
    return render_to_response("KB/gezinDetails.html",
                              {"gezinForm": gezinForm,
                               "formState": formState,
                               "cancelRedirect": cancelRedirect},
                               context_instance=RequestContext(request))
示例#2
0
def handleGezinDetails(request, gezinId):
    gezin = Gezin.objects.get(idgezin=gezinId)
    persoonList = list(Persoon.objects.filter(idgezin=gezinId).order_by("idgezinsrol", "dtmgeboortedatum"))
        
    # Default mode is "view"
    formState = "VIEW"
    
    # On cancel reload current page
    cancelRedirect = ""
    
    # Check if form has been submitted
    if (request.method == "POST"):
        # A form bound to the POST data
        gezinForm = GezinForm(request.POST, instance=gezin)
        # Check if validations pass
        if (gezinForm.is_valid()):
            # Form is valid
            gezinForm.save()
            gezinId = gezinForm.instance.idgezin
            formState = "VIEW"
        else:
            formState = "MODIFY"
    else:
        # No POST data
        gezinForm = GezinForm(instance=gezin)
    
    return render_to_response("KB/gezinDetails.html",
                              {"gezinForm": gezinForm,
                               "persoonList": persoonList,
                               "formState": formState,
                               "cancelRedirect": cancelRedirect},
                               context_instance=RequestContext(request))