Snippet and template tag for footer text

pull/20/head
Scot Hacker 2017-02-10 14:01:07 +00:00
rodzic 35dc25f6d7
commit b0db0bba66
5 zmienionych plików z 54 dodań i 3 usunięć

Wyświetl plik

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-02-10 13:38
from __future__ import unicode_literals
from django.db import migrations, models
import wagtail.wagtailcore.fields
class Migration(migrations.Migration):
dependencies = [
('base', '0002_auto_20170210_1217'),
]
operations = [
migrations.CreateModel(
name='FooterText',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('body', wagtail.wagtailcore.fields.RichTextField()),
],
),
]

Wyświetl plik

@ -55,6 +55,21 @@ class People(ClusterableModel):
verbose_name_plural = 'People'
@register_snippet
class FooterText(models.Model):
body = RichTextField()
panels = [
FieldPanel('body'),
]
def __str__(self):
return "Footer text"
class Meta:
verbose_name_plural = 'Footer Text'
class AboutLocationRelationship(Orderable, models.Model):
"""
This defines the relationship between the `LocationPage` within the `locations`

Wyświetl plik

@ -1,7 +1,7 @@
from django import template
from django.template import Template
from django.utils.http import urlencode
from wagtail.wagtailcore.models import Page
from bakerydemo.base.models import FooterText
register = template.Library()
# https://docs.djangoproject.com/en/1.9/howto/custom-template-tags/
@ -87,3 +87,12 @@ def breadcrumbs(context):
'ancestors': ancestors,
'request': context['request'],
}
@register.inclusion_tag('base/include/footer.html', takes_context=True)
def get_footer_text(context):
footer_text = FooterText.objects.first().body
return {
'footer_text': footer_text,
}

Wyświetl plik

@ -165,7 +165,7 @@
</a>
</li>
</ul>
<p class="copyright text-muted">Copyright &copy; Your Website 2016</p>
<p class="copyright text-muted">{% get_footer_text %}</p>
</div>
</div>
</div>

Wyświetl plik

@ -0,0 +1,4 @@
{% load wagtailcore_tags %}
{{ footer_text|richtext }}