mirror of
https://github.com/Alexander-D-Karpov/akarpov
synced 2024-11-22 13:16:33 +03:00
added preview for files in folders
This commit is contained in:
parent
c0c6c5f8d4
commit
76457b27b7
|
@ -10,6 +10,7 @@
|
||||||
ForeignKey,
|
ForeignKey,
|
||||||
IntegerField,
|
IntegerField,
|
||||||
Model,
|
Model,
|
||||||
|
Q,
|
||||||
SlugField,
|
SlugField,
|
||||||
TextField,
|
TextField,
|
||||||
)
|
)
|
||||||
|
@ -116,6 +117,9 @@ class Folder(BaseFileItem, ShortLinkModel, UserHistoryModel):
|
||||||
size = IntegerField(default=0)
|
size = IntegerField(default=0)
|
||||||
amount = IntegerField(default=0)
|
amount = IntegerField(default=0)
|
||||||
|
|
||||||
|
def get_last_preview_files(self, cut=4):
|
||||||
|
return self.children.filter(~Q(File___preview=""))[:cut]
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse("files:folder", kwargs={"slug": self.slug})
|
return reverse("files:folder", kwargs={"slug": self.slug})
|
||||||
|
|
||||||
|
|
|
@ -124,6 +124,15 @@
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="card-body d-flex flex-column">
|
<div class="card-body d-flex flex-column">
|
||||||
<h5 class="card-title">{{ file.name }}</h5>
|
<h5 class="card-title">{{ file.name }}</h5>
|
||||||
|
<div class="flex-column position-absolute ml-2 top-50 start-50 translate-middle">
|
||||||
|
<div class="align-items-center justify-content-center row position-relative mb-5 g-3">
|
||||||
|
{% for child_file in file.get_last_preview_files %}
|
||||||
|
<div class="col-6">
|
||||||
|
<img class="img-fluid" src="{{ child_file.preview.url }}" alt="">
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<p class="card-text mb-4"><small class="text-muted">{{ file.size | filesizeformat }}, {{ file.amount }} {% if file.amount == 1 %} item {% else %} items {% endif %}</small></p>
|
<p class="card-text mb-4"><small class="text-muted">{{ file.size | filesizeformat }}, {{ file.amount }} {% if file.amount == 1 %} item {% else %} items {% endif %}</small></p>
|
||||||
<div class="align-self-stretch align-items-center justify-content-center d-flex flex-column fill-height controlsdiv">
|
<div class="align-self-stretch align-items-center justify-content-center d-flex flex-column fill-height controlsdiv">
|
||||||
<img src="{% static 'images/files/folder.jpg' %}" class="img-fluid" alt="">
|
<img src="{% static 'images/files/folder.jpg' %}" class="img-fluid" alt="">
|
||||||
|
|
Loading…
Reference in New Issue
Block a user