Merge pull request #10 from datalets/contact-form-embed-78

Contact form embed 78
This commit is contained in:
datalets 2017-05-15 22:46:25 +02:00 committed by GitHub
commit 1a416f602c
7 changed files with 57 additions and 24 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,16 @@
{% load wagtailcore_tags %}
{% if form %}
<form action="{% pageurl form %}" method="POST">
{% csrf_token %}
<div class="form-group">
<input name="name" id="id_name" type="text" placeholder="Name / Nom" class="form-control" required>
</div>
<div class="form-group">
<input name="email" id="id_email" type="email" placeholder="E-Mail" class="form-control" required>
</div>
<div class="form-group">
<textarea name="message" id="id_message" rows="3" placeholder="Nachricht / Message" class="form-control" required></textarea>
</div>
<button class="btn btn-primary" type="submit">Senden / Envoi</button>
</form>
{% endif %}

View file

@ -15,10 +15,11 @@ 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():
if Contact.objects.last():
return {
'contact': Contact.objects.last(),
'form': Contact.objects.last().contact_form,
}
# Contact links (header)

View file

@ -19,14 +19,12 @@
</div>
<a name="contact-info"></a>
<div class="col-md-8" id="contact-info">
<div class="col-md-4" id="contact-info">
{% contact_info %}
</div>
<!--
<div class="col-md-4" id="contact-form">
{# contact_form #}
{% footer_form %}
</div>
-->
</div><!-- /row -->
</div><!-- /container -->
</footer>

View file

@ -19,10 +19,9 @@
</nav>
<nav class="navbar navbar-default navbar-main navbar-fixed-top">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="sr-only">Navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>