ticket API changed to detect "__in" key
This commit is contained in:
parent
db8206b1bd
commit
970d6c0307
@ -42,7 +42,7 @@ class TicketListApiView(APIView):
|
|||||||
pagination_class = TicketPaginiation
|
pagination_class = TicketPaginiation
|
||||||
|
|
||||||
ALLOWED_FILTERS = (
|
ALLOWED_FILTERS = (
|
||||||
"uuid__in", "priority__in", "tags__in", "author__department__in", "search"
|
"uuid__in", "priority", "tags__in", "author__department", "search"
|
||||||
)
|
)
|
||||||
MATCHER_MAP = {
|
MATCHER_MAP = {
|
||||||
"contains": lambda k, v: {k: v[0]},
|
"contains": lambda k, v: {k: v[0]},
|
||||||
@ -100,6 +100,8 @@ class TicketListApiView(APIView):
|
|||||||
for key, values in request.GET.lists():
|
for key, values in request.GET.lists():
|
||||||
key = key.removesuffix("[]")
|
key = key.removesuffix("[]")
|
||||||
|
|
||||||
|
print(key, values)
|
||||||
|
|
||||||
if key not in self.ALLOWED_FILTERS:
|
if key not in self.ALLOWED_FILTERS:
|
||||||
raise KeyError(key)
|
raise KeyError(key)
|
||||||
|
|
||||||
@ -116,6 +118,10 @@ class TicketListApiView(APIView):
|
|||||||
if "all" in values:
|
if "all" in values:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if not key.endswith("__in"):
|
||||||
|
queryset = queryset.filter(Q(**{key: values}))
|
||||||
|
continue
|
||||||
|
|
||||||
for value in values:
|
for value in values:
|
||||||
filter_kwargs = {key: [value]}
|
filter_kwargs = {key: [value]}
|
||||||
queryset = queryset.filter(Q(**filter_kwargs))
|
queryset = queryset.filter(Q(**filter_kwargs))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user