Inline contact form
This commit is contained in:
parent
0b07bfe668
commit
fc7b0b1e8c
6 changed files with 41 additions and 19 deletions
21
publichealth/home/migrations/0018_contact_contact_form.py
Normal file
21
publichealth/home/migrations/0018_contact_contact_form.py
Normal 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'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -7,8 +7,9 @@ from django.db import models
|
||||||
from wagtail.wagtailsnippets.models import register_snippet
|
from wagtail.wagtailsnippets.models import register_snippet
|
||||||
|
|
||||||
from wagtail.wagtailcore.models import Page
|
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
|
from ..util import TranslatedField
|
||||||
|
|
||||||
# List of supported social networks
|
# List of supported social networks
|
||||||
|
@ -59,11 +60,19 @@ class Contact(models.Model):
|
||||||
phone = models.CharField(max_length=40, default="")
|
phone = models.CharField(max_length=40, default="")
|
||||||
email = models.EmailField(max_length=100, default="")
|
email = models.EmailField(max_length=100, default="")
|
||||||
www = models.URLField(null=True, blank=True)
|
www = models.URLField(null=True, blank=True)
|
||||||
|
|
||||||
map_url = models.URLField(null=True, blank=True,
|
map_url = models.URLField(null=True, blank=True,
|
||||||
help_text="Optional link of address to mapping provider")
|
help_text="Optional link of address to mapping provider")
|
||||||
analytics = models.CharField(max_length=60, default="", blank=True,
|
analytics = models.CharField(max_length=60, default="", blank=True,
|
||||||
help_text="Optional web analytics property code")
|
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 + [
|
panels = Page.content_panels + [
|
||||||
FieldPanel('title_fr'),
|
FieldPanel('title_fr'),
|
||||||
FieldPanel('address'),
|
FieldPanel('address'),
|
||||||
|
@ -72,6 +81,7 @@ class Contact(models.Model):
|
||||||
FieldPanel('www'),
|
FieldPanel('www'),
|
||||||
FieldPanel('map_url'),
|
FieldPanel('map_url'),
|
||||||
FieldPanel('analytics'),
|
FieldPanel('analytics'),
|
||||||
|
PageChooserPanel('contact_form', 'home.ContactForm'),
|
||||||
]
|
]
|
||||||
|
|
||||||
def phone_link(self):
|
def phone_link(self):
|
||||||
|
|
|
@ -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>
|
|
5
publichealth/home/templates/tags/footer_form.html
Normal file
5
publichealth/home/templates/tags/footer_form.html
Normal 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>
|
|
@ -15,10 +15,10 @@ def contact_info():
|
||||||
}
|
}
|
||||||
|
|
||||||
# Contact form (footer)
|
# Contact form (footer)
|
||||||
@register.inclusion_tag('tags/contact_form.html')
|
@register.inclusion_tag('tags/footer_form.html')
|
||||||
def contact_form():
|
def footer_form():
|
||||||
return {
|
return {
|
||||||
'contact': Contact.objects.last(),
|
'form': Contact.objects.last().contact_form,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Contact links (header)
|
# Contact links (header)
|
||||||
|
|
|
@ -22,11 +22,9 @@
|
||||||
<div class="col-md-8" id="contact-info">
|
<div class="col-md-8" id="contact-info">
|
||||||
{% contact_info %}
|
{% contact_info %}
|
||||||
</div>
|
</div>
|
||||||
<!--
|
|
||||||
<div class="col-md-4" id="contact-form">
|
<div class="col-md-4" id="contact-form">
|
||||||
{# contact_form #}
|
{% footer_form %}
|
||||||
</div>
|
</div>
|
||||||
-->
|
|
||||||
</div><!-- /row -->
|
</div><!-- /row -->
|
||||||
</div><!-- /container -->
|
</div><!-- /container -->
|
||||||
</footer>
|
</footer>
|
||||||
|
|
Loading…
Reference in a new issue