diff --git a/server/books/models/module.py b/server/books/models/module.py index f11849b5..9b43a953 100644 --- a/server/books/models/module.py +++ b/server/books/models/module.py @@ -1,16 +1,16 @@ -from django import forms +from core.constants import DEFAULT_RICH_TEXT_FEATURES +from core.wagtail_utils import StrictHierarchyPage, get_default_settings from django.db import models from django.utils import timezone from django.utils.translation import gettext as _ -from wagtail.admin.forms import WagtailAdminPageForm -from wagtail.admin.panels import FieldPanel, TabbedInterface, ObjectList, TitleFieldPanel -from wagtail.fields import RichTextField - -from django.conf import settings -from core.constants import DEFAULT_RICH_TEXT_FEATURES -from core.wagtail_utils import StrictHierarchyPage, get_default_settings from users.models import SchoolClass -from django.utils.text import slugify +from wagtail.admin.panels import ( + FieldPanel, + ObjectList, + TabbedInterface, + TitleFieldPanel, +) +from wagtail.fields import RichTextField EXACT = "exact" @@ -52,6 +52,7 @@ class ModuleCategory(models.Model): def __str__(self): return f"{self.name}" + # Commented out since that check is not necessary if a slug is chosen that is already in use # a new one will be generated # TODO: remove after pullrequest is merged @@ -111,7 +112,7 @@ class Module(StrictHierarchyPage): FieldPanel("intro"), ] # TODO remove after pullrequest is merged - #base_form_class = ModulePageForm + # base_form_class = ModulePageForm edit_handler = TabbedInterface( [ObjectList(content_panels, heading="Content"), get_default_settings()] @@ -221,11 +222,11 @@ class Module(StrictHierarchyPage): super().full_clean(*args, **kwargs) # Always create a slug if it is not available + # todo: do we really want to do this? this will silently change a slug if the users sets one that already exists, which probably isn't what they expect if not self._slug_is_available(self.slug, self.get_parent(), self): self.slug = self._get_autogenerated_slug(self.slug) - class RecentModule(models.Model): module = models.ForeignKey( Module, on_delete=models.CASCADE, related_name="recent_modules"