feat: home page with cta
This commit is contained in:
parent
75662f9d98
commit
72bf6bffb8
6 changed files with 87 additions and 14 deletions
|
@ -0,0 +1,36 @@
|
|||
# Generated by Django 5.0.2 on 2024-02-29 20:42
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('home', '0003_homepage_body'),
|
||||
('wagtailcore', '0091_remove_revision_submitted_for_moderation'),
|
||||
('wagtailimages', '0025_alter_image_file_alter_rendition_file'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='homepage',
|
||||
name='hero_cta',
|
||||
field=models.CharField(blank=True, help_text='Text to display on Call to Action', max_length=255, verbose_name='Hero CTA'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='homepage',
|
||||
name='hero_cta_link',
|
||||
field=models.ForeignKey(blank=True, help_text='Choose a page to link to for the Call to Action', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailcore.page', verbose_name='Hero CTA link'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='homepage',
|
||||
name='hero_text',
|
||||
field=models.CharField(blank=True, help_text='Write an introduction for the site', max_length=255),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='homepage',
|
||||
name='image',
|
||||
field=models.ForeignKey(blank=True, help_text='Homepage image', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.image'),
|
||||
),
|
||||
]
|
|
@ -2,11 +2,47 @@ from django.db import models
|
|||
|
||||
from wagtail.models import Page
|
||||
from wagtail.fields import RichTextField
|
||||
from wagtail.admin.panels import FieldPanel
|
||||
from wagtail.admin.panels import FieldPanel, MultiFieldPanel
|
||||
|
||||
class HomePage(Page):
|
||||
image = models.ForeignKey(
|
||||
"wagtailimages.Image",
|
||||
null=True,
|
||||
blank=True,
|
||||
on_delete=models.SET_NULL,
|
||||
related_name="+",
|
||||
help_text="Homepage image",
|
||||
)
|
||||
hero_text = models.CharField(
|
||||
blank=True,
|
||||
max_length=255, help_text="Write an introduction for the site"
|
||||
)
|
||||
hero_cta = models.CharField(
|
||||
blank=True,
|
||||
verbose_name="Hero CTA",
|
||||
max_length=255,
|
||||
help_text="Text to display on Call to Action",
|
||||
)
|
||||
hero_cta_link = models.ForeignKey(
|
||||
"wagtailcore.Page",
|
||||
null=True,
|
||||
blank=True,
|
||||
on_delete=models.SET_NULL,
|
||||
related_name="+",
|
||||
verbose_name="Hero CTA link",
|
||||
help_text="Choose a page to link to for the Call to Action",
|
||||
)
|
||||
body = RichTextField(blank=True)
|
||||
|
||||
content_panels = Page.content_panels + [
|
||||
MultiFieldPanel(
|
||||
[
|
||||
FieldPanel("image"),
|
||||
FieldPanel("hero_text"),
|
||||
FieldPanel("hero_cta"),
|
||||
FieldPanel("hero_cta_link"),
|
||||
],
|
||||
heading="Hero section",
|
||||
),
|
||||
FieldPanel('body'),
|
||||
]
|
||||
|
|
|
@ -1,18 +1,19 @@
|
|||
{% extends "base.html" %}
|
||||
{% load static %}
|
||||
{% load wagtailcore_tags %}
|
||||
{% load wagtailcore_tags wagtailimages_tags %}
|
||||
|
||||
{% block body_class %}template-homepage{% endblock %}
|
||||
|
||||
{% block extra_css %}
|
||||
|
||||
{% comment %}
|
||||
Delete the line below if you're just getting started and want to remove the welcome screen!
|
||||
{% endcomment %}
|
||||
<link rel="stylesheet" href="{% static 'css/welcome_page.css' %}">
|
||||
{% endblock extra_css %}
|
||||
|
||||
<!-- replace everything below with: -->
|
||||
{% block content %}
|
||||
{{ page.body|richtext }}
|
||||
{% endblock %}
|
||||
<div>
|
||||
<h1>{{ page.title }}</h1>
|
||||
{% image page.image fill-480x320 %}
|
||||
<p>{{ page.hero_text }}</p>
|
||||
{% if page.hero_cta_link %}
|
||||
<a href="{% pageurl page.hero_cta_link %}">
|
||||
{% firstof page.hero_cta page.hero_cta_link.title %}
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{{ page.body|richtext }}
|
||||
{% endblock content %}
|
BIN
media/images/pexels-life-of-pix-8892.2e16d0ba.fill-480x320.jpg
Normal file
BIN
media/images/pexels-life-of-pix-8892.2e16d0ba.fill-480x320.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 31 KiB |
BIN
media/images/pexels-life-of-pix-8892.max-165x165.jpg
Normal file
BIN
media/images/pexels-life-of-pix-8892.max-165x165.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.8 KiB |
BIN
media/original_images/pexels-life-of-pix-8892.jpg
Normal file
BIN
media/original_images/pexels-life-of-pix-8892.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 MiB |
Loading…
Add table
Add a link
Reference in a new issue