Files
neuf-www/dnscms/associations/models.py

43 lines
1.1 KiB
Python

from django.db import models
from wagtail.models import Page
from wagtail.fields import StreamField
from wagtail import blocks
from wagtail.admin.panels import FieldPanel
from wagtail.images.blocks import ImageChooserBlock
class Association(Page):
class AssociationType(models.TextChoices):
FORENING = "forening", "Forening"
UTVALG = "utvalg", "Utvalg"
body = StreamField(
[
("heading", blocks.CharBlock(form_classname="title")),
("paragraph", blocks.RichTextBlock()),
("image", ImageChooserBlock()),
]
)
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="+",
)
url = models.URLField()
content_panels = Page.content_panels + [
# FieldPanel('author'),
# FieldPanel('date'),
FieldPanel("body"),
FieldPanel("logo"),
FieldPanel("association_type"),
FieldPanel("url"),
]