Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jun 17, 2021
1 parent 37927f9 commit 9c3a40c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions backend-project/small_eod/autocomplete/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
9 changes: 5 additions & 4 deletions backend-project/small_eod/autocomplete/views.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -33,6 +33,7 @@
UserAutocompleteSerializer,
)


class AdministrativeUnitAutocompleteViewSet(viewsets.ReadOnlyModelViewSet):
queryset = AdministrativeUnit.objects.only("id", "name").all()
serializer_class = AdministrativeUnitAutocompleteSerializer
Expand Down Expand Up @@ -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:
Expand All @@ -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")


Expand Down

0 comments on commit 9c3a40c

Please sign in to comment.