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

Some fixes for issues discovered in new version #90

Merged
merged 5 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
History
=======

UNRELEASED
------------------

* Fix issues with query params parsing
* Make `get_queryset` consistent for start actions

1.3.0 (2025-01-09)
------------------

Expand Down
3 changes: 3 additions & 0 deletions import_export_extensions/api/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ class LimitQuerySetToCurrentUserMixin:

def get_queryset(self):
"""Return user's jobs."""
if self.action == "start":
# To make it consistent and for better support of drf-spectacular
return super().get_queryset() # pragma: no cover
return (
super()
.get_queryset()
Expand Down
8 changes: 5 additions & 3 deletions import_export_extensions/api/views/export_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ class ExportJobViewSet(

def get_queryset(self):
"""Filter export jobs by resource used in viewset."""
if self.action == "start":
# To make it consistent and for better support of drf-spectacular
return super().get_queryset() # pragma: no cover
return super().get_queryset().filter(
resource_path=self.resource_class.class_path,
)
Expand Down Expand Up @@ -157,12 +160,11 @@ def get_export_create_serializer_class(self):

def start(self, request: Request):
"""Validate request data and start ExportJob."""
query_params = dict(request.query_params)
ordering = query_params.pop("ordering", self.ordering)
ordering = request.query_params.getlist("ordering", default=())
serializer = self.get_serializer(
data=request.data,
ordering=ordering,
filter_kwargs=query_params,
filter_kwargs=request.query_params,
)
serializer.is_valid(raise_exception=True)
export_job = serializer.save()
Expand Down
Loading