feat(home/models.py): add CourseModulePage.course property

This commit is contained in:
2026-03-12 14:08:48 +01:00
parent bddc857345
commit da0c06d3b6

View File

@@ -41,16 +41,18 @@ class CourseModulePage(Page):
body = RichTextField(blank=True) body = RichTextField(blank=True)
@property @property
def full_title(self): def course(self):
if hasattr(self, "get_parent"): if hasattr(self, "get_parent"):
parent = self.get_parent() parent = self.get_parent()
if parent and hasattr(parent, "specific"): if parent and hasattr(parent, "specific"):
course = parent.specific return parent.specific
else: return None
course = None
if course and hasattr(course, "title"): @property
return f"{course.title} {self.title}" def full_title(self):
course = self.course
if course:
return f"{course.title} - {self.title}"
return self.title return self.title
content_panels = Page.content_panels + ["body"] content_panels = Page.content_panels + ["body"]