mirror of
https://git.sdbs.cz/sdbs/pile.git
synced 2025-05-10 00:12:18 +00:00
fix random crash if no documents present
This commit is contained in:
parent
fb73142de5
commit
54f57e1531
2 changed files with 18 additions and 16 deletions
|
@ -10,6 +10,7 @@
|
||||||
postupně dávat ty nejdůležitější nebo nejzajímavější věci, zatim se o tom ale nikde moc nešiřte.</p>
|
postupně dávat ty nejdůležitější nebo nejzajímavější věci, zatim se o tom ale nikde moc nešiřte.</p>
|
||||||
<p class="intro sign">/-\</p>
|
<p class="intro sign">/-\</p>
|
||||||
</div>
|
</div>
|
||||||
|
{% if random_document %}
|
||||||
<div class="text">
|
<div class="text">
|
||||||
<h2>Random document</h2>
|
<h2>Random document</h2>
|
||||||
<div class="random-document">
|
<div class="random-document">
|
||||||
|
@ -27,6 +28,7 @@
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<div class="text recent-additions">
|
<div class="text recent-additions">
|
||||||
<h2>Recent additions</h2>
|
<h2>Recent additions</h2>
|
||||||
|
|
|
@ -51,7 +51,7 @@ class IndexView(BasePileView):
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'recent_documents': self.documents.order_by('-uploaded')[:5],
|
'recent_documents': self.documents.order_by('-uploaded')[:5],
|
||||||
'random_document': choice(self.documents.all()[5:]),
|
'random_document': choice(self.documents.all()[5:]) if self.documents.count() > 0 else None,
|
||||||
**base_context_data
|
**base_context_data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue