Added contact info snippet

This commit is contained in:
Oleg Lavrovsky 2017-04-08 14:33:03 +02:00
parent 0c4d9b41f5
commit 8c6319feaf
6 changed files with 112 additions and 14 deletions

View 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)),
],
),
]

View 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),
),
]

View 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

View 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>

View 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(),
}

View file

@ -5,21 +5,15 @@
<footer id="footer">
<div class="container">
<div class="row">
<div class="col-md-4">
<!-- Bottom Menu -->
{% footer_menu parent=site_root calling_page=self %}
</div>
</div>
<div class="row">
<div class="col-md-4" id="contact">
<address>
<p>Public Health Schweiz<br>
Effingerstrasse 54<br>
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>
{{ contact_info }}
</div>
</div>
<div class="col-md-4">
<form action="https://formspree.io/info@datalets.ch" method="POST">