feat(models.py): add course_image property to CoursePage

This commit is contained in:
2026-03-12 14:19:36 +01:00
parent da0c06d3b6
commit 7bcbb63a49

View File

@@ -1,5 +1,6 @@
from django.contrib.auth.models import Group from django.contrib.auth.models import Group
from django.forms import CheckboxSelectMultiple from django.forms import CheckboxSelectMultiple
from django.db import models
from wagtail.admin.panels import FieldPanel from wagtail.admin.panels import FieldPanel
from wagtail.fields import RichTextField from wagtail.fields import RichTextField
from wagtail.models import Page from wagtail.models import Page
@@ -14,6 +15,13 @@ class HomePage(Page):
class CoursePage(Page): class CoursePage(Page):
body = RichTextField(blank=True) body = RichTextField(blank=True)
course_image = models.ForeignKey(
"wagtailimages.Image",
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name="+",
)
allowed_groups = ParentalManyToManyField( allowed_groups = ParentalManyToManyField(
Group, Group,
related_name="course_pages", related_name="course_pages",
@@ -32,6 +40,7 @@ class CoursePage(Page):
return context return context
content_panels = Page.content_panels + [ content_panels = Page.content_panels + [
FieldPanel("course_image"),
FieldPanel("body"), FieldPanel("body"),
FieldPanel("allowed_groups", widget=CheckboxSelectMultiple), FieldPanel("allowed_groups", widget=CheckboxSelectMultiple),
] ]