Skip to content

Commit

Permalink
refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvin-muchiri committed Aug 26, 2024
1 parent fbb8864 commit 5aff467
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions onadata/apps/api/viewsets/entity_list_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,24 +182,24 @@ def get_queryset_entities(self, request, entity_list):
detail=True,
renderer_classes=[renderers.CSVRenderer],
)
def download(self, request, format=None, *args, **kwargs):
def download(self, request, *args, **kwargs):
"""Provides `download` action for dataset"""
accept_header = request.headers.get("Accept", "")

if (
format is not None or accept_header
kwargs.get("format") is not None or accept_header
) and not request.accepted_renderer.format == "csv":
raise NotFound(code=status.HTTP_404_NOT_FOUND)

entity_list = self.get_object()

return get_entity_list_export_response(request, entity_list, entity_list.name)

def retrieve(self, request, format=None, *args, **kwargs):
def retrieve(self, request, *args, **kwargs):
"""Override `retrieve` method"""
instance = self.get_object()

if format == "csv" or request.accepted_renderer.format == "csv":
if kwargs.get("format") == "csv" or request.accepted_renderer.format == "csv":
return get_entity_list_export_response(request, instance, instance.name)

return super().retrieve(request, format, *args, **kwargs)

0 comments on commit 5aff467

Please sign in to comment.