Logo and color fields

This commit is contained in:
Oleg Lavrovsky 2019-10-17 17:42:27 +02:00
parent ead009f381
commit 7c89dd3273
3 changed files with 57 additions and 0 deletions

View file

@ -0,0 +1,25 @@
# Generated by Django 2.1.12 on 2019-10-17 15:15
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('wagtailimages', '0001_squashed_0021'),
('home', '0026_auto_20190625_1521'),
]
operations = [
migrations.AddField(
model_name='contact',
name='color',
field=models.CharField(blank=True, default='', max_length=40),
),
migrations.AddField(
model_name='contact',
name='logo',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.Image'),
),
]

View file

@ -7,6 +7,7 @@ from django.db import models
from wagtail.snippets.models import register_snippet
from wagtail.core.models import Page
from wagtail.images.edit_handlers import ImageChooserPanel
from wagtail.admin.edit_handlers import FieldPanel, PageChooserPanel
from .forms import ContactForm
@ -63,11 +64,20 @@ class Contact(models.Model):
'title_fr',
'title_en',
)
address = models.TextField(default="", blank=True)
phone = models.CharField(max_length=40, blank=True, default="")
email = models.EmailField(max_length=100, blank=True, default="")
www = models.URLField(null=True, blank=True)
color = models.CharField(max_length=40, blank=True, default="")
logo = models.ForeignKey(
'wagtailimages.Image',
null=True, blank=True,
on_delete=models.SET_NULL,
related_name='+'
)
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,
@ -95,6 +105,8 @@ class Contact(models.Model):
FieldPanel('phone'),
FieldPanel('email'),
FieldPanel('www'),
ImageChooserPanel('logo'),
FieldPanel('color'),
FieldPanel('map_url'),
FieldPanel('analytics'),
PageChooserPanel('contact_form', 'home.ContactForm'),

View file

@ -1,3 +1,5 @@
{% load wagtailimages_tags %}
<address>
<p>
{% if contact.map_url %}
@ -19,6 +21,24 @@
{% endfor %}
</div>
<style type="text/css">
{% if contact.color %}
footer#footer, .navbar-pre {
background-color: {{ contact.color }};
}
{% endif %}
{% if contact.logo %}
{% image contact.logo original as contact_logo %}
.navbar-brand {
background-size: contain !important;
background-repeat: no-repeat;
background-image: url('{{ contact_logo.url }}');
padding-left: 80px;
}
.navbar-brand img { display: none !important; }
{% endif %}
</style>
{% if contact.is_google_analytics %}
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ contact.analytics }}"></script>