Created
August 28, 2014 17:13
-
-
Save anonymous/c47a1fa1c8322fafd852 to your computer and use it in GitHub Desktop.
View - envio de e-mail ao cadastrar/inserir dados
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@login_required | |
def reclame(request): | |
if request.method == 'POST': | |
form = FormReclame(request.POST) | |
if form.is_valid(): | |
reclamacao = form.save(commit=False) | |
reclamacao.usuario = request.user | |
reclamacao.save() | |
subject = 'Uma nova reclamção foi adicionada.' | |
message = 'Confira. http://localhost:8000/reclamacao/{marcador}>'.format(marcador=reclamacao.marcador) | |
from_email = settings.EMAIL_HOST_USER | |
to_list = [reclamacao.titulo, settings.EMAIL_HOST_USER] | |
send_mail(subject, message, from_email, to_list, fail_silently=True) | |
return redirect('/') | |
else: | |
form = FormReclame() | |
return render_to_response( | |
'reclame.html', | |
locals(), | |
context_instance=RequestContext(request)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment