diff --git a/akarpov/files/models.py b/akarpov/files/models.py index da1e747..6ca27d7 100644 --- a/akarpov/files/models.py +++ b/akarpov/files/models.py @@ -10,6 +10,7 @@ ForeignKey, IntegerField, Model, + Q, SlugField, TextField, ) @@ -116,6 +117,9 @@ class Folder(BaseFileItem, ShortLinkModel, UserHistoryModel): size = 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): return reverse("files:folder", kwargs={"slug": self.slug}) diff --git a/akarpov/templates/files/list.html b/akarpov/templates/files/list.html index e4d236e..6a0d7bf 100644 --- a/akarpov/templates/files/list.html +++ b/akarpov/templates/files/list.html @@ -124,6 +124,15 @@ {% else %}
{{ file.size | filesizeformat }}, {{ file.amount }} {% if file.amount == 1 %} item {% else %} items {% endif %}