sort document lists by their status

This commit is contained in:
Tomáš Mládek 2020-04-15 21:54:55 +02:00
parent 264dc9485d
commit 23faa2bb69
3 changed files with 33 additions and 10 deletions

View file

@ -100,6 +100,20 @@ ul > li:before {
margin: 0 0 1rem 0; margin: 0 0 1rem 0;
} }
.docs-header {
text-align: center;
text-transform: uppercase;
background: #303030;
}
.docs-header h3 {
margin: 0;
}
.doc-item {
padding: 1.2rem 1rem;
}
.doc-item-text { .doc-item-text {
display: inline-block; display: inline-block;
margin-right: 3em; margin-right: 3em;

View file

@ -19,16 +19,21 @@
</div> </div>
{% endif %} {% endif %}
{% for document in documents %} {% for status, documents in status_documents.items %}
<div class="text doc-item"> {% if documents|length > 0 %}
<a class="doc-item-link" href="{% url "pile:retrieve" document.id %}">🔗</a> <div class="text docs-header"><h3>{{ status.label }}</h3></div>
<a href="{% url "pile:document" document.id %}"> {% for document in documents %}
<div class="doc-item-text"> <div class="text doc-item">
<h2>{{ document.title }}</h2> <a class="doc-item-link" href="{% url "pile:retrieve" document.id %}">🔗</a>
<h3>{{ document.author }} {{ document.published }}</h3> <a href="{% url "pile:document" document.id %}">
<div class="doc-item-text">
<h2>{{ document.title }}</h2>
<h3>{{ document.author }} {{ document.published }}</h3>
</div>
</a>
</div> </div>
</a> {% endfor %}
</div> {% endif %}
{% endfor %} {% endfor %}
{% endblock %} {% endblock %}

View file

@ -78,10 +78,14 @@ class TagView(BasePileView):
except ObjectDoesNotExist: except ObjectDoesNotExist:
raise Http404 raise Http404
status_documents = {s: [] for s in Document.DocumentStatus}
for document in documents:
status_documents[document.status] += [document]
return { return {
'tag': tag if tag != "UNTAGGED" else None, 'tag': tag if tag != "UNTAGGED" else None,
'untagged': tag == "UNTAGGED", 'untagged': tag == "UNTAGGED",
'documents': documents, 'status_documents': status_documents,
**base_context_data **base_context_data
} }