generated from bisco/codex-bootstrap
246 lines
7.1 KiB
Python
246 lines
7.1 KiB
Python
from django.db import models
|
|
from modelcluster.fields import ParentalKey
|
|
from wagtail.admin.panels import FieldPanel, InlinePanel, MultiFieldPanel
|
|
from wagtail.contrib.settings.models import BaseSiteSetting, register_setting
|
|
from wagtail.fields import RichTextField
|
|
from wagtail.models import Orderable, Page
|
|
from wagtail.snippets.models import register_snippet
|
|
|
|
|
|
@register_setting(icon="cog")
|
|
class SiteSettings(BaseSiteSetting):
|
|
laboratory_name = models.CharField(max_length=120, default="Azione!Lab")
|
|
short_claim = models.CharField(max_length=180, blank=True)
|
|
email = models.EmailField(blank=True)
|
|
phone = models.CharField(max_length=40, blank=True)
|
|
whatsapp = models.CharField(max_length=40, blank=True)
|
|
instagram = models.URLField(blank=True)
|
|
facebook = models.URLField(blank=True)
|
|
address = models.CharField(max_length=255, blank=True)
|
|
footer_text = models.CharField(max_length=255, blank=True)
|
|
|
|
panels = [
|
|
MultiFieldPanel(
|
|
[FieldPanel("laboratory_name"), FieldPanel("short_claim")],
|
|
heading="Identity",
|
|
),
|
|
MultiFieldPanel(
|
|
[
|
|
FieldPanel("email"),
|
|
FieldPanel("phone"),
|
|
FieldPanel("whatsapp"),
|
|
FieldPanel("instagram"),
|
|
FieldPanel("facebook"),
|
|
FieldPanel("address"),
|
|
],
|
|
heading="Contacts",
|
|
),
|
|
FieldPanel("footer_text"),
|
|
]
|
|
|
|
class Meta:
|
|
verbose_name = "site settings"
|
|
|
|
|
|
class HomePage(Page):
|
|
hero_title = models.CharField(max_length=180)
|
|
hero_subtitle = models.TextField()
|
|
hero_image = models.ForeignKey(
|
|
"wagtailimages.Image",
|
|
null=True,
|
|
blank=True,
|
|
on_delete=models.SET_NULL,
|
|
related_name="+",
|
|
)
|
|
intro_title = models.CharField(max_length=180, blank=True)
|
|
intro_body = RichTextField(blank=True)
|
|
cta_primary_label = models.CharField(max_length=80, blank=True)
|
|
cta_primary_url = models.CharField(max_length=255, blank=True)
|
|
cta_secondary_label = models.CharField(max_length=80, blank=True)
|
|
cta_secondary_url = models.CharField(max_length=255, blank=True)
|
|
laboratory_title = models.CharField(max_length=180, blank=True)
|
|
laboratory_body = RichTextField(blank=True)
|
|
laboratory_image = models.ForeignKey(
|
|
"wagtailimages.Image",
|
|
null=True,
|
|
blank=True,
|
|
on_delete=models.SET_NULL,
|
|
related_name="+",
|
|
)
|
|
|
|
max_count = 1
|
|
subpage_types: list[str] = []
|
|
|
|
content_panels = Page.content_panels + [
|
|
MultiFieldPanel(
|
|
[
|
|
FieldPanel("hero_title"),
|
|
FieldPanel("hero_subtitle"),
|
|
FieldPanel("hero_image"),
|
|
],
|
|
heading="Hero",
|
|
),
|
|
MultiFieldPanel(
|
|
[FieldPanel("intro_title"), FieldPanel("intro_body")],
|
|
heading="Manifesto",
|
|
),
|
|
MultiFieldPanel(
|
|
[
|
|
FieldPanel("cta_primary_label"),
|
|
FieldPanel("cta_primary_url"),
|
|
FieldPanel("cta_secondary_label"),
|
|
FieldPanel("cta_secondary_url"),
|
|
],
|
|
heading="Calls to action",
|
|
),
|
|
InlinePanel("feature_cards", label="Feature card", max_num=3),
|
|
MultiFieldPanel(
|
|
[
|
|
FieldPanel("laboratory_title"),
|
|
FieldPanel("laboratory_body"),
|
|
FieldPanel("laboratory_image"),
|
|
],
|
|
heading="Laboratory",
|
|
),
|
|
]
|
|
|
|
|
|
class FeatureCard(Orderable):
|
|
page = ParentalKey(
|
|
HomePage,
|
|
on_delete=models.CASCADE,
|
|
related_name="feature_cards",
|
|
)
|
|
title = models.CharField(max_length=120)
|
|
text = models.TextField()
|
|
|
|
panels = [FieldPanel("title"), FieldPanel("text")]
|
|
|
|
def __str__(self) -> str:
|
|
return self.title
|
|
|
|
|
|
@register_snippet
|
|
class TeacherProfile(models.Model):
|
|
name = models.CharField(max_length=120)
|
|
photo = models.ForeignKey(
|
|
"wagtailimages.Image",
|
|
null=True,
|
|
blank=True,
|
|
on_delete=models.SET_NULL,
|
|
related_name="+",
|
|
)
|
|
short_bio = models.TextField()
|
|
full_bio = RichTextField(blank=True)
|
|
quote = models.TextField(blank=True)
|
|
|
|
panels = [
|
|
FieldPanel("name"),
|
|
FieldPanel("photo"),
|
|
FieldPanel("short_bio"),
|
|
FieldPanel("full_bio"),
|
|
FieldPanel("quote"),
|
|
]
|
|
|
|
class Meta:
|
|
verbose_name = "teacher profile"
|
|
|
|
def __str__(self) -> str:
|
|
return self.name
|
|
|
|
|
|
@register_snippet
|
|
class LessonInfo(models.Model):
|
|
day_time = models.CharField(max_length=180)
|
|
location = models.CharField(max_length=255)
|
|
audience = models.TextField()
|
|
description = RichTextField()
|
|
trial_lesson = models.CharField(max_length=255, blank=True)
|
|
notes = models.TextField(blank=True)
|
|
|
|
panels = [
|
|
FieldPanel("day_time"),
|
|
FieldPanel("location"),
|
|
FieldPanel("audience"),
|
|
FieldPanel("description"),
|
|
FieldPanel("trial_lesson"),
|
|
FieldPanel("notes"),
|
|
]
|
|
|
|
class Meta:
|
|
verbose_name = "lesson information"
|
|
verbose_name_plural = "lesson information"
|
|
|
|
def __str__(self) -> str:
|
|
return self.day_time
|
|
|
|
|
|
@register_snippet
|
|
class Show(models.Model):
|
|
title = models.CharField(max_length=180)
|
|
year = models.PositiveSmallIntegerField()
|
|
short_description = models.TextField()
|
|
description = RichTextField(blank=True)
|
|
poster = models.ForeignKey(
|
|
"wagtailimages.Image",
|
|
null=True,
|
|
blank=True,
|
|
on_delete=models.SET_NULL,
|
|
related_name="+",
|
|
)
|
|
location = models.CharField(max_length=255, blank=True)
|
|
cast = models.TextField(blank=True)
|
|
order = models.PositiveIntegerField(default=0)
|
|
visible_on_home = models.BooleanField(default=True)
|
|
|
|
panels = [
|
|
FieldPanel("title"),
|
|
FieldPanel("year"),
|
|
FieldPanel("short_description"),
|
|
FieldPanel("description"),
|
|
FieldPanel("poster"),
|
|
FieldPanel("location"),
|
|
FieldPanel("cast"),
|
|
FieldPanel("order"),
|
|
FieldPanel("visible_on_home"),
|
|
]
|
|
|
|
class Meta:
|
|
ordering = ["order", "-year", "title"]
|
|
|
|
def __str__(self) -> str:
|
|
return f"{self.title} ({self.year})"
|
|
|
|
|
|
@register_snippet
|
|
class GalleryItem(models.Model):
|
|
class Category(models.TextChoices):
|
|
LESSONS = "lessons", "Lessons"
|
|
BACKSTAGE = "backstage", "Backstage"
|
|
SHOWS = "shows", "Shows"
|
|
GROUP = "group", "Group"
|
|
|
|
image = models.ForeignKey(
|
|
"wagtailimages.Image",
|
|
on_delete=models.CASCADE,
|
|
related_name="+",
|
|
)
|
|
category = models.CharField(max_length=20, choices=Category.choices)
|
|
caption = models.CharField(max_length=255, blank=True)
|
|
order = models.PositiveIntegerField(default=0)
|
|
visible_on_home = models.BooleanField(default=True)
|
|
|
|
panels = [
|
|
FieldPanel("image"),
|
|
FieldPanel("category"),
|
|
FieldPanel("caption"),
|
|
FieldPanel("order"),
|
|
FieldPanel("visible_on_home"),
|
|
]
|
|
|
|
class Meta:
|
|
ordering = ["order", "id"]
|
|
|
|
def __str__(self) -> str:
|
|
return self.caption or self.image.title
|