add a media filter to show only skipped media, resolves #197
This commit is contained in:
parent
538b3cb319
commit
77fb4963f9
|
@ -4,7 +4,7 @@
|
|||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col s12 m9">
|
||||
<div class="col s12 m6">
|
||||
<h1 class="truncate">Media</h1>
|
||||
</div>
|
||||
<div class="col s12 m3">
|
||||
|
@ -14,6 +14,13 @@
|
|||
<a href="{% url 'sync:media' %}?show_skipped=yes{% if source %}&filter={{ source.pk }}{% endif %}" class="btn"><i class="far fa-eye"></i> Show skipped media</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="col s12 m3">
|
||||
{% if only_skipped %}
|
||||
<a href="{% url 'sync:media' %}{% if source %}?filter={{ source.pk }}{% endif %}" class="btn"><i class="far fa-eye-slash"></i> Only skipped media</a>
|
||||
{% else %}
|
||||
<a href="{% url 'sync:media' %}?only_skipped=yes{% if source %}&filter={{ source.pk }}{% endif %}" class="btn"><i class="far fa-eye"></i> Only skipped media</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% include 'infobox.html' with message=message %}
|
||||
<div class="row no-margin-bottom">
|
||||
|
|
|
@ -445,6 +445,7 @@ class MediaView(ListView):
|
|||
def __init__(self, *args, **kwargs):
|
||||
self.filter_source = None
|
||||
self.show_skipped = False
|
||||
self.only_skipped = False
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
|
@ -457,17 +458,25 @@ class MediaView(ListView):
|
|||
show_skipped = request.GET.get('show_skipped', '').strip()
|
||||
if show_skipped == 'yes':
|
||||
self.show_skipped = True
|
||||
if not self.show_skipped:
|
||||
only_skipped = request.GET.get('only_skipped', '').strip()
|
||||
if only_skipped == 'yes':
|
||||
self.only_skipped = True
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
def get_queryset(self):
|
||||
if self.filter_source:
|
||||
if self.show_skipped:
|
||||
q = Media.objects.filter(source=self.filter_source)
|
||||
elif self.only_skipped:
|
||||
q = Media.objects.filter(source=self.filter_source, skip=True)
|
||||
else:
|
||||
q = Media.objects.filter(source=self.filter_source, skip=False)
|
||||
else:
|
||||
if self.show_skipped:
|
||||
q = Media.objects.all()
|
||||
elif self.only_skipped:
|
||||
q = Media.objects.filter(skip=True)
|
||||
else:
|
||||
q = Media.objects.filter(skip=False)
|
||||
return q.order_by('-published', '-created')
|
||||
|
@ -481,6 +490,7 @@ class MediaView(ListView):
|
|||
data['message'] = message.format(name=self.filter_source.name)
|
||||
data['source'] = self.filter_source
|
||||
data['show_skipped'] = self.show_skipped
|
||||
data['only_skipped'] = self.only_skipped
|
||||
return data
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue