Exemple #1
0
def perfil(request):

    try:
        perfil = Perfil.objects.filter(user="******")
        if request.method == 'POST':
            Perfil.objects.filter(pk=perfil).update(
                nome=request.POST["nome"],
                cargo=request.POST["cargo"],
                area=request.POST["area"],
                matricula=request.POST["matricula"])
            return HttpResponseRedirect('/perfil/contato/')
        formperfil = PerfilForm(instance=perfil[0])
    except:
        formperfil = PerfilForm()

        if request.method == 'POST':
            formperfil = PerfilForm(request.POST, request.FILES)
            formperfil.is_valid()
            formperfil.save()

    return render_to_response('perfil.html',
                              locals(),
                              context_instance=RequestContext(request))
Exemple #2
0
def perfil(request):
    if Perfil.objects.filter(user=request.session['username']):
        perfil = Perfil.objects.filter(user=request.session['username'])

        formperfil = PerfilForm(instance=perfil[0])
        if request.method == 'POST':
            dados_form = PerfilForm(request.POST,
                                    request.FILES,
                                    instance=perfil[0])
            dados_form.save()
            #Perfil.objects.filter(pk = perfil).update(nome = request.POST["nome"],cargo = request.POST["cargo"],area = request.POST["area"],matricula =request.POST["matricula"],user = request.session['username'],foto = request.FILES['foto'])
            return HttpResponseRedirect('/perfil/profissional/')
    else:
        formperfil = PerfilForm(initial={"user": request.session['username']})

    if request.method == 'POST':
        formperfil = PerfilForm(request.POST, request.FILES)
        formperfil.is_valid()
        formperfil.save()

    list_fotos = Album.objects.filter(user=request.session['username'])
    return render_to_response('perfil.html',
                              locals(),
                              context_instance=RequestContext(request))