Only show approved list items

This commit is contained in:
Mouse Reeve 2021-01-31 11:21:50 -08:00
parent a2e69d783d
commit 846489e88e
2 changed files with 8 additions and 6 deletions

View file

@ -23,11 +23,11 @@
<div class="columns content"> <div class="columns content">
<section class="column is-three-quarters"> <section class="column is-three-quarters">
{% if not list.books.exists %} {% if not items.exists %}
<p>This list is currently empty</p> <p>This list is currently empty</p>
{% else %} {% else %}
<ol> <ol>
{% for item in list.listitem_set.all %} {% for item in items %}
<li class="block"> <li class="block">
<div class="card"> <div class="card">
<header class="card-header"> <header class="card-header">

View file

@ -64,16 +64,18 @@ class List(View):
) )
suggestions = [s.book for s in suggestions[:5]] suggestions = [s.book for s in suggestions[:5]]
if len(suggestions) < 5: if len(suggestions) < 5:
suggestions += [s.default_edition for s in \ suggestions += [
models.Work.objects.filter( s.default_edition for s in \
~Q(editions__in=book_list.books.all()), models.Work.objects.filter(
).order_by('-updated_date') ~Q(editions__in=book_list.books.all()),
).order_by('-updated_date')
][:5 - len(suggestions)] ][:5 - len(suggestions)]
data = { data = {
'title': '%s | Lists' % book_list.name, 'title': '%s | Lists' % book_list.name,
'list': book_list, 'list': book_list,
'items': book_list.listitem_set.filter(approved=True),
'suggested_books': suggestions, 'suggested_books': suggestions,
'list_form': forms.ListForm(instance=book_list), 'list_form': forms.ListForm(instance=book_list),
'query': query or '' 'query': query or ''