feat(home/models.py): add CourseModulePage.course property
This commit is contained in:
@@ -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"]
|
||||||
|
|||||||
Reference in New Issue
Block a user