From fbb52dc93f9fbb12650654e3626d470916d06ba1 Mon Sep 17 00:00:00 2001 From: simon Date: Wed, 5 Oct 2022 15:47:17 +0200 Subject: [PATCH] implement basic channel query string for downloads page --- tubearchivist/home/views.py | 15 ++++++++++++--- tubearchivist/static/script.js | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/tubearchivist/home/views.py b/tubearchivist/home/views.py index 55b6918..8533585 100644 --- a/tubearchivist/home/views.py +++ b/tubearchivist/home/views.py @@ -362,7 +362,7 @@ class DownloadView(ArchivistResultsView): def get(self, request): """handle get request""" self.initiate_vars(request) - self._update_view_data() + self._update_view_data(request) self.find_results() self.context.update( { @@ -372,15 +372,24 @@ class DownloadView(ArchivistResultsView): ) return render(request, "home/downloads.html", self.context) - def _update_view_data(self): + def _update_view_data(self, request): """update downloads view specific data dict""" if self.context["show_ignored_only"]: filter_view = "ignore" else: filter_view = "pending" + + must_list = [{"term": {"status": {"value": filter_view}}}] + + channel_filter = request.GET.get("channel", False) + if channel_filter: + must_list.append( + {"term": {"channel_id": {"value": channel_filter}}} + ) + self.data.update( { - "query": {"term": {"status": {"value": filter_view}}}, + "query": {"bool": {"must": must_list}}, "sort": [{"timestamp": {"order": "asc"}}], } ) diff --git a/tubearchivist/static/script.js b/tubearchivist/static/script.js index 178ecec..7e375c1 100644 --- a/tubearchivist/static/script.js +++ b/tubearchivist/static/script.js @@ -140,7 +140,7 @@ function toggleCheckbox(checkbox) { var payload = JSON.stringify(payloadDict); sendPost(payload); setTimeout(function(){ - var currPage = window.location.pathname; + var currPage = window.location.pathname + window.location.search; window.location.replace(currPage); return false; }, 500);