diff --git a/publichealth/home/migrations/0010_contact.py b/publichealth/home/migrations/0010_contact.py new file mode 100644 index 0000000..cd64dbe --- /dev/null +++ b/publichealth/home/migrations/0010_contact.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.6 on 2017-04-08 12:27 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('home', '0009_auto_20170406_1449'), + ] + + operations = [ + migrations.CreateModel( + name='Contact', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title_fr', models.CharField(default='', max_length=255)), + ('address', models.TextField(blank=True, default='')), + ('phone', models.CharField(default='', max_length=40)), + ('email', models.CharField(default='', max_length=40)), + ('www', models.URLField(blank=True, null=True)), + ], + ), + ] diff --git a/publichealth/home/migrations/0011_contact_title.py b/publichealth/home/migrations/0011_contact_title.py new file mode 100644 index 0000000..7873061 --- /dev/null +++ b/publichealth/home/migrations/0011_contact_title.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.6 on 2017-04-08 12:31 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('home', '0010_contact'), + ] + + operations = [ + migrations.AddField( + model_name='contact', + name='title', + field=models.CharField(default='', max_length=255), + ), + ] diff --git a/publichealth/home/snippets.py b/publichealth/home/snippets.py new file mode 100644 index 0000000..b051f55 --- /dev/null +++ b/publichealth/home/snippets.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- + +from __future__ import unicode_literals + +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 .util import TranslatedField + +@register_snippet +class Contact(models.Model): + title = models.CharField(max_length=255, default="") + title_fr = models.CharField(max_length=255, default="") + trans_title = TranslatedField( + 'title', + 'title_fr', + ) + address = models.TextField(default="", blank=True) + phone = models.CharField(max_length=40, default="") + email = models.CharField(max_length=40, default="") + www = models.URLField(null=True, blank=True) + + panels = Page.content_panels + [ + FieldPanel('title_fr'), + FieldPanel('address'), + FieldPanel('phone'), + FieldPanel('email'), + FieldPanel('www'), + ] + + def __str__(self): + return self.trans_title diff --git a/publichealth/home/templates/tags/contact_info.html b/publichealth/home/templates/tags/contact_info.html new file mode 100644 index 0000000..bf54ff9 --- /dev/null +++ b/publichealth/home/templates/tags/contact_info.html @@ -0,0 +1,8 @@ +
+

{{ contact.trans_title }}
+ {{ contact.address }} +

+

Tel. {{ contact.phone }}
+ {{ contact.email }}
+ {{ contact.www }}

+
diff --git a/publichealth/home/templatetags/information.py b/publichealth/home/templatetags/information.py new file mode 100644 index 0000000..2d03194 --- /dev/null +++ b/publichealth/home/templatetags/information.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- +from django import template +from django.utils import translation + +from ..snippets import Contact + +register = template.Library() + +# Contact information (footer) +@register.inclusion_tag('tags/contact_info.html') +def contact_info(): + return { + 'contact': Contact.objects.first(), + } diff --git a/publichealth/templates/footer.html b/publichealth/templates/footer.html index f35e1a8..9e268f0 100644 --- a/publichealth/templates/footer.html +++ b/publichealth/templates/footer.html @@ -5,21 +5,15 @@