Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LTD-5947-doc-generation-view #2435

Draft
wants to merge 3 commits into
base: dev
Choose a base branch
from
Draft

Conversation

depsiatwal
Copy link
Contributor

https://uktrade.atlassian.net/browse/LTD-5947

This is still WIP most likely the filter ability will change and we will add/remove items that are returned.

This iteration is just returning the template details to the frontend so we can obtain the template id for next step in letter generation. The current view that supports this depends to much on case/advice/goods filtering.

@@ -276,3 +280,13 @@ def get(self, request, **kwargs):
return JsonResponse(data=preview, status=status.HTTP_400_BAD_REQUEST)

return JsonResponse(data={"preview": preview}, status=status.HTTP_200_OK)


class LetterTemplatesFilter(generics.ListAPIView):
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is a new endpoint, would suggest that we think about locating it under api/letter_templates/caseworker/ - ideally I think for most things going forward we will do a caseworker or an exporter endpoint

Comment on lines +290 to +292
def get_queryset(self):
case_type = self.kwargs["case_type"]
return LetterTemplate.objects.filter(case_types__sub_type=case_type)
Copy link
Contributor

@currycoder currycoder Feb 28, 2025

Choose a reason for hiding this comment

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

Take a look at django-filter based API filtering;

filter_backends = [DjangoFilterBackend]
filterset_class = GovUserFilter

It seems like we could do this declaratively with a filter class instead of having to override the queryset

Docs; https://www.django-rest-framework.org/api-guide/filtering/#djangofilterbackend

@@ -91,3 +91,11 @@ class LetterTemplateListSerializer(serializers.Serializer):
case_types = CaseTypeReferenceListSerializer(many=True)
layout = LetterLayoutReadOnlySerializer()
updated_at = serializers.DateTimeField()


class LetterTemplateFilterSerializer(serializers.ModelSerializer):
Copy link
Contributor

Choose a reason for hiding this comment

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

Putting "Filter" in the name here doesn't seem right, it's just a LetterTemplateSerializer - right?

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.

2 participants