Projet

Général

Profil

0001-add-additional-read-only-information-in-main-table-2.patch

Paul Marillonnet, 13 mars 2018 14:42

Télécharger (3,12 ko)

Voir les différences:

Subject: [PATCH] add additional read-only information in main table (#21486)

 fargo/fargo/tables.py            |  3 +--
 fargo/templates/fargo/table.html | 13 +++++++++++--
 2 files changed, 12 insertions(+), 4 deletions(-)
fargo/fargo/tables.py
7 7

  
8 8
class DocumentTable(tables.Table):
9 9
    '''Display the list of documents of the user'''
10
    filename = tables.Column(verbose_name=_('filename').title())
11 10
    size = tables.TemplateColumn(template_code='{{ record.document.content.size|filesizeformat }}',
12 11
                                 orderable=False,
13 12
                                 verbose_name=_('size').title())
......
15 14

  
16 15
    class Meta:
17 16
        model = models.Document
18
        fields = ('filename', 'size', 'created')
17
        fields = ('size', 'created')
19 18
        empty_text = _('You currently have no documents')
fargo/templates/fargo/table.html
5 5
{% block table.thead %}
6 6
  <thead>
7 7
    <tr>
8
      <th class="orderable sortable title"><a href="?sort=title">Title</a></th>
8 9
      {% for column in table.columns %}
9 10
        {% if column.orderable %}
10 11
          <th {{ column.attrs.th.as_html }}>
......
24 25
  <tr class="{{ forloop.counter|divisibleby:2|yesno:"even,odd" }} {{row.record.css_classes}}"
25 26
      data-url="{{row.record.get_download_url}}"
26 27
      > {# avoid cycle for Django 1.2-1.6 compatibility #}
28
    <td>
29
    {% if row.record.title %}{{ row.record.title }}{% else %}{{ row.record.filename }}{% endif %}
30
    </td>
27 31
    {% for column, cell in row.items %}
28 32
      <td {{ column.attrs.td.as_html }}>{% if column.localize == None %}{{ cell }}{% else %}{% if column.localize %}{{ cell|localize }}{% else %}{{ cell|unlocalize }}{% endif %}{% endif %}</td>
29 33
    {% endfor %}
30 34
      {% with url=row.record.get_thumbnail_url %}
31
        <td class="thumbnail">{% if url %}<img src="{{ url }}"/>{% endif %}</td>
35
      <td class="thumbnail" rowspan={{ row.record.description|yesno:"2,1" }}>{% if url %}<img src="{{ url }}"/>{% endif %}</td>
32 36
      {% endwith %}
33
    <td class="action-column">
37
    <td class="action-column" rowspan={{ row.record.description|yesno:"2,1" }}>
34 38
      {% block action-column %}
35 39
      {% if include_edit_link %}
36 40
        <a class="icon-edit" rel="popup" href="{% url 'edit' pk=row.record.pk %}"></a>
......
44 48
      {% endblock %}
45 49
   </td>
46 50
  </tr>
51
  {% if row.record.description %}
52
  <tr class="{{ forloop.counter|divisibleby:2|yesno:"even,odd" }} description-row">
53
      <td class="description" colspan={{table.columns|length|add:"1"}}>{{row.record.description}}</td>
54
  </tr>
55
  {% endif %}
47 56
{% endblock table.tbody.row %}
48 57

  
49 58
{% block pagination.cardinality %}
50
-