diff --git a/atlas/forms.py b/atlas/forms.py index 96e24dc3..cea1ab7b 100755 --- a/atlas/forms.py +++ b/atlas/forms.py @@ -63,6 +63,8 @@ from crispy_forms.helper import FormHelper from atlas.helpers import get_cases_available_to_user +from typing import Any + class CaseSelect(Select): template_name = "atlas/case_select_widget.html" @@ -72,8 +74,14 @@ class CaseSelect(Select): print(option) + return option + def get_context(self, name: str, value, attrs) -> dict[str, Any]: + context = super().get_context(name, value, attrs) + return context + + pass class ConditionForm(ModelForm): @@ -326,7 +334,8 @@ class CaseForm(ModelForm): # self.fields["series"].queryset = if self.user.groups.filter(name="atlas_editor").exists(): - case_queryset = Case.objects.all().order_by("pk") + case_queryset = Case.objects.all().order_by("pk").prefetch_related( + ) else: case_queryset = get_cases_available_to_user(self.user) self.fields["previous_case"].queryset=case_queryset diff --git a/atlas/models.py b/atlas/models.py index 46dc5a6a..f0901c97 100644 --- a/atlas/models.py +++ b/atlas/models.py @@ -417,7 +417,7 @@ class Case(models.Model, AuthorMixin, QuestionMixin): for s in self.series.all(): html += s.get_block() - return html + return mark_safe(html) def get_long_str(self): examinations = [series.get_examination() for series in self.series.all()] @@ -1301,7 +1301,11 @@ class UncategorisedDicom(models.Model): if self.image: ds = self.get_dicom_info() - self.series_instance_uid = ds["SeriesInstanceUID"].value + try: + self.series_instance_uid = ds["SeriesInstanceUID"].value + except AttributeError: + # ? only called with invalid dicom? + self.series_instance_uid = ds["SeriesInstanceUID"] # if self.check_for_duplicates(): # return DuplicateDicom diff --git a/atlas/templates/atlas/case_select_widget.html b/atlas/templates/atlas/case_select_widget.html index cf40e878..9db6893f 100644 --- a/atlas/templates/atlas/case_select_widget.html +++ b/atlas/templates/atlas/case_select_widget.html @@ -1,15 +1,38 @@ -
+
Cases -
+