improved preview on file list, fixed update time

This commit is contained in:
Alexander Karpov 2023-04-10 00:18:06 +03:00
parent 88c3c2d41a
commit e072f71d9b
2 changed files with 14 additions and 3 deletions

View File

@ -45,6 +45,12 @@ def file_image_url(self):
return settings.STATIC_URL + f"images/files/{end}.png"
return settings.STATIC_URL + "images/files/_blank.png"
@property
def file_size(self):
if self.file:
return self.file.size
return 0
def get_absolute_url(self):
return reverse("files:view", kwargs={"slug": self.slug})

View File

@ -14,6 +14,8 @@
display: flex;
flex-direction: column;
}
.fill-height { flex-grow: 1; width: 100%; }
.controlsdiv { display: table; width: 100%; }
</style>
{% endblock %}
@ -23,11 +25,14 @@
{% endfor %}
<div class="row">
{% for file in file_list %}
<div class="col-lg-2 col-md-4 col-sm-6 col-xs-12 mb-3 m-3 d-flex align-items-stretch card">
<div class="col-lg-2 col-xxl-2 col-md-4 col-sm-6 col-xs-12 mb-3 m-3 d-flex align-items-stretch card">
<div class="card-body d-flex flex-column">
<h5 class="card-title">{{ file.name }}</h5>
<p class="card-text mb-4"><small class="text-muted">{{ file.edited | naturaltime }}</small></p>
<img src="{{ file.file_image_url }}" class="card-img-bottom" alt="">
<p class="card-text mb-4"><small class="text-muted">{{ file.file_size | filesizeformat }}</small></p>
<div class="align-self-stretch align-items-center justify-content-center d-flex flex-column fill-height controlsdiv">
<img src="{{ file.file_image_url }}" class="img-fluid" alt="">
</div>
<p class="card-text mb-4 mt-2 ms-3"><small class="text-muted">{{ file.modified | naturaltime }}</small></p>
</div>
</div>
{% endfor %}