Project

General

Profile

0001-WIP-configure-displayed-columns-22470.patch

Paul Marillonnet, 14 Mar 2018 05:42 PM

Download (1.74 KB)

View differences:

Subject: [PATCH] WIP configure displayed columns (#22470)

 fargo/fargo/tables.py | 10 +++++++++-
 fargo/settings.py     |  2 ++
 2 files changed, 11 insertions(+), 1 deletion(-)
fargo/fargo/tables.py
1
from django.conf import settings
1 2
from django.utils.translation import ugettext_lazy as _
2 3

  
3 4
import django_tables2 as tables
......
12 13
                                 verbose_name=_('size').title())
13 14
    created = tables.DateTimeColumn(verbose_name=_('creation date').title())
14 15

  
16
    def __init__(self, data, *args, **kwargs):
17
        super(DocumentTable, self).__init__(data, *args, **kwargs)
18

  
19
        for column in settings.FARGO_TABLE_COLUMNS:
20
            if not hasattr(self, column) and hasattr(self.Meta.model, column):
21
                setattr(self, column, tables.Column(verbose_name=column.title()))
22

  
15 23
    class Meta:
16 24
        model = models.Document
17
        fields = ('size', 'created')
25
        fields = settings.FARGO_TABLE_COLUMNS
18 26
        empty_text = _('You currently have no documents')
fargo/settings.py
155 155

  
156 156
FARGO_VALIDATION_LIFETIME = 3600 * 24 * 31 * 6  # nearly 6 months
157 157

  
158
FARGO_TABLE_COLUMNS = ('size', 'creation_date', 'filename')
159

  
158 160
FARGO_DOCUMENT_TYPES = [
159 161
    {
160 162
        'name': 'avis-d-imposition',
161
-