Skip to content

Conversation

@girumb
Copy link
Contributor

@girumb girumb commented Jan 14, 2025

No description provided.

@girumb girumb requested a review from rhunwicks January 14, 2025 04:35
@girumb girumb self-assigned this Jan 14, 2025
)


class CountryManager(models.Manager):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary? Can we use objects = IdentifierManager.from_queryset(ReferenceDataQuerySet)() instead?

"""
field_lookups = [
*[(field, "icontains") for field in translation_fields("wealth_characteristic__name")],
("wealth_characteristic__code", "istartswith"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the codes are hierarchical, so I think this can be iexact

"""

renderer_classes = [JSONRenderer]
permission_classes = [DjangoModelPermissionsOrAnonReadOnly]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why DjangoModelPermissionsOrAnonReadOnly and not just AllowAny?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or just leave permissions classes blank and override get_permissions?

"""

renderer_classes = [JSONRenderer]
permission_classes = []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a better approach is:

    permission_classes = [AllowAny]

and no get_permissions. Does that work?

]


class LivelihoodBaselineFacetedSearchView(APIView):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be LivelihoodZoneBaselineFacetedSearchView

hea/urls.py Outdated
]
urlpatterns += [
path(
"api/livelihoodbaselinefacetedsearch/",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be /api/livelihoodzonebaselinefacetedsearch

)
self.assertEqual(response.status_code, 200)
data = response.data
self.assertEqual(len(data["products"]), 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we extend these unit tests so that they finish by using the filter and checking that the number of results matches the facet count?

I.e. call /api/livelihoodzonebaseline.json?product=XXX and check len(response.json)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the values from data["products"][0]["filter"], etc. to create the url.

Return a faceted set of matching filters
"""
results = {}
search_term = request.query_params.get("search", "")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that search here should be read from settings.SEARCH_PARAM.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rhunwicks rhunwicks self-requested a review January 22, 2025 09:04
@rhunwicks rhunwicks merged commit da40467 into main Jan 22, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants