Archived
1
Fork 0

Add editable info for footer and homepage

This commit is contained in:
Edgar P. Burkhart 2024-06-12 16:45:04 +02:00
parent b1596dcdc8
commit 651a2b3682
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
12 changed files with 166 additions and 7 deletions

0
lps/base/__init__.py Normal file
View file

6
lps/base/apps.py Normal file
View file

@ -0,0 +1,6 @@
from django.apps import AppConfig
class BaseConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "base"

View file

@ -0,0 +1,47 @@
# Generated by Django 5.0.6 on 2024-06-12 14:16
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = []
operations = [
migrations.CreateModel(
name="NavigationSettings",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"address",
models.CharField(
blank=True, max_length=256, verbose_name="Adresse"
),
),
(
"phone",
models.CharField(
blank=True, max_length=16, verbose_name="Numéro de téléphone"
),
),
(
"email",
models.EmailField(
blank=True, max_length=254, verbose_name="Adresse de courriel"
),
),
],
options={
"abstract": False,
},
),
]

View file

@ -0,0 +1,19 @@
# Generated by Django 5.0.6 on 2024-06-12 14:18
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("base", "0001_initial"),
]
operations = [
migrations.AlterField(
model_name="navigationsettings",
name="phone",
field=models.CharField(
blank=True, max_length=32, verbose_name="Numéro de téléphone"
),
),
]

View file

23
lps/base/models.py Normal file
View file

@ -0,0 +1,23 @@
from django.db import models
from wagtail.admin.panels import FieldPanel, MultiFieldPanel
from wagtail.contrib.settings.models import BaseGenericSetting, register_setting
@register_setting
class NavigationSettings(BaseGenericSetting):
address = models.CharField(max_length=256, verbose_name="Adresse", blank=True)
phone = models.CharField(
max_length=32, verbose_name="Numéro de téléphone", blank=True
)
email = models.EmailField(verbose_name="Adresse de courriel", blank=True)
panels = [
MultiFieldPanel(
[
FieldPanel("address"),
FieldPanel("phone"),
FieldPanel("email"),
],
"Informations de contact",
)
]

View file

@ -0,0 +1,33 @@
# Generated by Django 5.0.6 on 2024-06-12 14:24
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("home", "0003_homepage_body"),
("wagtailimages", "0026_delete_uploadedimage"),
]
operations = [
migrations.AddField(
model_name="homepage",
name="hero_text",
field=models.CharField(
blank=True, help_text="Phrase d'accueil", max_length=1024
),
),
migrations.AddField(
model_name="homepage",
name="image",
field=models.ForeignKey(
blank=True,
help_text="Image page d'accueil",
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="+",
to="wagtailimages.image",
),
),
]

View file

@ -1,11 +1,25 @@
from django.db import models
from wagtail.admin.panels import FieldPanel from wagtail.admin.panels import FieldPanel
from wagtail.fields import RichTextField from wagtail.fields import RichTextField
from wagtail.models import Page from wagtail.models import Page
class HomePage(Page): class HomePage(Page):
image = models.ForeignKey(
"wagtailimages.Image",
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name="+",
help_text="Image page d'accueil",
)
hero_text = models.CharField(
blank=True, max_length=1024, help_text="Phrase d'accueil"
)
body = RichTextField(blank=True) body = RichTextField(blank=True)
content_panels = Page.content_panels + [ content_panels = Page.content_panels + [
FieldPanel("image"),
FieldPanel("hero_text"),
FieldPanel("body"), FieldPanel("body"),
] ]

View file

@ -1,9 +1,12 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load wagtailcore_tags %} {% load wagtailcore_tags wagtailimages_tags %}
{% block body_class %}template-homepage{% endblock %} {% block body_class %}template-homepage{% endblock %}
{% block content %} {% block content %}
<h1>Lycée du Pays de Soule</h1> <h1>{{ page.title }}</h1>
<p>Formations générales, scientifiques et technologiques</p> <section>
<p>{{ page.hero_text }}</p>
{% srcset_image page.image width-{510,700,950,1200,1450} %}
</section>
<hr> <hr>
<section> <section>
{{ page.body|richtext }} {{ page.body|richtext }}

View file

@ -24,10 +24,12 @@ BASE_DIR = os.path.dirname(PROJECT_DIR)
# Application definition # Application definition
INSTALLED_APPS = [ INSTALLED_APPS = [
"base",
"home", "home",
"search", "search",
"wagtail.contrib.forms", "wagtail.contrib.forms",
"wagtail.contrib.redirects", "wagtail.contrib.redirects",
"wagtail.contrib.settings",
"wagtail.embeds", "wagtail.embeds",
"wagtail.sites", "wagtail.sites",
"wagtail.users", "wagtail.users",
@ -73,6 +75,7 @@ TEMPLATES = [
"django.template.context_processors.request", "django.template.context_processors.request",
"django.contrib.auth.context_processors.auth", "django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages", "django.contrib.messages.context_processors.messages",
"wagtail.contrib.settings.context_processors.settings",
], ],
}, },
}, },

View file

@ -6,6 +6,6 @@ h1, h2, h3, h4, h5, h6 {
--pico-font-weight: 600; --pico-font-weight: 600;
} }
img.full-width { img {
width: 100%; width: 100%;
} }

View file

@ -1,6 +1,17 @@
<hr> <hr>
<section> <section>
<p> <nav>
Lycée du Pays de Soule Avenue Jean Monnet, 64130 Chéraute <a href="tel:+33559282228">+33&nbsp;5&nbsp;59&nbsp;28&nbsp;22&nbsp;28</a> <a href="mailto:ce.0641779L@ac-bordeaux.fr">ce.0641779L@ac-bordeaux.fr</a> <ul>
</p> <li>Lycée du Pays de Soule</li>
</ul>
<ul>
<li>{{ settings.base.NavigationSettings.address }}</li>
<li>
<a href="tel:{{ settings.base.NavigationSettings.phone }}">Téléphone</a>
</li>
<li>
<a href="mailto:{{ settings.base.NavigationSettings.email }}">Courriel</a>
</li>
</ul>
</nav>
</section> </section>