From 334cd7df48ea727608ffadd08b52e58f15e244dd Mon Sep 17 00:00:00 2001 From: Alex Lubbock Date: Tue, 12 Mar 2024 10:52:24 +0000 Subject: [PATCH] fix: retrieve ELISAs by cohort pk, not library --- backend/antigenapi/views.py | 2 +- frontend/src/App.js | 1 + frontend/src/crudtemplates/ListTable.js | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/antigenapi/views.py b/backend/antigenapi/views.py index 78cb3fe..ea6cf04 100644 --- a/backend/antigenapi/views.py +++ b/backend/antigenapi/views.py @@ -371,7 +371,7 @@ class ElisaPlateViewSet(AuditLogMixin, DeleteProtectionMixin, ModelViewSet): queryset = ElisaPlate.objects.all().select_related("library__cohort") serializer_class = ElisaPlateSerializer - filterset_fields = ("library",) + filterset_fields = ("library", "library__cohort") def perform_create(self, serializer): # noqa: D102 serializer.save(added_by=self.request.user) diff --git a/frontend/src/App.js b/frontend/src/App.js index f94fefb..c612060 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.js @@ -421,6 +421,7 @@ const App = () => { diff --git a/frontend/src/crudtemplates/ListTable.js b/frontend/src/crudtemplates/ListTable.js index 38ab11a..31e53ff 100644 --- a/frontend/src/crudtemplates/ListTable.js +++ b/frontend/src/crudtemplates/ListTable.js @@ -25,7 +25,9 @@ const ListTable = (props) => { useEffect(() => { const refreshRecords = () => { let schemaUrl = config.url.API_URL + props.schema.apiUrl + "/"; - if (props.schema.parentObjectName) { + if (props.filterField) { + schemaUrl += "?" + props.filterField + "=" + recordId; + } else if (props.schema.parentObjectName) { schemaUrl += "?" + props.schema.parentObjectName + "=" + recordId; } fetch(schemaUrl, {