Added search bar to collection list

This commit is contained in:
Tris Forster 2023-03-04 17:12:58 +11:00
parent 0bd2596ebc
commit fb700b15d6
2 changed files with 4 additions and 10 deletions

View File

@ -30,9 +30,6 @@
<th>Composer</th> <th>Composer</th>
<th class="is-hidden-mobile">Edition</th> <th class="is-hidden-mobile">Edition</th>
{% if not collection %}<th class="is-hidden-touch">Collection</th>{% endif %} {% if not collection %}<th class="is-hidden-touch">Collection</th>{% endif %}
{% if request.is_admin %}
<th class="is-hidden-mobile">Copies</th>
{% endif %}
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -42,9 +39,6 @@
<td title="{{ work.composer }}">{{ work.composer|truncatewords:3 }}</td> <td title="{{ work.composer }}">{{ work.composer|truncatewords:3 }}</td>
<td class="is-hidden-mobile" title="{{ work.edition }}">{{ work.edition|truncatewords:2 }}</td> <td class="is-hidden-mobile" title="{{ work.edition }}">{{ work.edition|truncatewords:2 }}</td>
{% if not collection %}<td class="is-hidden-touch">{{ work.collection.name }}</td>{% endif %} {% if not collection %}<td class="is-hidden-touch">{{ work.collection.name }}</td>{% endif %}
{% if request.is_admin %}
<td class="is-hidden-mobile {{ work.is_available|yesno:'has-text-success,has-text-danger' }}">{{ work.available }}</td>
{% endif %}
</tr> </tr>
{% empty %} {% empty %}
<tr><td colspan="4">No works found</td></tr> <tr><td colspan="4">No works found</td></tr>

View File

@ -184,7 +184,7 @@ class LibraryWorkListView(WorkListView):
return True return True
def get_works(self): def get_works(self):
collections = models.Collection.objects collections = models.Collection.objects.all()
if not self.request.user.is_superuser: if not self.request.user.is_superuser:
collections = collections.filter(administrators=self.request.user) collections = collections.filter(administrators=self.request.user)
@ -204,9 +204,9 @@ class CollectionWorkListView(WorkListView):
def get_works(self): def get_works(self):
works = Work.objects.filter(collection=self.kwargs['collection']) works = Work.objects.filter(collection=self.kwargs['collection'])
if self.request.is_admin: #if self.request.is_admin:
loan_count = Count('project_items', Q(project_items__checkout__lte=now(), project_items__returned=None)) # loan_count = Count('project_items', Q(project_items__checkout__lte=now(), project_items__returned=None))
works = works.annotate(loan_count=loan_count) # works = works.annotate(loan_count=loan_count)
return works return works
def get_context_data(self, *args, **kwargs): def get_context_data(self, *args, **kwargs):