Files
old-saburly-wagtail-web/services/models.py

84 lines
2.7 KiB
Python
Raw Normal View History

2024-09-10 20:21:33 +02:00
from __future__ import unicode_literals
from django.db import models
from wagtail.fields import RichTextField
2024-09-15 04:36:27 +02:00
from wagtail.admin.panels import FieldPanel, MultiFieldPanel, InlinePanel
from wagtail.models import Page, Orderable
from modelcluster.models import ParentalKey
2024-09-10 20:21:33 +02:00
2024-09-11 23:05:33 +02:00
from saburly.custom_editor import FULL_EDITOR
2024-09-15 04:36:27 +02:00
2024-09-10 20:21:33 +02:00
class ServicesPage(Page):
2024-09-16 20:16:16 +02:00
intro_title = RichTextField(blank=True, features=FULL_EDITOR)
intro_text = RichTextField(blank=True, features=FULL_EDITOR)
intro_image = models.ForeignKey(
'wagtailimages.Image',
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name='+'
)
2024-09-10 20:21:33 +02:00
content_panels = Page.content_panels + [
MultiFieldPanel([
2024-09-16 20:16:16 +02:00
FieldPanel('intro_title'),
FieldPanel('intro_text'),
FieldPanel('intro_image'),
], heading="Intro Section"),
2024-09-15 04:36:27 +02:00
InlinePanel('carousel_services', heading="Carousel Services", label="Carousel Services"),
2024-09-16 20:16:16 +02:00
InlinePanel('sections_services', heading="Sections Services", label="Sections Services"),
InlinePanel('subsections_services', heading="Sub-Sections Services", label="Sub-Sections Services"),
2024-09-10 20:21:33 +02:00
]
2024-09-15 04:36:27 +02:00
class ServicesPageCarousel(Orderable):
page = ParentalKey(ServicesPage, on_delete=models.CASCADE, related_name='carousel_services')
carousel_name = models.CharField(max_length=255, blank=True)
carousel_image = models.ForeignKey(
'wagtailimages.Image',
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name='+'
)
panels = [
FieldPanel('carousel_name'),
FieldPanel('carousel_image'),
2024-09-16 20:16:16 +02:00
]
class ServicesPageSections(Orderable):
page = ParentalKey(ServicesPage, on_delete=models.CASCADE, related_name='sections_services')
section_title = RichTextField(blank=True, features=FULL_EDITOR)
section_text = RichTextField(blank=True, features=FULL_EDITOR)
section_image = models.ForeignKey(
'wagtailimages.Image',
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name='+'
)
panels = [
FieldPanel('section_title'),
FieldPanel('section_text'),
FieldPanel('section_image'),
]
class ServicesPageSubSection(Orderable):
page = ParentalKey(ServicesPage, on_delete=models.CASCADE, related_name='subsections_services')
sub_section_text = RichTextField(blank=True, features=FULL_EDITOR)
sub_section_image = models.ForeignKey(
'wagtailimages.Image',
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name='+'
)
panels = [
FieldPanel('sub_section_text'),
FieldPanel('sub_section_image'),
2024-09-15 04:36:27 +02:00
]