Permalink
Browse files

refs 267 começando

  • Loading branch information...
1 parent 9ce99b7 commit 5017fb3d418fe080236e5da402c79c1f8f062732 @PaollaCoutinho PaollaCoutinho committed Nov 6, 2013
No changes.
@@ -0,0 +1,40 @@
+# -*- coding: utf-8 -*-
+
+__all__ = ('AddContactForm',)
+
+from django import forms
+from lethusbox.django.fields import BRPhoneNumberField
+from django.utils.translation import ugettext_lazy as _
+
+class AddContactForm(forms.Form):
@wpjunior
wpjunior Nov 6, 2013 collaborator

ContactForm fica com o nome correto do que acontecerá realmente

+ nome = forms.CharField(
+ label=_('Name'),
+ required=True,
+ max_length=64,
+ widget=forms.TextInput(attrs={'class': 'span5'}),
+ help_text=_('Enter your first and last name.'))
+
+ phone = BRPhoneNumberField(
+ label = _('Phone'),
+ required = True,
+ error_messages={'invalid' :u"Número de telefone inválido!"})
+
+ email = forms.EmailField(
+ label=_("E-mail"),
+ max_length=75,
+ help_text=_('Enter a valid email address.'))
+
+ subject = forms.CharField(
+ label=_('Subject'),
+ required=True,
+ widget=forms.TextInput(attrs={'class': 'span5'}))
+
+ message = forms.CharField(
+ label=_('Message'),
+ required=True,
+ widget=forms.Textarea(attrs={'class': 'input-xxlarge'}))
+
+
+ def __init__(self, *args, **kwargs):
+ super(AddContactForm, self).__init__(*args, **kwargs)
+
@@ -0,0 +1,54 @@
+{% extends 'faq/inner.html' %}
+
+{% load i18n %}
+{% load url from future %}
+
+{% load knowledge_tags %}
+
+{% block title %}{% trans "Contact" %}{% endblock title %}
+
+{% block header %}
+<style type="text/css">
+#id_name, #id_email, #id_title {
+ width: 500px;
+}
+#id_comment {
+ width: 100%;
+}
+#id_phone {
+ width: 130px;
+}
+</style>
+{% endblock %}
+
+{% block knowledge_widgets %}
+{% if not search %}
+{% endif %}
+<div id="primary" class="sidebar-off">
+ <div class="container">
+ <section id="content">
+ <div class="dk-widget">
+ <div class="page-header">
+ <h3>
+ {% trans "Contact" %}
+ </h3>
+ </div>
+ <form id="form" novalidate action="{% if object %}{{ object.get_absolute_url }}{% else %}.{% endif %}" method="POST">
@wpjunior
wpjunior Nov 6, 2013 collaborator

action="." apenas

por que não estamos trabalhando com objetos no banco de dados.

+ {% csrf_token %}
+
+ <p class="btn-group">
+ <button type="submit" class="btn btn-primary">
+ <i class="icon-ok icon-white"></i> {% trans "Sent" %}
+ </button>
+ <button type="button" onclick="history.go(-1)" class="btn">
+ <i class="icon-arrow-left"></i> {% trans "Back" %}
+ </button>
+ </p>
+ {% include "master/form_snippet.html" %}
+ </form>
+
+ </div>
+ </section>
+ </div>
+</div>
+{% endblock knowledge_widgets %}
@@ -0,0 +1,13 @@
+from django.conf.urls.defaults import patterns, include, url
+from django.contrib.staticfiles.urls import staticfiles_urlpatterns
+from django.contrib.auth.decorators import login_required
+from django.conf import settings
+
+from supportcenter.accounts.decorators import superuser_only
+
+from .views import *
+
+urlpatterns = patterns('',
+ url(r'^$', AddContactView.as_view(), name="contact"),
+ url(r'^sent/',ContactView.as_view(), name='contact_sent'),
+)
@@ -0,0 +1,26 @@
+# -*- coding: utf-8 -*-
+
+__all__ = ('AddContactView', 'ContactView')
+
+from django.views.generic import (
+ TemplateView, FormView)
+from mongoengine.queryset import Q
+from mongoengine.django.shortcuts import get_document_or_404
+from django.utils.translation import ugettext_lazy as _
+from lethusbox.django.responses import HybridListView
+
+from .forms import *
+
+class AddContactView(FormView):
+ form_class = AddContactForm
+ success_url = '/contact/'
+ template_name = 'contact/form.html'
+ success_message = _("Your contact has been sent")
+
+
@wpjunior
wpjunior Nov 6, 2013 collaborator

agora implementaremos o form_valid

+
+class ContactView(TemplateView):
+ template_name = 'contact/confirm_contact_sent.html'
+ success_url = '/contact/'
+ success_message = _(u"The email has been sent")
+
@@ -130,7 +130,8 @@
'supportcenter.common',
'supportcenter.accounts',
'supportcenter.faq',
- 'supportcenter.forum'
+ 'supportcenter.forum',
+ 'supportcenter.contact',
)
LOGGING = {
@@ -35,4 +35,7 @@
#Forum
url(r'^forum/', include('supportcenter.forum.urls')),
+
+ #Contact
+ url(r'^contact/', include('supportcenter.contact.urls')),
)

0 comments on commit 5017fb3

Please sign in to comment.