Ejemplo n.º 1
0
def template_new(request):
    if request.method == 'POST':
        form = TemplateForm(request.POST)

        if form.is_valid():
            t = form.save(commit=False)
            t.user = request.user
            t.save()
            return HttpResponseRedirect('/control/templates')
    else:
        form = TemplateForm()

    return render_to_response('control/template.html', {'form': form},
                              context_instance=RequestContext(request))
Ejemplo n.º 2
0
def template_edit(request, template_id):
    template = get_object(request, Template, id=template_id)

    if request.method == 'POST':
        form = TemplateForm(request.POST, instance=template)

        if form.is_valid():
            t = form.save(commit=False)
            t.user = request.user
            t.save()
            return HttpResponseRedirect('/control/templates')
    else:
        form = TemplateForm(instance=template)

    return render_to_response('control/template.html', {'form': form},
                              context_instance=RequestContext(request))