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"> <table class="file-input">
{% if widget.is_initial %} {% if widget.is_initial %}
<tr> <tr>
<th>{{ widget.initial_text }}</th> <th>{{ widget.initial_text }}</th>
<td> <td>
<a href="{{ widget.value.url }}">Fichier</a> <a href="{{ widget.value.url }}">{% translate "File" %} [{{ widget.value|extension }}]</a>
</td> </td>
</tr> </tr>
{% if not widget.required %} {% if not widget.required %}

View file

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

View file

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