Add circle title to assignment in wagtail cms view
This commit is contained in:
parent
aabaced836
commit
7597311220
|
|
@ -127,6 +127,12 @@ class Assignment(CourseBasePage):
|
||||||
"evaluation_tasks",
|
"evaluation_tasks",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def get_admin_display_title(self):
|
||||||
|
circle_title = self.get_attached_circle_title()
|
||||||
|
if circle_title:
|
||||||
|
return f"{circle_title}: {self.title}"
|
||||||
|
return self.title
|
||||||
|
|
||||||
assignment_type = models.CharField(
|
assignment_type = models.CharField(
|
||||||
max_length=50,
|
max_length=50,
|
||||||
choices=[(tag.value, tag.value) for tag in AssignmentType],
|
choices=[(tag.value, tag.value) for tag in AssignmentType],
|
||||||
|
|
@ -271,6 +277,16 @@ class Assignment(CourseBasePage):
|
||||||
return lp.get_frontend_url()
|
return lp.get_frontend_url()
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
def get_attached_circle_title(self):
|
||||||
|
if self.learningcontentassignment_set.count() > 1:
|
||||||
|
# probably "Reflexion" which is attached to multiple circles
|
||||||
|
return ""
|
||||||
|
|
||||||
|
lp = self.find_attached_learning_content()
|
||||||
|
if lp and lp.get_parent_circle():
|
||||||
|
return lp.get_parent_circle().title
|
||||||
|
return ""
|
||||||
|
|
||||||
|
|
||||||
class AssignmentCompletionStatus(Enum):
|
class AssignmentCompletionStatus(Enum):
|
||||||
IN_PROGRESS = "IN_PROGRESS"
|
IN_PROGRESS = "IN_PROGRESS"
|
||||||
|
|
|
||||||
|
|
@ -277,6 +277,14 @@ class LearningContent(CourseBasePage):
|
||||||
return "ERROR: could not parse slug"
|
return "ERROR: could not parse slug"
|
||||||
return f"/course/{m.group('coursePart')}/learn/{m.group('circlePart')}/{m.group('lcPart')}"
|
return f"/course/{m.group('coursePart')}/learn/{m.group('circlePart')}/{m.group('lcPart')}"
|
||||||
|
|
||||||
|
def get_parent_circle(self):
|
||||||
|
try:
|
||||||
|
return self.get_ancestors().exact_type(Circle).first()
|
||||||
|
except Exception:
|
||||||
|
# noop
|
||||||
|
pass
|
||||||
|
return None
|
||||||
|
|
||||||
def save(self, clean=True, user=None, log_action=False, **kwargs):
|
def save(self, clean=True, user=None, log_action=False, **kwargs):
|
||||||
self.slug = find_slug_with_parent_prefix(self, "lc")
|
self.slug = find_slug_with_parent_prefix(self, "lc")
|
||||||
super().save(**kwargs)
|
super().save(**kwargs)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue