From 9c3a40c234269e8dca30ed4d01293607dd63e391 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 17 Jun 2021 14:13:01 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../small_eod/autocomplete/tests/test_views.py | 4 ++-- backend-project/small_eod/autocomplete/views.py | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/backend-project/small_eod/autocomplete/tests/test_views.py b/backend-project/small_eod/autocomplete/tests/test_views.py index 23f197e8e..1a07c2e12 100644 --- a/backend-project/small_eod/autocomplete/tests/test_views.py +++ b/backend-project/small_eod/autocomplete/tests/test_views.py @@ -109,12 +109,12 @@ def test_suggests_related(self): # Match all - the related institution should appear at the top. resp = self.get_response_for_query("institution", case=case.id) - self.assertEqual(resp.data['results'][0]['id'], institution_b.id) + self.assertEqual(resp.data["results"][0]["id"], institution_b.id) # Match a specific, non-related item. # The related institution should not be present. resp = self.get_response_for_query("institution_a", case=case.id) - self.assertEqual([r['id'] for r in resp.data['results']], [institution_a.id]) + self.assertEqual([r["id"] for r in resp.data["results"]], [institution_a.id]) class TagAutocompleteViewSetTestCase(ReadOnlyViewSetMixin, SearchQueryMixin, TestCase): diff --git a/backend-project/small_eod/autocomplete/views.py b/backend-project/small_eod/autocomplete/views.py index d9a49c87f..34f44a9cd 100644 --- a/backend-project/small_eod/autocomplete/views.py +++ b/backend-project/small_eod/autocomplete/views.py @@ -1,5 +1,5 @@ -from django_filters.rest_framework import DjangoFilterBackend from django.db import models +from django_filters.rest_framework import DjangoFilterBackend from rest_framework import viewsets from ..administrative_units.filterset import AdministrativeUnitFilterSet @@ -33,6 +33,7 @@ UserAutocompleteSerializer, ) + class AdministrativeUnitAutocompleteViewSet(viewsets.ReadOnlyModelViewSet): queryset = AdministrativeUnit.objects.only("id", "name").all() serializer_class = AdministrativeUnitAutocompleteSerializer @@ -89,7 +90,7 @@ class InstitutionAutocompleteViewSet(viewsets.ReadOnlyModelViewSet): def get_queryset(self): req = self.request - related_case_id = req.GET.get('case', None) + related_case_id = req.GET.get("case", None) if related_case_id is None: qs = Institution.objects.all() else: @@ -98,9 +99,9 @@ def get_queryset(self): related=models.Case( models.When(case=related_case_id, then=True), default=False, - output_field=models.BooleanField() + output_field=models.BooleanField(), ) - ).order_by('-related') + ).order_by("-related") return qs.only("id", "name")