Skip to content
This repository has been archived by the owner on May 20, 2024. It is now read-only.

Commit

Permalink
fix: Provide separate thumbnail handler for documents to resolve miss…
Browse files Browse the repository at this point in the history
…ing url completion
  • Loading branch information
hepplerj committed Apr 26, 2024
1 parent 453938d commit c7b6541
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion postcards/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Meta:

class DocumentsHtmxTable(tables.Table):
thumbnail = tables.TemplateColumn(
template_name="postal/thumbnail.html", orderable=False
template_name="postal/document_thumbnail.html", orderable=False
)
title = tables.Column(accessor="title", verbose_name="Title")
doc_type = tables.Column(accessor="document_type", verbose_name="Document Type")
Expand Down
8 changes: 8 additions & 0 deletions theme/templates/postal/document_thumbnail.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% load static %}
{% if record.images.first %}
<a href="{% url 'document' id=record.id %}"><img class="mx-auto d-block" src="{{ record.images.first.image.url }}" alt="Thumbnail" width="50" height="50"/></a>
<p class="text-center"><a class="table-caption" href="{% url 'document' id=record.id %}">{{ record.item_id }}</a></p>
{% else %}
<span class="text-center">No image available</span>
<p class="text-center"><a class="table-caption" href="{% url 'document' id=record.id %}">{{ record.item_id }}</a></p>
{% endif %}
18 changes: 4 additions & 14 deletions theme/templates/postal/thumbnail.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
{% load static %}
{% if record.images.first %}
<a href="{% if request.resolver_match.url_name == 'items' %}{% url 'items' id=record.id %}{% elif request.resolver_match.url_name == 'documents_table' %}{% url 'document' id=record.id %}{% endif %}">
<img class="mx-auto d-block" src="{{ record.images.first.image.url }}" alt="Thumbnail" width="50" height="50"/>
</a>
<p class="text-center">
<a class="table-caption" href="{% if request.resolver_match.url_name == 'items' %}{% url 'items' id=record.id %}{% elif request.resolver_match.url_name == 'documents_table' %}{% url 'document' id=record.id %}{% endif %}">
{{ record.item_id }}
</a>
</p>
<a href="{% url 'items' id=record.id %}"><img class="mx-auto d-block" src="{{ record.images.first.image.url }}" alt="Thumbnail" width="50" height="50"/></a>
<p class="text-center"><a class="table-caption" href="{% url 'items' id=record.id %}">{{ record.item_id }}</a></p>
{% else %}
<span class="text-center">No image available</span>
<p class="text-center">
<a class="table-caption" href="{% if request.resolver_match.url_name == 'items' %}{% url 'items' id=record.id %}{% elif request.resolver_match.url_name == 'documents_table' %}{% url 'document' id=record.id %}{% endif %}">
{{ record.item_id }}
</a>
</p>
{% endif %}
<p class="text-center"><a class="table-caption" href="{% url 'items' id=record.id %}">{{ record.item_id }}</a></p>
{% endif %}

0 comments on commit c7b6541

Please sign in to comment.