Example #1
0
def rh_curriculo_view(request):
    config = SiteConfig.objects.get(id = 1)
    pagina = PaginaRecursosHumanos.objects.get(id = 1)
    cadastrado = False
    novo_cadastro = FormCurriculo()
    if request.method == "POST":
        novo_usuario = User()
        novo_usuario.username = request.POST['login']
        novo_usuario.set_password(request.POST['senha'])
        novo_usuario.save()
        nascimento = date(int(request.POST['ano']), int(request.POST['mes']), int(request.POST['dia']))
        telefone = "%s%s" % (request.POST['ddd_telefone'], request.POST['telefone'])
        celular = "%s%s" % (request.POST['ddd_celular'], request.POST['celular'])  
        novo_cadastro = FormCurriculo(request.POST)
        if novo_cadastro.is_valid():
            novo_objeto = novo_cadastro.save()
            novo_objeto.telefone = telefone
            novo_objeto.nascimento = nascimento
            novo_objeto.celular = celular
            novo_objeto.usuario = novo_usuario
            caracteres = "abcdefghijklmnopqrstuvxzwy1234567890ABCDEFGHIJKLMNOPQRSTUVXZKWY"
            codigo_cadastro = ""
            for letra in range(1, 16):
                codigo_cadastro += caracteres[random.randint(0, 60)]
            novo_objeto.codigo_cadastro = codigo_cadastro
            novo_objeto.save()
            cadastrado = True        
    variaveis = RequestContext(request, {'formulario': novo_cadastro, 'pagina': pagina, 'config': config, 'cadastrado': cadastrado})
    return render_to_response('rh_form.html', variaveis)
Example #2
0
def rh_curriculo_editar_view(request, id_curriculo = False):
    config = SiteConfig.objects.get(id = 1)
    pagina = PaginaRecursosHumanos.objects.get(id = 1)
    curriculo = Curriculo.objects.get(codigo_cadastro = id_curriculo)
    formulario = FormCurriculo(instance = curriculo)                                                      
    editado = False
    if request.method == "POST":        
        nascimento = date(int(request.POST['ano']), int(request.POST['mes']), int(request.POST['dia']))
        telefone = "%s%s" % (request.POST['ddd_telefone'], request.POST['telefone'])
        celular = "%s%s" % (request.POST['ddd_celular'], request.POST['celular'])
        formulario = FormCurriculo(request.POST, instance = curriculo)
        if formulario.is_valid():
            novo_objeto = formulario.save()
            novo_objeto.telefone = telefone
            novo_objeto.nascimento = nascimento
            novo_objeto.celular = celular
            novo_objeto.save()
            editado = True        
    variaveis = RequestContext(request, {'formulario': formulario, 'pagina': pagina, 'config': config, 'editado': editado, 'curriculo': curriculo})
    return render_to_response('rh_form_editar.html', variaveis)