Inline contact form

This commit is contained in:
Oleg Lavrovsky 2017-05-11 10:12:55 +02:00
parent 0b07bfe668
commit fc7b0b1e8c
6 changed files with 41 additions and 19 deletions

View file

@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2017-05-11 08:01
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('home', '0017_auto_20170510_1627'),
]
operations = [
migrations.AddField(
model_name='contact',
name='contact_form',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='home.ContactForm'),
),
]

View file

@ -7,8 +7,9 @@ from django.db import models
from wagtail.wagtailsnippets.models import register_snippet
from wagtail.wagtailcore.models import Page
from wagtail.wagtailadmin.edit_handlers import FieldPanel
from wagtail.wagtailadmin.edit_handlers import FieldPanel, PageChooserPanel
from .forms import ContactForm
from ..util import TranslatedField
# List of supported social networks
@ -59,11 +60,19 @@ class Contact(models.Model):
phone = models.CharField(max_length=40, default="")
email = models.EmailField(max_length=100, default="")
www = models.URLField(null=True, blank=True)
map_url = models.URLField(null=True, blank=True,
help_text="Optional link of address to mapping provider")
analytics = models.CharField(max_length=60, default="", blank=True,
help_text="Optional web analytics property code")
contact_form = models.ForeignKey(
'home.ContactForm',
null=True, blank=True,
on_delete=models.SET_NULL,
related_name='+',
)
panels = Page.content_panels + [
FieldPanel('title_fr'),
FieldPanel('address'),
@ -72,6 +81,7 @@ class Contact(models.Model):
FieldPanel('www'),
FieldPanel('map_url'),
FieldPanel('analytics'),
PageChooserPanel('contact_form', 'home.ContactForm'),
]
def phone_link(self):

View file

@ -1,12 +0,0 @@
<form action="https://formspree.io/{{ contact.email }}" method="POST">
<div class="form-group">
<input name="name" id="name" type="text" placeholder="Name / Nom" class="form-control">
</div>
<div class="form-group">
<input name="_replyto" id="email" type="email" placeholder="E-Mail" class="form-control">
</div>
<div class="form-group">
<textarea name="message" id="message" rows="3" placeholder="Nachricht / Message" class="form-control"></textarea>
</div>
<button class="btn btn-primary" type="submit">Senden / Envoi</button>
</form>

View file

@ -0,0 +1,5 @@
<form action="." method="POST">
{% csrf_token %}
{{ form.as_p }}
<button class="btn btn-primary" type="submit">Senden / Envoi</button>
</form>

View file

@ -15,10 +15,10 @@ def contact_info():
}
# Contact form (footer)
@register.inclusion_tag('tags/contact_form.html')
def contact_form():
@register.inclusion_tag('tags/footer_form.html')
def footer_form():
return {
'contact': Contact.objects.last(),
'form': Contact.objects.last().contact_form,
}
# Contact links (header)

View file

@ -22,11 +22,9 @@
<div class="col-md-8" id="contact-info">
{% contact_info %}
</div>
<!--
<div class="col-md-4" id="contact-form">
{# contact_form #}
{% footer_form %}
</div>
-->
</div><!-- /row -->
</div><!-- /container -->
</footer>