55 lines
1.3 KiB
Python
55 lines
1.3 KiB
Python
from django.db import models
|
|
from wagtail import blocks
|
|
from wagtail.admin.panels import FieldPanel
|
|
from wagtail.fields import StreamField
|
|
from wagtail.models import Page
|
|
|
|
|
|
class AssociationIndex(Page):
|
|
max_count = 1
|
|
subpage_types = ["associations.AssociationPage"]
|
|
|
|
body = StreamField(
|
|
[
|
|
("paragraph", blocks.RichTextBlock()),
|
|
]
|
|
)
|
|
|
|
content_panels = Page.content_panels + [
|
|
FieldPanel("body"),
|
|
]
|
|
|
|
|
|
class AssociationPage(Page):
|
|
subpage_types = []
|
|
parent_page_types = ["associations.AssociationIndex"]
|
|
show_in_menus = False
|
|
|
|
class AssociationType(models.TextChoices):
|
|
FORENING = "forening", "Forening"
|
|
UTVALG = "utvalg", "Utvalg"
|
|
|
|
body = StreamField(
|
|
[
|
|
("paragraph", blocks.RichTextBlock()),
|
|
]
|
|
)
|
|
association_type = models.CharField(
|
|
max_length=64, choices=AssociationType, default=AssociationType.FORENING
|
|
)
|
|
logo = models.ForeignKey(
|
|
"wagtailimages.Image",
|
|
null=True,
|
|
blank=True,
|
|
on_delete=models.SET_NULL,
|
|
related_name="+",
|
|
)
|
|
websiteUrl = models.URLField()
|
|
|
|
content_panels = Page.content_panels + [
|
|
FieldPanel("body"),
|
|
FieldPanel("logo"),
|
|
FieldPanel("association_type", heading="Type"),
|
|
FieldPanel("websiteUrl", heading="Nettside"),
|
|
]
|