Show file extension

This commit is contained in:
Edgar P. Burkhart 2023-04-19 17:19:01 +02:00
parent 06b51a87ff
commit 9deba5b28f
Signed by: edpibu
GPG Key ID: 9833D3C5A25BD227
3 changed files with 9 additions and 2 deletions

View File

@ -1,9 +1,11 @@
{% load i18n %}
{% load main_extras %}
<table class="file-input">
{% if widget.is_initial %}
<tr>
<th>{{ widget.initial_text }}</th>
<td>
<a href="{{ widget.value.url }}">Fichier</a>
<a href="{{ widget.value.url }}">{% translate "File" %} [{{ widget.value|extension }}]</a>
</td>
</tr>
{% if not widget.required %}

View File

@ -18,7 +18,7 @@
<a href="{{ invoice.get_absolute_url }}">{{ invoice.name }}</a>
</th>
<td>
<a href="{{ invoice.file.url }}">{% translate "File" %}</a>
<a href="{{ invoice.file.url }}">{% translate "File" %} [{{ invoice.file|extension }}]</a>
</td>
<td>
<a href="{{ invoice.get_delete_url }}">{% translate "Delete" %}

View File

@ -45,3 +45,8 @@ def form_buttons(instance):
@register.filter
def remix(icon):
return mark_safe(f"""<span class="ri-{icon}-line"></span>""")
@register.filter
def extension(file):
return file.name.split(".")[-1].upper()