fix(home/models.py): fix allowed_groups not changing in wagtail panel
This commit is contained in:
@@ -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),
|
||||
]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user