Author name added to search filter
This commit is contained in:
parent
c7a185a919
commit
2586dcc944
@ -100,8 +100,6 @@ 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)
|
||||||
|
|
||||||
@ -111,7 +109,9 @@ class TicketListApiView(APIView):
|
|||||||
if key == "search":
|
if key == "search":
|
||||||
queryset = queryset.filter(
|
queryset = queryset.filter(
|
||||||
Q(**{"title__contains": values}) |
|
Q(**{"title__contains": values}) |
|
||||||
Q(**{"description__contains": values})
|
Q(**{"description__contains": values}) |
|
||||||
|
Q(**{"author__forename__contains": values}) |
|
||||||
|
Q(**{"author__surname__contains": values})
|
||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ class TicketListApiView(APIView):
|
|||||||
filter_kwargs = {key: [value]}
|
filter_kwargs = {key: [value]}
|
||||||
queryset = queryset.filter(Q(**filter_kwargs))
|
queryset = queryset.filter(Q(**filter_kwargs))
|
||||||
|
|
||||||
tickets = queryset.order_by("-create_timestamp")
|
tickets = queryset.order_by("-edit_timestamp")
|
||||||
serializer = TicketSerializer(tickets, many=True)
|
serializer = TicketSerializer(tickets, many=True)
|
||||||
response_data = serializer.data
|
response_data = serializer.data
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user