feat(models.py): add tags and color fields to EventPage
This commit is contained in:
@@ -2,10 +2,15 @@ from django import forms
|
|||||||
from django.contrib.auth.models import Group, User
|
from django.contrib.auth.models import Group, User
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.forms import CheckboxSelectMultiple
|
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.admin.panels import FieldPanel
|
||||||
from wagtail.fields import RichTextField, StreamField
|
from wagtail.fields import RichTextField, StreamField
|
||||||
from wagtail.models import Page
|
from wagtail.models import Page
|
||||||
from wagtail.models.copying import ParentalManyToManyField
|
from wagtail.models.copying import ParentalManyToManyField
|
||||||
|
from wagtail_color_panel.fields import ColorField
|
||||||
|
from wagtail_color_panel.edit_handlers import NativeColorPanel
|
||||||
|
|
||||||
|
|
||||||
class EmptyPage(Page):
|
class EmptyPage(Page):
|
||||||
@@ -72,7 +77,17 @@ class CourseModulePage(Page):
|
|||||||
content_panels = Page.content_panels + ["body"]
|
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):
|
class EventPage(Page):
|
||||||
|
tags = ClusterTaggableManager(through=EventPageTag, blank=True)
|
||||||
|
color = ColorField(default="#1c398e")
|
||||||
image = models.ForeignKey(
|
image = models.ForeignKey(
|
||||||
"wagtailimages.Image",
|
"wagtailimages.Image",
|
||||||
null=True,
|
null=True,
|
||||||
@@ -120,6 +135,8 @@ class EventPage(Page):
|
|||||||
return context
|
return context
|
||||||
|
|
||||||
content_panels = Page.content_panels + [
|
content_panels = Page.content_panels + [
|
||||||
|
FieldPanel("tags"),
|
||||||
|
NativeColorPanel("color"),
|
||||||
FieldPanel("image"),
|
FieldPanel("image"),
|
||||||
FieldPanel("start"),
|
FieldPanel("start"),
|
||||||
FieldPanel("end"),
|
FieldPanel("end"),
|
||||||
|
|||||||
Reference in New Issue
Block a user