mirror of
https://github.com/tubearchivist/tubearchivist-frontend.git
synced 2024-11-22 20:00:15 +00:00
implement show_subed_only on playlist view
This commit is contained in:
parent
a1167bac4e
commit
f26fbc0dc5
@ -732,7 +732,7 @@ class PlaylistView(View):
|
|||||||
)
|
)
|
||||||
|
|
||||||
url = view_config["es_url"] + "/ta_playlist/_search"
|
url = view_config["es_url"] + "/ta_playlist/_search"
|
||||||
data = self.build_data(pagination_handler, search_get)
|
data = self.build_data(pagination_handler, search_get, view_config)
|
||||||
search = SearchHandler(url, data)
|
search = SearchHandler(url, data)
|
||||||
playlist_hits = search.get_data()
|
playlist_hits = search.get_data()
|
||||||
pagination_handler.validate(search.max_hits)
|
pagination_handler.validate(search.max_hits)
|
||||||
@ -742,6 +742,7 @@ class PlaylistView(View):
|
|||||||
"search_form": search_form,
|
"search_form": search_form,
|
||||||
"title": "Playlists",
|
"title": "Playlists",
|
||||||
"colors": view_config["colors"],
|
"colors": view_config["colors"],
|
||||||
|
"show_subed_only": view_config["show_subed_only"],
|
||||||
"pagination": pagination_handler.pagination,
|
"pagination": pagination_handler.pagination,
|
||||||
"playlists": playlist_hits,
|
"playlists": playlist_hits,
|
||||||
"view_style": view_config["view_style"],
|
"view_style": view_config["view_style"],
|
||||||
@ -749,7 +750,7 @@ class PlaylistView(View):
|
|||||||
return render(request, "home/playlist.html", context)
|
return render(request, "home/playlist.html", context)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def build_data(pagination_handler, search_get):
|
def build_data(pagination_handler, search_get, view_config):
|
||||||
"""build data object for query"""
|
"""build data object for query"""
|
||||||
data = {
|
data = {
|
||||||
"size": pagination_handler.pagination["page_size"],
|
"size": pagination_handler.pagination["page_size"],
|
||||||
@ -759,6 +760,8 @@ class PlaylistView(View):
|
|||||||
},
|
},
|
||||||
"sort": [{"playlist_name.keyword": {"order": "asc"}}],
|
"sort": [{"playlist_name.keyword": {"order": "asc"}}],
|
||||||
}
|
}
|
||||||
|
if view_config["show_subed_only"]:
|
||||||
|
data["query"] = {"term": {"playlist_subscribed": {"value": True}}}
|
||||||
if search_get:
|
if search_get:
|
||||||
data["query"] = {
|
data["query"] = {
|
||||||
"bool": {
|
"bool": {
|
||||||
@ -791,10 +794,14 @@ class PlaylistView(View):
|
|||||||
if not view_style:
|
if not view_style:
|
||||||
view_style = config_handler.config["default_view"]["channel"]
|
view_style = config_handler.config["default_view"]["channel"]
|
||||||
|
|
||||||
|
sub_only_key = f"{user_id}:show_subed_only"
|
||||||
|
show_subed_only = RedisArchivist().get_message(sub_only_key)["status"]
|
||||||
|
|
||||||
view_config = {
|
view_config = {
|
||||||
"es_url": config_handler.config["application"]["es_url"],
|
"es_url": config_handler.config["application"]["es_url"],
|
||||||
"colors": config_handler.colors,
|
"colors": config_handler.colors,
|
||||||
"view_style": view_style,
|
"view_style": view_style,
|
||||||
|
"show_subed_only": show_subed_only,
|
||||||
}
|
}
|
||||||
return view_config
|
return view_config
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user