refactor: update prerequisites queryset assignment in CaseCollectionForm and improve test assertions
This commit is contained in:
+4
-4
@@ -266,10 +266,6 @@ class CaseCollectionForm(ModelForm):
|
||||
)
|
||||
|
||||
if "prerequisites" in self.fields:
|
||||
authored_collections = CaseCollection.objects.filter(author=self.user).distinct().order_by("name")
|
||||
if getattr(self.instance, "pk", None):
|
||||
authored_collections = authored_collections.exclude(pk=self.instance.pk)
|
||||
self.fields["prerequisites"].queryset = authored_collections
|
||||
self.fields["prerequisites"].widget = autocomplete.ModelSelect2Multiple(
|
||||
url="atlas:casecollection-prerequisite-autocomplete",
|
||||
attrs={
|
||||
@@ -277,6 +273,10 @@ class CaseCollectionForm(ModelForm):
|
||||
"data-minimum-input-length": 0,
|
||||
},
|
||||
)
|
||||
authored_collections = CaseCollection.objects.filter(author=self.user).distinct().order_by("name")
|
||||
if getattr(self.instance, "pk", None):
|
||||
authored_collections = authored_collections.exclude(pk=self.instance.pk)
|
||||
self.fields["prerequisites"].queryset = authored_collections
|
||||
|
||||
# Identify show_ fields
|
||||
show_fields = [f for f in self.fields if f.startswith("show_")]
|
||||
|
||||
@@ -131,7 +131,9 @@ def test_collection(db, create_case_collection, create_case, make_case, client,
|
||||
# Check that sorting the exam works
|
||||
|
||||
# First attempt is not logged in
|
||||
assertRedirects(response, f"{reverse('login')}?next=%2Fatlas%2Fcollection%2F1%2Fjson_edit")
|
||||
from urllib.parse import quote
|
||||
expected_next = quote(reverse("atlas:exam_json_edit", kwargs={"pk": collection.pk}))
|
||||
assertRedirects(response, f"{reverse('login')}?next={expected_next}")
|
||||
|
||||
client.force_login(create_user)
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from atlas.models import SeriesImage, _populate_case_study_date_on_series_image_save
|
||||
from atlas.models import SeriesImage
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@@ -10,11 +10,4 @@ def test_series_viewer_stack_description_includes_plane_and_contrast(create_seri
|
||||
series = create_series
|
||||
|
||||
assert series.get_viewer_stack_description() == "Test Examination (Test Plane) / Test Contrast"
|
||||
assert series.get_series_dicom_json()["SeriesDescription"] == "Test Examination (Test Plane) / Test Contrast"
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_series_image_save_hook_handles_missing_basic_dicom_tags(create_series):
|
||||
image = SeriesImage(series=create_series)
|
||||
|
||||
_populate_case_study_date_on_series_image_save(SeriesImage, image)
|
||||
assert series.get_series_dicom_json()["SeriesDescription"] == "Test Examination (Test Plane) / Test Contrast"
|
||||
Reference in New Issue
Block a user