Enhance AnatomyQuestion string representation; improve formatting and handle missing attributes for better readability
This commit is contained in:
+10
-8
@@ -132,14 +132,16 @@ class AnatomyQuestion(QuestionBase):
|
|||||||
return "anatomy"
|
return "anatomy"
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
# Get first answer
|
# Nicely formatted representation
|
||||||
return "{}/{}: {} [{}, {}]".format(
|
pk = self.pk or ""
|
||||||
self.pk,
|
qtype = str(self.question_type) if self.question_type else "N/A"
|
||||||
self.question_type,
|
primary = self.get_primary_answer() or "None"
|
||||||
self.get_primary_answer(),
|
modality = str(self.modality) if self.modality else "Unknown"
|
||||||
self.modality,
|
structure = str(self.structure) if self.structure else "Unknown"
|
||||||
self.structure,
|
title = self.get_title() if hasattr(self, "get_title") else (self.description or "")
|
||||||
)
|
if title and len(title) > 60:
|
||||||
|
title = title[:57] + "..."
|
||||||
|
return f"{title} (Type: {qtype}) — Answer: {primary} — Modality: {modality}; Structure: {structure}"
|
||||||
|
|
||||||
def get_link(self):
|
def get_link(self):
|
||||||
return format_html("<a href='{}'>{}</a>", self.get_absolute_url(), self)
|
return format_html("<a href='{}'>{}</a>", self.get_absolute_url(), self)
|
||||||
|
|||||||
@@ -77,4 +77,4 @@
|
|||||||
<style>
|
<style>
|
||||||
.show-all-button.active, .show-unmarked-button.active { box-shadow: inset 0 -2px 0 rgba(0,0,0,0.08); }
|
.show-all-button.active, .show-unmarked-button.active { box-shadow: inset 0 -2px 0 rgba(0,0,0,0.08); }
|
||||||
</style>
|
</style>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Reference in New Issue
Block a user