Esempio n. 1
0
def item(request, nr_item):
    item = get_object_or_404(ItemAgenda, usuario=request.user, pk=nr_item)
    form = FormItemAgenda(request.POST or None,
                            request.FILES or None, instance=item)
    if form.is_valid():
        form.save()
        return redirect("/")
    return render(request, "item.html", {'form': form})
Esempio n. 2
0
def item(request, nr_item):
    item = get_object_or_404(ItemAgenda, usuario=request.user, id=nr_item)
    form = FormItemAgenda(request.POST or None, request.FILES or None, instance=item)
    if form.is_valid():
        form.save()
        return HttpResponseRedirect("/")
    return render_to_response("item.html", {'form': form},
            context_instance=RequestContext(request))
Esempio n. 3
0
def item(request, nr_item):
    item = ItemAgenda.objects.get(pk=nr_item)
    if request.method == 'POST':  # Formulário enviado
        form = FormItemAgenda(request.POST, request.FILES, instance=item)
        if form.is_valid():
            form.save()
        return render_to_response("salvo.html", {})
    form = FormItemAgenda(instance=item)
    return render_to_response("item.html", {'form': form, 'item': item})
Esempio n. 4
0
def adiciona(request):
    if request.method == 'POST':
        form = FormItemAgenda(request.POST, request.FILES)
        if form.is_valid():
            form.save()
            return render_to_response("salvo.html", {})
    else:
        form = FormItemAgenda()
    return render_to_response("item.html", {'form':form}, context_instance=RequestContext(request))
Esempio n. 5
0
def adiciona(request):
    if request.method == 'POST':
        form = FormItemAgenda(request.POST, request.FILES)
        if form.is_valid():
            form.save()
            return render_to_response("salvo.html", {})
    else:
        form = FormItemAgenda()
    return render_to_response("item.html", {'form': form},
                              context_instance=RequestContext(request))
Esempio n. 6
0
def adiciona(request):
    if request.method == 'POST':  # Formulário enviado
        form = FormItemAgenda(request.POST, request.FILES)
        if form.is_valid():
            form.save()
            return redirect("/")
    else:
        # Exibe formulário em branco
        form = FormItemAgenda()
    return render(request, "adiciona.html", {'form': form})
Esempio n. 7
0
def adiciona_(request):
    if request.method == 'POST': # Formulário enviado
        form = FormItemAgenda(request.POST, request.FILES)
        if form.is_valid():
            form.save()
            return redirect("/")
    else:
        # Exibe formulário em branco
        form = FormItemAgenda()
    return render(request, "adiciona.html", {'form': form})
Esempio n. 8
0
def item(request, nr_item):
    item = get_object_or_404(ItemAgenda, pk=nr_item)
    if request.method == "POST":
        form = FormItemAgenda(request.POST, request.FILES, instance=item)
        if form.is_valid():
            form.save()
            return render_to_response("salvo.html", {})
    else:
        form = FormItemAgenda(instance=item)
    return render_to_response('item.html', {'form': form}, context_instance=RequestContext(request))
Esempio n. 9
0
def item(request, nr_item):
    item = get_object_or_404(ItemAgenda, pk=nr_item)
    form = FormItemAgenda(request.POST or None,
                          request.FILES or None,
                          instance=item)
    if form.is_valid():
        form.save()
        return redirect("/")

    return render(request, "item.html", {'form': form})
Esempio n. 10
0
def item(request, nr_item):
    item = get_object_or_404(ItemAgenda, pk=nr_item)
    if request.method == "POST":
        form = FormItemAgenda(request.POST, request.FILES, instance=item)
        if form.is_valid():
            form.save()
            return render_to_response("salvo.html", {})
    else:
        form = FormItemAgenda(instance=item)
    return render_to_response("item.html", {'form': form},
                              context_instance=RequestContext(request))
Esempio n. 11
0
def item(request, nr_item):
    item = get_object_or_404(ItemAgenda, usuario=request.user, id=nr_item)
    if request.method == "POST":
        form = FormItemAgenda(request.POST, request.FILES, instance=item)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect("/")
    else:
        form = FormItemAgenda(instance=item)
    return render_to_response("item.html", {'form': form},
                              context_instance=RequestContext(request))
Esempio n. 12
0
def adiciona(request):
    form = FormItemAgenda(request.POST or None, request.FILES or None)
    if form.is_valid():
        item = form.save(commit=False)
        item.usuario = request.user
        item.save()
        return redirect("/")
    return render(request, "adiciona.html", {'form': form})
Esempio n. 13
0
def adiciona(request):
	if request.method == "POST":
		form = FormItemAgenda(request.POST, request.FILES)
		if form.is_valid():
			item = form.save(commit=False)
			item.usuario = request.user
			item.save()
			return render_to_response("salvo.html",{})
	else:
		form = FormItemAgenda()
	return render_to_response("adiciona.html",{'form':form},
				  context_instance=RequestContext(request))
