feat(models.py): add tags and color fields to EventPage

This commit is contained in:
2026-03-16 13:12:39 +01:00
parent 8f47f14611
commit 7b10f8f367

View File

@@ -2,10 +2,15 @@ from django import forms
from django.contrib.auth.models import Group, User
from django.db import models
from django.forms import CheckboxSelectMultiple
from modelcluster.contrib.taggit import ClusterTaggableManager
from modelcluster.fields import ParentalKey
from taggit.models import TaggedItemBase
from wagtail.admin.panels import FieldPanel
from wagtail.fields import RichTextField, StreamField
from wagtail.models import Page
from wagtail.models.copying import ParentalManyToManyField
from wagtail_color_panel.fields import ColorField
from wagtail_color_panel.edit_handlers import NativeColorPanel
class EmptyPage(Page):
@@ -72,7 +77,17 @@ class CourseModulePage(Page):
content_panels = Page.content_panels + ["body"]
class EventPageTag(TaggedItemBase):
content_object = ParentalKey(
"home.EventPage",
related_name="tagged_items",
on_delete=models.CASCADE,
)
class EventPage(Page):
tags = ClusterTaggableManager(through=EventPageTag, blank=True)
color = ColorField(default="#1c398e")
image = models.ForeignKey(
"wagtailimages.Image",
null=True,
@@ -120,6 +135,8 @@ class EventPage(Page):
return context
content_panels = Page.content_panels + [
FieldPanel("tags"),
NativeColorPanel("color"),
FieldPanel("image"),
FieldPanel("start"),
FieldPanel("end"),