Permalink
Browse files

Merge pull request #1 from contatogilsonsbf/master

Refatoração no Projeto
  • Loading branch information...
2 parents 3f4d004 + f4a2bdc commit 2106017534a0eee39c7ac5acee86135f4f6fd57a @onovaes committed Aug 23, 2011
View
@@ -0,0 +1,6 @@
+# Arquivos Compilados
+*.pyc
+
+# Imagens enviadas via upload no desenvolvimento
+media/galeria/original/*.*
+media/galeria/thumbnail/*.*
View
@@ -1,3 +1,4 @@
+# Easy News
Projeto de um sistema de gerencimento de noticias com python/django
View
Binary file not shown.
View
@@ -1,13 +1,16 @@
-from django.shortcuts import render_to_response
-from django.template import RequestContext
+# -*- coding: utf8 -*-
+
from django import forms
from django.core.mail import send_mail
class FormContato(forms.Form):
+ """Formulário usado para
+ o Fale Conosco do Portal.
+ """
nome = forms.CharField(max_length=50)
email = forms.EmailField(required=False)
mensagem = forms.Field(widget=forms.Textarea)
-
+
def enviar(self):
titulo = 'Mensagem enviada pelo site'
destino = 'gabriel@reclameaqui.com.br'
@@ -23,21 +26,4 @@ def enviar(self):
message=texto,
from_email=destino,
recipient_list=[destino],
- )
-
-def contato(request):
- if request.method == 'POST':
- form = FormContato(request.POST)
-
- if form.is_valid():
- form.enviar()
- mostrar = 'Contato enviado!'
- form = FormContato()
- else:
- form = FormContato()
-
- return render_to_response(
- 'contato.html',
- locals(),
- context_instance=RequestContext(request),
- )
+ )
View
@@ -0,0 +1,25 @@
+# -*- coding: utf8 -*-
+
+from django.shortcuts import render_to_response
+from django.template import RequestContext
+
+from forms import FormContato
+
+def contato(request):
+ """Renderiza o formulário
+ de contato e captura os dados
+ destes para enviar o e-mail para
+ o responsável pelo portal.
+ """
+ if request.method == 'POST':
+ form = FormContato(request.POST)
+
+ if form.is_valid():
+ form.enviar()
+ mostrar = 'Contato enviado!'
+ form = FormContato()
+ else:
+ form = FormContato()
+
+ return render_to_response('contato.html',locals(),
+ context_instance=RequestContext(request))
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
@@ -0,0 +1,3 @@
+Nome: {{ nome }}
+E-mail: {{ email }}
+Mensagem: {{ mensagem }}
View
BIN urls.pyc
Binary file not shown.
View
Binary file not shown.
View
@@ -0,0 +1,24 @@
+# -*- coding: utf8 -*-
+
+from django.core.mail import send_email
+from django.template.loader import render_to_string
+from django.conf import settings
+
+
+def enviar_email(conteudo):
+ """Método responsável
+ por enviar e-mails pelo sistema.
+
+ Os parametros são:
+ - subject: Título do E-mail;
+ - message: caminho do arquivo
+ que contém o template do e-mail
+ para renderização
+ """
+ message = render_to_string('email/fale_conosco.txt', {'conteudo': conteudo})
+
+ send_email(subject=subject, message=message,
+ from_email=settings.DEFAULT_FROM_EMAIL,
+ recipient_list = [conteudo.email],
+ )
+
View
Binary file not shown.
View
BIN views.pyc
Binary file not shown.

0 comments on commit 2106017

Please sign in to comment.