You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.6 KiB
51 lines
1.6 KiB
from django.db import models
|
|
|
|
from modelcluster.fields import ParentalKey
|
|
|
|
from wagtail.core.models import Page, Orderable
|
|
from wagtail.core.fields import RichTextField
|
|
from wagtail.admin.edit_handlers import FieldPanel, InlinePanel
|
|
from wagtail.images.edit_handlers import ImageChooserPanel
|
|
from wagtail.search import index
|
|
from wagtail.api import APIField
|
|
|
|
|
|
class HomePage(Page):
|
|
body = RichTextField(blank=True)
|
|
address = models.CharField(max_length=255, verbose_name="Adresa", blank=True, default='')
|
|
mobile = models.CharField(max_length=24, verbose_name="Mobil", blank=True, default='')
|
|
email = models.EmailField(max_length=64, verbose_name="E-mail", blank=True, null=True)
|
|
map_link = models.URLField(max_length=128, verbose_name="Odkaz na mapu", blank=True, default='')
|
|
|
|
content_panels = Page.content_panels + [
|
|
FieldPanel('body', classname="full"),
|
|
FieldPanel('address'),
|
|
FieldPanel('mobile'),
|
|
FieldPanel('email'),
|
|
FieldPanel('map_link'),
|
|
InlinePanel('carousel_images', label="Obrázky"),
|
|
]
|
|
|
|
search_fields = Page.search_fields + [
|
|
index.SearchField('body'),
|
|
]
|
|
|
|
api_fields = [
|
|
APIField('carousel_images'),
|
|
]
|
|
|
|
|
|
class CarouselImage(Orderable):
|
|
page = ParentalKey(HomePage, on_delete=models.CASCADE, related_name='carousel_images')
|
|
image = models.ForeignKey('wagtailimages.Image', on_delete=models.CASCADE, related_name='+')
|
|
caption = models.CharField(blank=True, max_length=250)
|
|
|
|
panels = [
|
|
ImageChooserPanel('image'),
|
|
FieldPanel('caption'),
|
|
]
|
|
|
|
api_fields = [
|
|
APIField('image'),
|
|
APIField('caption'),
|
|
]
|