diff --git a/home/models.py b/home/models.py index 53390f8..86c0a94 100644 --- a/home/models.py +++ b/home/models.py @@ -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"),