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):