Commit 6c658a23 authored by Leila's avatar Leila
Browse files

🚧 WIP

parent c63a82d1
from django.db import models
from django.utils.translation import ugettext as _
from django.db.models.signals import post_save
from django.dispatch import receiver
class Contact(models.Model):
name = models.CharField(max_length=100)
mail = models.EmailField(max_length=100)
phone = models.CharField(max_length=100)
message = models.TextField()
class Contact(models.Model):
name = models.CharField(_('Name'), max_length=100)
mail = models.EmailField(_('E-mail'), max_length=100)
phone = models.CharField(_('Phone'), max_length=100)
message = models.TextField(_('Message'))
created_at = models.DateTimeField(auto_now_add=True)
@property
def short(self):
if len(self.message) > 30:
return '{}...'.format(self.message[:27])
return self.message
@receiver(post_save, sender=Contact)
def contact_send_mail(sender, instance, **kwargs):
from .tasks import send_contact_mail
send_contact_mail.delay(instance.pk)
......@@ -5208,12 +5208,11 @@ button.close {
.footer p a:active, .footer p a:hover {
text-decoration: none; }
.contact-picture {
.contactus {
margin-top: 20vh; }
.contact-form .submit {
.contactus .form-horizontal .submit {
background-color: #56CEE9;
color: #fff; }
.contact-form .pull-right {
.contactus .form-horizontal .pull-right {
float: none !important;
margin-top: 30px; }
......@@ -3,19 +3,12 @@
{% load staticfiles %}
{% block content %}
<div class="contact">
<div class="contact-picture">
<div class="hidden-xs col-sm-6">
<img src="../static/img/contact.jpg">
</div>
<div class="contactus">
<div class="contactphoto col-sm-6 hidden-xs">
<img src="../static/img/contact.jpg">
</div>
<div class="formulaire col-xs-12 col-sm-6">
{% crispy form %}
</div>
<div class="contact-form">
<div class="formulaire col-xs-12 col-sm-6">
<div class="form-horizontal">
{% crispy form %}
</div>
</div>
</div>
</div>
{% endblock %}
\ No newline at end of file
from django.views.generic.edit import FormView
from django.views.generic.base import TemplateResponseMixin
from django.core.urlresolvers import reverse_lazy
from .models import Contact
from .forms import ContactForm
class ContactView(FormView):
class AjaxResponseMixin(TemplateResponseMixin):
model = Contact
template_name = 'cuisine_entre_amis/contact.html'
html_template_name = None
ajax_template_name = None
class AbstractContactView(object):
def get_context_data(self, **kwargs):
context = super(AbstractContactView, self).get_context_data(**kwargs)
return context
class ContactView(AbstractContactView, FormView, AjaxResponseMixin):
html_template_name = 'jean_yves/contact.html'
ajax_template_name = "jean_yves/ajax-contact.html"
form_class = ContactForm
success_url = reverse_lazy('/')
success_url = reverse_lazy('thanks')
def form_valid(self, form):
if form.should_save:
......
.contact-picture{
.contactus {
margin-top: 20vh;
}
.contact-form {
.form-horizontal {
.submit{
background-color: $brand-primary;
color: $white;
}
.submit{
background-color: $brand-primary;
color: $white;
}
.pull-right {
.pull-right {
float: none !important;
margin-top: 30px;
}
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment