better 404 handling in views
This commit is contained in:
parent
c176405b32
commit
86d157699a
|
@ -386,7 +386,7 @@ class ThumbValidator:
|
|||
"query": {"bool": {"should": should_list}},
|
||||
"_source": ["youtube_id"],
|
||||
}
|
||||
result = IndexPaginate("ta_video", data).get_results()
|
||||
result = IndexPaginate("ta_video,ta_download", data).get_results()
|
||||
thumbs_should = {i["youtube_id"] for i in result}
|
||||
|
||||
return thumbs_should
|
||||
|
|
|
@ -431,6 +431,8 @@ class ChannelIdBaseView(ArchivistResultsView):
|
|||
path = f"ta_channel/_doc/{channel_id}"
|
||||
response, _ = ElasticWrap(path).get()
|
||||
channel_info = SearchProcess(response).process()
|
||||
if not channel_info:
|
||||
raise Http404
|
||||
|
||||
return channel_info
|
||||
|
||||
|
@ -724,6 +726,9 @@ class PlaylistIdView(ArchivistResultsView):
|
|||
"""handle get request"""
|
||||
self.initiate_vars(request)
|
||||
playlist_info, channel_info = self._get_info(playlist_id)
|
||||
if not playlist_info:
|
||||
raise Http404
|
||||
|
||||
playlist_name = playlist_info["playlist_name"]
|
||||
self._update_view_data(playlist_id, playlist_info)
|
||||
self.find_results()
|
||||
|
@ -874,6 +879,8 @@ class VideoView(MinView):
|
|||
config_handler = AppConfig()
|
||||
response, _ = ElasticWrap(f"ta_video/_doc/{video_id}").get()
|
||||
video_data = SearchProcess(response).process()
|
||||
if not video_data:
|
||||
raise Http404
|
||||
|
||||
try:
|
||||
rating = video_data["stats"]["average_rating"]
|
||||
|
|
Loading…
Reference in New Issue