add additional read-only information in main table (#21486)

This commit is contained in:
Paul Marillonnet 2018-01-29 19:31:44 +01:00 committed by Frédéric Péters
parent 6d8c9f9a54
commit bf3e756d51
2 changed files with 12 additions and 4 deletions

View File

@ -7,7 +7,6 @@ from . import models
class DocumentTable(tables.Table):
'''Display the list of documents of the user'''
filename = tables.Column(verbose_name=_('filename').title())
size = tables.TemplateColumn(template_code='{{ record.document.content.size|filesizeformat }}',
orderable=False,
verbose_name=_('size').title())
@ -15,5 +14,5 @@ class DocumentTable(tables.Table):
class Meta:
model = models.Document
fields = ('filename', 'size', 'created')
fields = ('size', 'created')
empty_text = _('You currently have no documents')

View File

@ -5,6 +5,7 @@
{% block table.thead %}
<thead>
<tr>
<th class="orderable sortable title"><a href="?sort=title">Title</a></th>
{% for column in table.columns %}
{% if column.orderable %}
<th {{ column.attrs.th.as_html }}>
@ -24,13 +25,16 @@
<tr class="{{ forloop.counter|divisibleby:2|yesno:"even,odd" }} {{row.record.css_classes}}"
data-url="{{row.record.get_download_url}}"
> {# avoid cycle for Django 1.2-1.6 compatibility #}
<td class="title">
{% if row.record.title %}{{ row.record.title }}{% else %}{{ row.record.filename }}{% endif %}
</td>
{% for column, cell in row.items %}
<td {{ column.attrs.td.as_html }}>{% if column.localize == None %}{{ cell }}{% else %}{% if column.localize %}{{ cell|localize }}{% else %}{{ cell|unlocalize }}{% endif %}{% endif %}</td>
{% endfor %}
{% with url=row.record.get_thumbnail_url %}
<td class="thumbnail">{% if url %}<img src="{{ url }}"/>{% endif %}</td>
<td class="thumbnail" rowspan={{ row.record.description|yesno:"2,1" }}>{% if url %}<img src="{{ url }}"/>{% endif %}</td>
{% endwith %}
<td class="action-column">
<td class="action-column" rowspan={{ row.record.description|yesno:"2,1" }}>
{% block action-column %}
{% if include_edit_link %}
<a class="icon-edit" rel="popup" href="{% url 'edit' pk=row.record.pk %}"></a>
@ -44,6 +48,11 @@
{% endblock %}
</td>
</tr>
{% if row.record.description %}
<tr class="{{ forloop.counter|divisibleby:2|yesno:"even,odd" }} description-row">
<td class="description" colspan={{table.columns|length|add:"1"}}>{{row.record.description}}</td>
</tr>
{% endif %}
{% endblock table.tbody.row %}
{% block pagination.cardinality %}