Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #1 from contatogilsonsbf/master

Refatoração no Projeto
  • Loading branch information...
commit 2106017534a0eee39c7ac5acee86135f4f6fd57a 2 parents 3f4d004 + f4a2bdc
@onovaes authored
View
6 .gitignore
@@ -0,0 +1,6 @@
+# Arquivos Compilados
+*.pyc
+
+# Imagens enviadas via upload no desenvolvimento
+media/galeria/original/*.*
+media/galeria/thumbnail/*.*
View
1  README → README.md
@@ -1,3 +1,4 @@
+# Easy News
Projeto de um sistema de gerencimento de noticias com python/django
View
BIN  __init__.pyc
Binary file not shown
View
28 views.py → core/forms.py
@@ -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
25 core/views.py
@@ -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
BIN  enquetes/__init__.pyc
Binary file not shown
View
BIN  enquetes/admin.pyc
Binary file not shown
View
BIN  enquetes/models.pyc
Binary file not shown
View
BIN  enquetes/views.pyc
Binary file not shown
View
BIN  galeria/__init__.pyc
Binary file not shown
View
BIN  galeria/admin.pyc
Binary file not shown
View
BIN  galeria/models.pyc
Binary file not shown
View
BIN  galeria/views.pyc
Binary file not shown
View
BIN  media/galeria/original/Image0264.jpg
Deleted file not rendered
View
BIN  media/galeria/original/Imagem0265.jpg
Deleted file not rendered
View
BIN  media/galeria/original/Imagem0270.jpg
Deleted file not rendered
View
BIN  media/galeria/original/Imagem0402.jpg
Deleted file not rendered
View
BIN  media/galeria/thumbnail/2.jpg
Deleted file not rendered
View
BIN  media/galeria/thumbnail/3.jpg
Deleted file not rendered
View
BIN  media/galeria/thumbnail/4.jpg
Deleted file not rendered
View
BIN  noticias/__init__.pyc
Binary file not shown
View
BIN  noticias/admin.pyc
Binary file not shown
View
BIN  noticias/feeds.pyc
Binary file not shown
View
BIN  noticias/models.pyc
Binary file not shown
View
BIN  noticias/views.pyc
Binary file not shown
View
BIN  settings.pyc
Binary file not shown
View
3  templates/email/fale_conosco.txt
@@ -0,0 +1,3 @@
+Nome: {{ nome }}
+E-mail: {{ email }}
+Mensagem: {{ mensagem }}
View
BIN  urls.pyc
Binary file not shown
View
BIN  utils/__init__.pyc
Binary file not shown
View
24 utils/email.py
@@ -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
BIN  utils/signals_comuns.pyc
Binary file not shown
View
BIN  views.pyc
Binary file not shown

0 comments on commit 2106017

Please sign in to comment.
Something went wrong with that request. Please try again.