hide skipped media by default and add a show skipped media button
This commit is contained in:
parent
df35aa2a5f
commit
f6f4f244d7
|
@ -3,7 +3,7 @@
|
|||
<div class="col s12">
|
||||
<div class="pagination">
|
||||
{% for i in paginator.page_range %}
|
||||
<a class="pagenum{% if i == page_obj.number %} currentpage{% endif %}" href="?{% if filter %}filter={{ filter }}&{% endif %}page={{ i }}">{{ i }}</a>
|
||||
<a class="pagenum{% if i == page_obj.number %} currentpage{% endif %}" href="?{% if filter %}filter={{ filter }}&{% endif %}page={{ i }}{% if show_skipped %}&show_skipped=yes{% endif %}">{{ i }}</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -4,9 +4,16 @@
|
|||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col s12">
|
||||
<div class="col s12 m9">
|
||||
<h1 class="truncate">Media</h1>
|
||||
</div>
|
||||
<div class="col s12 m3">
|
||||
{% if show_skipped %}
|
||||
<a href="{% url 'sync:media' %}" class="btn"><i class="far fa-eye-slash"></i> Hide skipped media</a>
|
||||
{% else %}
|
||||
<a href="{% url 'sync:media' %}?show_skipped=yes" class="btn"><i class="far fa-eye"></i> Show skipped media</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% include 'infobox.html' with message=message %}
|
||||
<div class="row no-margin-bottom">
|
||||
|
@ -48,5 +55,5 @@
|
|||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% 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 %}
|
||||
|
|
|
@ -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:
|
||||
if self.show_skipped:
|
||||
q = Media.objects.filter(source=self.filter_source)
|
||||
else:
|
||||
q = Media.objects.filter(source=self.filter_source, skip=False)
|
||||
else:
|
||||
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
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue