better file display

This commit is contained in:
2025-07-16 22:30:47 +02:00
parent 60f231d908
commit 96b2549503
2 changed files with 15 additions and 2 deletions

View File

@@ -1,3 +1,5 @@
from pathlib import Path
from django.core.validators import FileExtensionValidator, ValidationError
from django.db import models
from django.urls import reverse
@@ -221,3 +223,6 @@ class Bill(models.Model):
def clean(self):
if self.status is None:
self.status = Bill.Status.SUBMITTED
def filename(self):
return Path(self.file_field.name).name

View File

@@ -103,8 +103,12 @@
<a
href="{{ form.file_field.value.url }}"
target="_blank"
class="text-gray-700 dark:text-gray-200 block w-full mt-1 rounded-md border-gray-300 dark:border-none shadow-sm focus:border-none focus:ring focus:ring-blue-200 dark:focus:ring-sky-700 focus:ring-opacity-50"
>{{ form.file_field.value }}</a>
>
<i class="fa-solid fa-file fa-fw text-red-800 dark:text-red-500 md:text-inherit group-hover:text-red-800 dark:group-hover:text-red-500"></i>
<span class="ml-2 sm:ml-1">{{ object.filename }}</span>
</a>
</label>
</div>
{% endif %}
@@ -122,8 +126,12 @@
<span class="text-gray-700 dark:text-gray-200">Hochgeladene Rechnung:</span>
<a
href="{{ form.file_field.value.url }}"
target="_blank"
class="text-gray-700 dark:text-gray-200 block w-full mt-1 rounded-md border-gray-300 dark:border-none shadow-sm focus:border-none focus:ring focus:ring-blue-200 dark:focus:ring-sky-700 focus:ring-opacity-50"
>{{ form.file_field.value }}</a>
>
<i class="fa-solid fa-file fa-fw text-red-800 dark:text-red-500 md:text-inherit group-hover:text-red-800 dark:group-hover:text-red-500"></i>
<span class="ml-2 sm:ml-1">{{ object.filename }}</span>
</a>
</label>
</div>