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_")]
|
||||
|
||||
Reference in New Issue
Block a user