Esempio n. 14
0
def adiciona(request):
    if request.method == 'POST':  # Formulário enviado
        form = FormItemAgenda(request.POST, request.FILES)
        if form.is_valid():

            form.save()
            # Formulário válido.
            #dados = form.cleaned_data
            #item = ItemAgenda(
            #    data = dados['data'],
            #    hora = dados['hora'],
            #    titulo = dados['titulo'],
            #    descricao = dados['descricao']
            #)
            #item.save()

        return render_to_response("salvo.html")
    else:
        form = FormItemAgenda()

    return render_to_response("adiciona.html", {'form': form},
                              context_instance=RequestContext(request))
Esempio n. 15
0
def item(request, id_item):
    # pk = primary key
    item = get_object_or_404(ItemAgenda, pk=id_item, usuario=request.user)
    if request.method == 'POST':
        form = FormItemAgenda(request.POST, request.FILES, instance=item)
        if form.is_valid():
            item = form.save(commit=False)
            item.usuario = request.user
            item.save()
            return render(request, 'salvo.html', {})
    else:
        form = FormItemAgenda(instance=item)
    return render(request, 'item.html', {'form': form})
Esempio n. 16
0
def adiciona(request):
    form = FormItemAgenda(request.POST or None, request.FILES or None)
    if form.is_valid():
        # Formulário válido
        item = form.save(commit=False)
        item.usuario = request.user
        item.save()
        
        # Mensagem de formulário cadastrado
        return HttpResponseRedirect("/")

    return render_to_response("adiciona.html", {'form': form},
            context_instance=RequestContext(request))
def adiciona(request):
    if request.method == "POST":
        form = FormItemAgenda(request.POST, request.FILES)
        if form.is_valid():
            item = form.save(commit=False)
            item.usuario = request.user
            item.save()
            form.save_m2m()
            return render_to_response("salvo.html", {})
    else:
        form = FormItemAgenda()
    return render_to_response("adiciona.html", {'form': form},
                              context_instance=RequestContext(request))
Esempio n. 18
0
def editar(request, nr_item):
    item = get_object_or_404(ItemAgenda, pk=nr_item, usuario=request.user)
    if request.method == 'POST':
        form = FormItemAgenda(request.POST, request.FILES, instance=item)
        if form.is_valid():
            item = form.save(commit=False)
            item.usuario = request.user
            item.participantes = form.cleaned_data['participantes']
            item.save()
            return render_to_response('agenda/salvo.html', {})
    else:
        form = FormItemAgenda(instance=item)
    return render_to_response('agenda/adiciona.html', {'form': form}, context_instance=RequestContext(request))
Esempio n. 19
0
def item(request, nr_item):
	item = get_object_or_404(ItemAgenda, pk=nr_item, usuario=request.user)
	if request.method == "POST":
		form = FormItemAgenda(request.POST, request.FILES, instance=item)
		if form.is_valid():
			item = form.save(commit=False)
			item.usuario = request.user
			item.save()
			form.save_m2m()
			return render_to_response("atualizado.html", {})
	else:
		form = FormItemAgenda(instance=item)
	return render_to_response("item.html", {'form': form}, context_instance=RequestContext(request))
Esempio n. 20
0
def adiciona(request):

    if request.method == 'POST':
        form = FormItemAgenda(request.POST, request.FILES)

        if form.is_valid():
            item = form.save(commit=False)
            item.usuario = request.user
            item.save()
            return render(request, 'salvo.html', {'form': form})

    else:
        form = FormItemAgenda()
    return render(request, 'adiciona.html', {'form': form})
Esempio n. 21
0
def adiciona(request):
    if request.method == 'POST':    # Formulário enviado
        form = FormItemAgenda(request.POST, request.FILES)
        if form.is_valid():         # Formulário válidou! Yey!
            item = form.save(commit=False)
            item.usuario = request.user
            item.save()
            item.participantes = form.cleaned_data['participantes']
            item.save()
            return render_to_response("agenda/salvo.html", {})
    else:   # Página acessada via URL, sem POST
        form = FormItemAgenda()     # Exibe Formulário em branco

    return render_to_response("agenda/adiciona.html", {'form':form}, context_instance=RequestContext(request))
def item(request, nr_item):
    item = get_object_or_404(ItemAgenda, id=nr_item, usuario=request.user)
    if request.method == "POST":
        form = FormItemAgenda(request.POST, request.FILES, instance=item)
        if form.is_valid():
            item = form.save(commit=False)
            item.usuario = request.user
            item.save()
            form.save_m2m()
            return render_to_response("salvo.html", {})
    else:
        form = FormItemAgenda(instance=item)
    return render_to_response("item.html", {'form': form},
                              context_instance=RequestContext(request))
