from __future__ import unicode_literals from django.db import models from wagtail.fields import RichTextField from wagtail.admin.panels import FieldPanel, MultiFieldPanel, InlinePanel from wagtail.models import Page, Orderable from modelcluster.models import ParentalKey from saburly.custom_editor import FULL_EDITOR class ServicesPage(Page): 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='+' ) content_panels = Page.content_panels + [ MultiFieldPanel([ FieldPanel('intro_title'), FieldPanel('intro_text'), FieldPanel('intro_image'), ], heading="Intro Section"), InlinePanel('carousel_services', heading="Carousel Services", label="Carousel Services"), InlinePanel('sections_services', heading="Sections Services", label="Sections Services"), InlinePanel('subsections_services', heading="Sub-Sections Services", label="Sub-Sections Services"), ] 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'), ] 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'), ]