Exemple #1
0
def create(request):
    data = {}
    if request.method == "POST":
        form = ProtocolForm(request.POST)
        if form.is_valid():
            protocol = form.save()

            return redirect(reverse("manage_protocols"))
    else:
        form = ProtocolForm()

    data["form"] = form
    return render(request, "protocols/create.html", data)
Exemple #2
0
def create(request):
    data = {}
    if request.method == 'POST':
        form = ProtocolForm(request.POST)
        if form.is_valid():
            protocol = form.save()
            
            return redirect(reverse('manage_protocols'))
    else:
        form = ProtocolForm()
        
    data['form'] = form    
    return render(request, 'protocols/create.html', data)
Exemple #3
0
def update(request, protocol):
    data = {}
    protocol = get_object_or_404(db.Protocol, label=protocol)

    if request.method == "POST":
        form = ProtocolForm(request.POST, instance=protocol)
        if form.is_valid():
            protocol = form.save()
            return redirect(reverse("manage_protocols"))
    else:
        form = ProtocolForm(instance=protocol)

    data["form"] = form
    data["protocol"] = protocol
    return render(request, "protocols/update.html", data)
Exemple #4
0
def update(request, protocol):
    data = {}
    protocol = get_object_or_404(db.Protocol, label=protocol)

    if request.method == 'POST':
        form = ProtocolForm(request.POST, instance=protocol)
        if form.is_valid():
            protocol = form.save()
            return redirect(reverse('manage_protocols'))
    else:
        form = ProtocolForm(instance=protocol)
        
    data['form'] = form   
    data['protocol'] = protocol 
    return render(request, 'protocols/update.html', data)