From 6e012383ab3d2f90c2003176b1504912eba685cc Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 4 Jul 2022 21:12:54 +0700 Subject: [PATCH] toggle playlist subscribed filter --- .../home/templates/home/channel_id.html | 25 +++---------------- .../templates/home/channel_id_playlist.html | 11 ++++++++ tubearchivist/home/views.py | 9 ++++--- 3 files changed, 20 insertions(+), 25 deletions(-) diff --git a/tubearchivist/home/templates/home/channel_id.html b/tubearchivist/home/templates/home/channel_id.html index a4e7f74..1e5b1b4 100644 --- a/tubearchivist/home/templates/home/channel_id.html +++ b/tubearchivist/home/templates/home/channel_id.html @@ -12,7 +12,7 @@

About

-
+
-

Last refreshed: {{ channel_info.channel_last_refresh }}

- {% if channel_info.channel_active %} -

Youtube: Active

- {% else %} -

Youtube: Deactivated

- {% endif %} - -
- Delete {{ channel_info.channel_name }} including all videos? -
-
-
-
-
- {% if channel_info.channel_views >= 1000000 %} -

Channel views: {{ channel_info.channel_views|intword }}

- {% elif channel_info.channel_views > 0 %} -

Channel views: {{ channel_info.channel_views|intcomma }}

- {% endif %} {% if max_hits %} -

Total Videos archived: {{ max_hits }}

-

Watched:

+

Total Videos: {{ max_hits }}

+ {% endif %}
diff --git a/tubearchivist/home/templates/home/channel_id_playlist.html b/tubearchivist/home/templates/home/channel_id_playlist.html index a1733f7..b7f5891 100644 --- a/tubearchivist/home/templates/home/channel_id_playlist.html +++ b/tubearchivist/home/templates/home/channel_id_playlist.html @@ -12,6 +12,17 @@

About

+
+ Show subscribed only: +
+ + {% if not show_subed_only %} + + {% else %} + + {% endif %} +
+
grid view list view diff --git a/tubearchivist/home/views.py b/tubearchivist/home/views.py index 2519e32..85fe41e 100644 --- a/tubearchivist/home/views.py +++ b/tubearchivist/home/views.py @@ -549,9 +549,12 @@ class ChannelIdPlaylistView(ArchivistResultsView): def _update_view_data(self, channel_id): """update view specific data dict""" self.data["sort"] = [{"playlist_name.keyword": {"order": "asc"}}] - self.data["query"] = { - "term": {"playlist_channel_id": {"value": channel_id}} - } + must_list = [{"match": {"playlist_channel_id": channel_id}}] + + if self.context["show_subed_only"]: + must_list.append({"match": {"playlist_subscribed": True}}) + + self.data["query"] = {"bool": {"must": must_list}} def _get_channel_meta(self, channel_id): """get metadata for channel"""