handle 404 in channel-video and playlist-video api view

This commit is contained in:
simon 2022-04-17 10:08:24 +07:00
parent b8ca324aaf
commit eb6d6be3b9
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4

View File

@ -52,7 +52,10 @@ class ApiBaseView(APIView):
print(self.search_base) print(self.search_base)
response, status_code = ElasticWrap(self.search_base).get(data=data) response, status_code = ElasticWrap(self.search_base).get(data=data)
self.response["data"] = SearchProcess(response).process() self.response["data"] = SearchProcess(response).process()
self.status_code = status_code if self.response["data"]:
self.status_code = status_code
else:
self.status_code = 404
class VideoApiView(ApiBaseView): class VideoApiView(ApiBaseView):
@ -238,7 +241,7 @@ class ChannelApiVideoView(ApiBaseView):
self.get_document_list(data) self.get_document_list(data)
self.get_paginate() self.get_paginate()
return Response(self.response) return Response(self.response, status=self.status_code)
class PlaylistApiListView(ApiBaseView): class PlaylistApiListView(ApiBaseView):
@ -286,7 +289,7 @@ class PlaylistApiVideoView(ApiBaseView):
} }
self.get_document_list(data) self.get_document_list(data)
self.get_paginate() self.get_paginate()
return Response(self.response) return Response(self.response, status=self.status_code)
class DownloadApiView(ApiBaseView): class DownloadApiView(ApiBaseView):