diff --git a/publichealth/home/migrations/0018_contact_contact_form.py b/publichealth/home/migrations/0018_contact_contact_form.py new file mode 100644 index 0000000..c412115 --- /dev/null +++ b/publichealth/home/migrations/0018_contact_contact_form.py @@ -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'), + ), + ] diff --git a/publichealth/home/models/snippets.py b/publichealth/home/models/snippets.py index 319e5e9..045d2a8 100644 --- a/publichealth/home/models/snippets.py +++ b/publichealth/home/models/snippets.py @@ -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): diff --git a/publichealth/home/templates/tags/contact_form.html b/publichealth/home/templates/tags/contact_form.html deleted file mode 100644 index 157b8e7..0000000 --- a/publichealth/home/templates/tags/contact_form.html +++ /dev/null @@ -1,12 +0,0 @@ -
-
- -
-
- -
-
- -
- -
diff --git a/publichealth/home/templates/tags/footer_form.html b/publichealth/home/templates/tags/footer_form.html new file mode 100644 index 0000000..b5e6605 --- /dev/null +++ b/publichealth/home/templates/tags/footer_form.html @@ -0,0 +1,5 @@ +
+ {% csrf_token %} + {{ form.as_p }} + +
diff --git a/publichealth/home/templatetags/information.py b/publichealth/home/templatetags/information.py index 564a230..2dee9ab 100644 --- a/publichealth/home/templatetags/information.py +++ b/publichealth/home/templatetags/information.py @@ -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) diff --git a/publichealth/templates/footer.html b/publichealth/templates/footer.html index 516277e..e8c3b42 100644 --- a/publichealth/templates/footer.html +++ b/publichealth/templates/footer.html @@ -22,11 +22,9 @@
{% contact_info %}
-