From 87dde70fd3b77765d28a9fc59e268f2471ce2d2e Mon Sep 17 00:00:00 2001 From: Ross Date: Tue, 11 Nov 2025 14:04:46 +0000 Subject: [PATCH] Enhance AnatomyQuestion string representation; improve formatting and handle missing attributes for better readability --- anatomy/models.py | 18 ++-- anatomy/templates/anatomy/mark2_overview.html | 86 +++++++++---------- 2 files changed, 53 insertions(+), 51 deletions(-) diff --git a/anatomy/models.py b/anatomy/models.py index 37d5d36c..664dce65 100644 --- a/anatomy/models.py +++ b/anatomy/models.py @@ -132,14 +132,16 @@ class AnatomyQuestion(QuestionBase): return "anatomy" def __str__(self): - # Get first answer - return "{}/{}: {} [{}, {}]".format( - self.pk, - self.question_type, - self.get_primary_answer(), - self.modality, - self.structure, - ) + # Nicely formatted representation + pk = self.pk or "" + qtype = str(self.question_type) if self.question_type else "N/A" + primary = self.get_primary_answer() or "None" + modality = str(self.modality) if self.modality else "Unknown" + structure = str(self.structure) if self.structure else "Unknown" + 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): return format_html("{}", self.get_absolute_url(), self) diff --git a/anatomy/templates/anatomy/mark2_overview.html b/anatomy/templates/anatomy/mark2_overview.html index 5d66895d..dfc4c148 100644 --- a/anatomy/templates/anatomy/mark2_overview.html +++ b/anatomy/templates/anatomy/mark2_overview.html @@ -19,62 +19,62 @@
    - {% for question, unmarked_count, unmarked_count2 in question_unmarked_map %} -
  • + {% for question, unmarked_count, unmarked_count2 in question_unmarked_map %} +
  • -
    -
    Unmarked
    - {% if unmarked_count > 0 %} - {{ unmarked_count }} - {% else %} - {{ unmarked_count }} - {% endif %} -
    +
    +
    Unmarked
    + {% if unmarked_count > 0 %} + {{ unmarked_count }} + {% else %} + {{ unmarked_count }} + {% endif %} +
  • {% empty %}
  • No questions found.
  • {% endfor %} -
-
-
+ + + - - - {% endblock %} + showAll(); + })(); + + +{% endblock %}