From 44ee735a2d3678a94aeef96593c299159444d6fb Mon Sep 17 00:00:00 2001 From: Artur Borecki Date: Thu, 12 Mar 2026 11:18:07 +0100 Subject: [PATCH] feat(home/models.py): add `allowed_groups` field to `CoursePage` --- home/models.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/home/models.py b/home/models.py index 551c9aa..f28005e 100644 --- a/home/models.py +++ b/home/models.py @@ -1,5 +1,8 @@ -from wagtail.models import Page +from django.contrib.auth.models import Group +from django.db import models +from wagtail.admin.panels import FieldPanel from wagtail.fields import RichTextField +from wagtail.models import Page class HomePage(Page): @@ -10,8 +13,19 @@ class HomePage(Page): class CoursePage(Page): body = RichTextField(blank=True) + allowed_groups = models.ForeignKey( + Group, + null=True, + blank=True, + on_delete=models.SET_NULL, + related_name="course_pages", + help_text="Select a group to restrict access to this course. Non-members will be prompted to purchase the course to view modules.", + ) - content_panels = Page.content_panels + ["body"] + content_panels = Page.content_panels + [ + FieldPanel("body"), + FieldPanel("allowed_groups", heading="Allowed Groups"), + ] class CourseModulePage(Page):