
16 changed files with 194 additions and 4 deletions
Binary file not shown.
@ -0,0 +1,50 @@ |
|||
# Generated by Django 3.1.7 on 2021-03-18 14:54 |
|||
|
|||
from django.db import migrations, models |
|||
import django.db.models.deletion |
|||
import modelcluster.fields |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('wagtailimages', '0023_add_choose_permissions'), |
|||
('home', '0003_homepage_body'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.AddField( |
|||
model_name='homepage', |
|||
name='address', |
|||
field=models.CharField(blank=True, default='', max_length=255, verbose_name='Adresa'), |
|||
), |
|||
migrations.AddField( |
|||
model_name='homepage', |
|||
name='email', |
|||
field=models.EmailField(blank=True, max_length=64, null=True, verbose_name='E-mail'), |
|||
), |
|||
migrations.AddField( |
|||
model_name='homepage', |
|||
name='map_link', |
|||
field=models.URLField(blank=True, default='', max_length=128, verbose_name='Odkaz na mapu'), |
|||
), |
|||
migrations.AddField( |
|||
model_name='homepage', |
|||
name='mobile', |
|||
field=models.CharField(blank=True, default='', max_length=24, verbose_name='Mobil'), |
|||
), |
|||
migrations.CreateModel( |
|||
name='CarouselImage', |
|||
fields=[ |
|||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
|||
('sort_order', models.IntegerField(blank=True, editable=False, null=True)), |
|||
('caption', models.CharField(blank=True, max_length=250)), |
|||
('image', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='+', to='wagtailimages.image')), |
|||
('page', modelcluster.fields.ParentalKey(on_delete=django.db.models.deletion.CASCADE, related_name='carousel_images', to='home.homepage')), |
|||
], |
|||
options={ |
|||
'ordering': ['sort_order'], |
|||
'abstract': False, |
|||
}, |
|||
), |
|||
] |
Binary file not shown.
@ -1,7 +1,51 @@ |
|||
from django.db import models |
|||
|
|||
from wagtail.core.models import Page |
|||
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): |
|||
pass |
|||
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'), |
|||
] |
Binary file not shown.
Binary file not shown.
@ -0,0 +1,15 @@ |
|||
from wagtail.api.v2.views import PagesAPIViewSet |
|||
from wagtail.api.v2.router import WagtailAPIRouter |
|||
from wagtail.images.api.v2.views import ImagesAPIViewSet |
|||
from wagtail.documents.api.v2.views import DocumentsAPIViewSet |
|||
|
|||
# Create the router. "wagtailapi" is the URL namespace |
|||
api_router = WagtailAPIRouter('wagtailapi') |
|||
|
|||
# Add the three endpoints using the "register_endpoint" method. |
|||
# The first parameter is the name of the endpoint (eg. pages, images). This |
|||
# is used in the URL of the endpoint |
|||
# The second parameter is the endpoint class that handles the requests |
|||
api_router.register_endpoint('pages', PagesAPIViewSet) |
|||
api_router.register_endpoint('images', ImagesAPIViewSet) |
|||
api_router.register_endpoint('documents', DocumentsAPIViewSet) |
Binary file not shown.
@ -0,0 +1,15 @@ |
|||
from wagtail.api.v2.views import PagesAPIViewSet |
|||
from wagtail.api.v2.router import WagtailAPIRouter |
|||
from wagtail.images.api.v2.views import ImagesAPIViewSet |
|||
from wagtail.documents.api.v2.views import DocumentsAPIViewSet |
|||
|
|||
# Create the router. "wagtailapi" is the URL namespace |
|||
api_router = WagtailAPIRouter('wagtailapi') |
|||
|
|||
# Add the three endpoints using the "register_endpoint" method. |
|||
# The first parameter is the name of the endpoint (eg. pages, images). This |
|||
# is used in the URL of the endpoint |
|||
# The second parameter is the endpoint class that handles the requests |
|||
api_router.register_endpoint('pages', PagesAPIViewSet) |
|||
api_router.register_endpoint('images', ImagesAPIViewSet) |
|||
api_router.register_endpoint('documents', DocumentsAPIViewSet) |
After Width: | Height: | Size: 56 KiB |
After Width: | Height: | Size: 9.9 KiB |
After Width: | Height: | Size: 6.7 KiB |
Loading…
Reference in new issue