Skip to content

Commit

Permalink
Turn __in filter lists into comma-separated strings (#227)
Browse files Browse the repository at this point in the history
For `__in` filters, the Paperless NGX API expects a comma-separated
string of IDs, not a list (see
paperless-ngx/paperless-ngx#6996). This patch
turns a list into such a string for `__in` filters.

Closes: #226

Signed-off-by: martin f. krafft <[email protected]>
  • Loading branch information
madduck authored Jul 2, 2024
1 parent 307f242 commit 0e4b1e9
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/pypaperless/models/mixins/helpers/iterable.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,25 @@ def pages(
"""
params = getattr(self, "_aiter_filters", None) or {}

for param in params:
if param.endswith("__in"):
value = params[param]
try:
value.extend([]) # throw AttributeError if not a list
params[param] = ",".join(map(str, value))

except AttributeError:
# value is not a list, don't modify
continue

params.setdefault("page", page)
params.setdefault("page_size", page_size)

# set requesting full permissions
if getattr(self, "_request_full_perms", False):
params.update({"full_perms": "true"})

return PageGenerator(self._api, self._api_path, self._resource_cls, params=params)
return PageGenerator(
self._api, self._api_path, self._resource_cls, params=params
)

0 comments on commit 0e4b1e9

Please sign in to comment.