Added contact info snippet
This commit is contained in:
parent
0c4d9b41f5
commit
8c6319feaf
6 changed files with 112 additions and 14 deletions
26
publichealth/home/migrations/0010_contact.py
Normal file
26
publichealth/home/migrations/0010_contact.py
Normal file
|
@ -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)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
20
publichealth/home/migrations/0011_contact_title.py
Normal file
20
publichealth/home/migrations/0011_contact_title.py
Normal file
|
@ -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),
|
||||||
|
),
|
||||||
|
]
|
36
publichealth/home/snippets.py
Normal file
36
publichealth/home/snippets.py
Normal file
|
@ -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
|
8
publichealth/home/templates/tags/contact_info.html
Normal file
8
publichealth/home/templates/tags/contact_info.html
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<address>
|
||||||
|
<p>{{ contact.trans_title }}<br>
|
||||||
|
{{ contact.address }}
|
||||||
|
</p>
|
||||||
|
<p>Tel. <a href="tel:{{ contact.phone }}">{{ contact.phone }}</a><br>
|
||||||
|
<a href="{{ contact.email }}">{{ contact.email }}</a><br>
|
||||||
|
<a href="{{ contact.www }}">{{ contact.www }}</a></p>
|
||||||
|
</address>
|
14
publichealth/home/templatetags/information.py
Normal file
14
publichealth/home/templatetags/information.py
Normal file
|
@ -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(),
|
||||||
|
}
|
|
@ -5,21 +5,15 @@
|
||||||
<footer id="footer">
|
<footer id="footer">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
<div class="col-md-4">
|
||||||
<div class="col-md-4">
|
<!-- Bottom Menu -->
|
||||||
<!-- Bottom Menu -->
|
{% footer_menu parent=site_root calling_page=self %}
|
||||||
{% footer_menu parent=site_root calling_page=self %}
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-4" id="contact">
|
<div class="row">
|
||||||
<address>
|
<div class="col-md-4" id="contact">
|
||||||
<p>Public Health Schweiz<br>
|
{{ contact_info }}
|
||||||
Effingerstrasse 54<br>
|
</div>
|
||||||
Postfach 3420<br>
|
|
||||||
3001 Bern</p>
|
|
||||||
<p>Tel. +41 31 389 92 86<br>
|
|
||||||
<a href="#">info@public-health.ch</a><br>
|
|
||||||
<a href="#">www.public-health.ch</a></p>
|
|
||||||
</address>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<form action="https://formspree.io/info@datalets.ch" method="POST">
|
<form action="https://formspree.io/info@datalets.ch" method="POST">
|
||||||
|
|
Loading…
Reference in a new issue