-
Notifications
You must be signed in to change notification settings - Fork 2
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
base: dev
Are you sure you want to change the base?
Conversation
@@ -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): |
There was a problem hiding this comment.
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
def get_queryset(self): | ||
case_type = self.kwargs["case_type"] | ||
return LetterTemplate.objects.filter(case_types__sub_type=case_type) |
There was a problem hiding this comment.
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;
lite-api/api/gov_users/caseworker/views.py
Lines 24 to 25 in 8d23e01
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): |
There was a problem hiding this comment.
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?
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.