diff --git a/home/models.py b/home/models.py index f28005e..0a5ab49 100644 --- a/home/models.py +++ b/home/models.py @@ -1,8 +1,9 @@ from django.contrib.auth.models import Group -from django.db import models +from django.forms import CheckboxSelectMultiple from wagtail.admin.panels import FieldPanel from wagtail.fields import RichTextField from wagtail.models import Page +from wagtail.models.copying import ParentalManyToManyField class HomePage(Page): @@ -13,18 +14,15 @@ class HomePage(Page): class CoursePage(Page): body = RichTextField(blank=True) - allowed_groups = models.ForeignKey( + allowed_groups = ParentalManyToManyField( 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 + [ FieldPanel("body"), - FieldPanel("allowed_groups", heading="Allowed Groups"), + FieldPanel("allowed_groups", widget=CheckboxSelectMultiple), ]