chore(home/models.py): remove redundant group assigning logic (built into wagtail)

This commit is contained in:
2026-03-11 14:47:55 +01:00
parent 4439fd1003
commit 75f79cecc1

View File

@@ -1,8 +1,5 @@
from django.db import models
from wagtail.models import Page from wagtail.models import Page
from wagtail.fields import RichTextField from wagtail.fields import RichTextField
from django.contrib.auth.models import Group
class HomePage(Page): class HomePage(Page):
@@ -13,28 +10,5 @@ class HomePage(Page):
class CoursePage(Page): class CoursePage(Page):
body = RichTextField(blank=True) body = RichTextField(blank=True)
group = models.ForeignKey(
Group,
on_delete=models.CASCADE,
null=True,
blank=True,
help_text="Only members of this group can access this course.",
)
content_panels = Page.content_panels + [ content_panels = Page.content_panels + ["body"]
"body",
"group",
]
def serve(self, request):
if self.group:
if (
not request.user.is_authenticated
or self.group not in request.user.groups.all()
):
from django.shortcuts import render
# render 403.html
return render(request, "403.html", status=403)
return super().serve(request)