From f6f4f244d7871d7951a22236672360e7e9851158 Mon Sep 17 00:00:00 2001 From: meeb Date: Thu, 18 Feb 2021 19:34:44 +1100 Subject: [PATCH] hide skipped media by default and add a show skipped media button --- tubesync/common/templates/pagination.html | 2 +- tubesync/sync/templates/sync/media.html | 11 +++++++++-- tubesync/sync/views.py | 15 +++++++++++++-- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/tubesync/common/templates/pagination.html b/tubesync/common/templates/pagination.html index ae8f138..0e378a8 100644 --- a/tubesync/common/templates/pagination.html +++ b/tubesync/common/templates/pagination.html @@ -3,7 +3,7 @@
diff --git a/tubesync/sync/templates/sync/media.html b/tubesync/sync/templates/sync/media.html index 76ae9ea..521bee8 100644 --- a/tubesync/sync/templates/sync/media.html +++ b/tubesync/sync/templates/sync/media.html @@ -4,9 +4,16 @@ {% block content %}
-
+

Media

+
+ {% if show_skipped %} + Hide skipped media + {% else %} + Show skipped media + {% endif %} +
{% include 'infobox.html' with message=message %}
@@ -48,5 +55,5 @@
{% endfor %}
-{% include 'pagination.html' with pagination=sources.paginator filter=source.pk %} +{% include 'pagination.html' with pagination=sources.paginator filter=source.pk show_skipped=show_skipped %} {% endblock %} diff --git a/tubesync/sync/views.py b/tubesync/sync/views.py index d6a7851..c0d5a89 100644 --- a/tubesync/sync/views.py +++ b/tubesync/sync/views.py @@ -438,6 +438,7 @@ class MediaView(ListView): def __init__(self, *args, **kwargs): self.filter_source = None + self.show_skipped = False super().__init__(*args, **kwargs) def dispatch(self, request, *args, **kwargs): @@ -447,13 +448,22 @@ class MediaView(ListView): self.filter_source = Source.objects.get(pk=filter_by) except Source.DoesNotExist: self.filter_source = None + show_skipped = request.GET.get('show_skipped', '').strip() + if show_skipped == 'yes': + self.show_skipped = True return super().dispatch(request, *args, **kwargs) def get_queryset(self): if self.filter_source: - q = Media.objects.filter(source=self.filter_source) + if self.show_skipped: + q = Media.objects.filter(source=self.filter_source) + else: + q = Media.objects.filter(source=self.filter_source, skip=False) else: - q = Media.objects.all() + if self.show_skipped: + q = Media.objects.all() + else: + q = Media.objects.filter(skip=False) return q.order_by('-published', '-created') def get_context_data(self, *args, **kwargs): @@ -464,6 +474,7 @@ class MediaView(ListView): message = str(self.messages.get('filter', '')) data['message'] = message.format(name=self.filter_source.name) data['source'] = self.filter_source + data['show_skipped'] = self.show_skipped return data