random document listing

This commit is contained in:
Tomáš Mládek 2020-04-01 01:50:41 +02:00
parent 13b17710c8
commit ce29e64299
3 changed files with 26 additions and 2 deletions

View file

@ -197,12 +197,17 @@ ul > li:before {
}
}
.random-tags {
font-style: italic;
color: white;
margin: .2em 0;
}
.recent-additions li {
margin-bottom: .5em;
}
.recent-additions-desc {
.index-listing-desc {
font-size: 12pt;
color: #bfbfbf;
padding-left: calc(20px + .5rem);

View file

@ -10,6 +10,23 @@
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>
</div>
<div class="text">
<h2>Random document</h2>
<div class="random-document">
<a href="{% url 'pile:document' random_document.id %}">
<span>#{{ random_document.id }}: {{ random_document.title }}</span>
<div class="index-listing-desc">
{% if random_document.tags.count > 0 %}
<div class="random-tags">Filed under: {{ random_document.tags.all | join:" / " }}</div>
{% endif %}
</div>
<div class="index-listing-desc">
{{ random_document.description }}
</div>
</a>
</div>
</div>
<div class="text recent-additions">
<h2>Recent additions</h2>
@ -22,7 +39,7 @@
{% endif %}
{{ document.title }}
<div class="recent-additions-desc">
<div class="index-listing-desc">
{{ document.description }}
</div>
</a>

View file

@ -2,6 +2,7 @@
import io
import logging
from operator import itemgetter
from random import choice
import weasyprint
from PyPDF2 import PdfFileWriter, PdfFileReader
@ -49,6 +50,7 @@ class IndexView(BasePileView):
return {
'recent_documents': self.documents.order_by('-uploaded')[:5],
'random_document': choice(self.documents.all()),
**base_context_data
}