Esempio n. 23
0
def adiciona(request):
	if request.method == 'POST': #form enviado
		form = FormItemAgenda(request.POST, request.FILES)
		if form.is_valid():
			dados = form.cleaned_data
			item = ItemAgenda(data = dados['data'],
						hora = dados['hora'],
						titulo = dados['titulo'],
						descricao = dados['descricao'])
			item = form.save(commit=False)
			item.usuario = request.user
			item.save()
			return render_to_response('salvo.html', {})
	else:    # via link - GET
		form = FormItemAgenda()	
	return render_to_response("adiciona.html", {'form': form}, context_instance=RequestContext(request))
Esempio n. 24
0
def adiciona(request):
    if request.method == 'POST': # Formulário enviado
        form = FormItemAgenda(request.POST, request.FILES)
        if form.is_valid():
            # Formulário válido.
            item = form.save(commit=False)
            item.usuario = request.user
            item.save()

            # Mensagem de formulário cadastrado
            return render_to_response("salvo.html", {}, context_instance=RequestContext(request))
    else:
        # Exibe formulário em branco
        form = FormItemAgenda()

    return render_to_response("adiciona.html", {'form': form}, context_instance=RequestContext(request))
Esempio n. 25
0
def adiciona(request):
    if request.method == 'POST':  # Formulário enviado
        form = FormItemAgenda(request.POST, request.FILES)
        if form.is_valid():
            # Formulário válido.
            item = form.save(commit=False)
            item.usuario = request.user
            item.save()

            # Mensagem de formulário cadastrado
            return HttpResponseRedirect("/")
    else:
        # Exibe formulário em branco
        form = FormItemAgenda()

    return render_to_response("adiciona.html", {'form': form},
                              context_instance=RequestContext(request))
Esempio n. 26
0
def item_editar(request, nr_item):
	item = get_object_or_404(ItemAgenda, pk=nr_item, usuario=request.user)

	if request.method == "POST":
		form = FormItemAgenda(request.POST, request.FILES, instance=item)
		if form.is_valid():
			item = form.save(commit=False)
			item.usuario = request.user
			item.save()
			form.save_m2m()
			return render_to_response("salvo.html", {})
	else:
		form = FormItemAgenda(instance=item) #se o usuario for dono, edita; caso contrário, não edita
		return render_to_response("item_editar.html", {'form': form, 'item': item},
						context_instance=RequestContext(request))

	item = get_object_or_404(ItemAgenda, pk=nr_item)
	return render_to_response("item.html", {'item': item},
	context_instance=RequestContext(request))
Esempio n. 27
0
def adiciona(request):
	if request.method == "POST":

		form = FormItemAgenda(request.POST, request.FILES)
		data = request.POST.copy()
		SALT = SECRET_KEY[:20]
        
		print '- conferindo ---------------------------------------'
		print data
		print data['hash_code_captcha']
		print sha.new(SALT+data['imgtext']).hexdigest()

#captcha		if (form.is_valid() and data['hash_code_captcha'] == sha.new(SALT+string.upper(data['imgtext'])).hexdigest() ):
		if form.is_valid():

			item = form.save(commit=False)
			item.usuario = request.user
			
			# tentando ja colocar um up vote
			#item.up_votes = 1
			#voteuser = get_object_or_404(UserProfile, user=request.user)
			#voteuser.up_voted.append(nr_item)
			#voteuser.save()
			
			item.save()
			form.save_m2m()
			return HttpResponseRedirect("/")
#			return render_to_response("salvo.html", {})
		else:
#captcha			c = Captcha()
#captcha			dados = c.gerarImagem(request.META['REMOTE_ADDR'])
			form = FormItemAgenda()
#captcha			return render_to_response("adiciona.html", {'form': form, 'dados': dados, 'data': data},
			return render_to_response("adiciona.html", {'form': form},
				context_instance=RequestContext(request))			
	else:
#captcha		c = Captcha()
#captcha		dados = c.gerarImagem(request.META['REMOTE_ADDR'])
		form = FormItemAgenda()
#captcha		return render_to_response("adiciona.html", {'form': form, 'dados': dados},
		return render_to_response("adiciona.html", {'form': form},
			context_instance=RequestContext(request))
Esempio n. 28
0
def adiciona(request):

	if request.method=="POST":
		form = FormItemAgenda(request.POST)
		if form.is_valid(): # se for valido
			"""
			dados = form.cleaned_data
			item = ItemAgenda(data = dados['data'],hora=dados['hora'],titulo=dados['titulo'],
				descricao=dados['descricao'])
			"""
			item=form.save(commit=False)
			item.usuario=request.user
			item.save()
			return render_to_response("salvo.html",{})

	else:
		#isntance
		form = FormItemAgenda()

	#{'form':form} renderiza o form 
	#chama adiciona.html e passa coomo parametro o form que foi instancia a cima
	#garante que as informacoes relacionadas a requisição serão enviadas para o template
	return render_to_response("adiciona.html",{'form':form},context_instance=RequestContext(request))