diff options
Diffstat (limited to 'ishtar_common')
| -rw-r--r-- | ishtar_common/views_item.py | 6 | ||||
| -rw-r--r-- | ishtar_common/widgets.py | 17 | 
2 files changed, 20 insertions, 3 deletions
| diff --git a/ishtar_common/views_item.py b/ishtar_common/views_item.py index a6bf7e190..3fa49bd07 100644 --- a/ishtar_common/views_item.py +++ b/ishtar_common/views_item.py @@ -1087,7 +1087,11 @@ def get_item(model, func_name, default_name, extra_request_keys=[],                  if hasattr(model, 'EXTRA_FULL_FIELDS'):                      table_cols += model.EXTRA_FULL_FIELDS              else: -                table_cols = model.TABLE_COLS +                tb_key = (getattr(model, 'SLUG', None), 'TABLE_COLS') +                if tb_key in settings.TABLE_COLS: +                    table_cols = settings.TABLE_COLS[tb_key] +                else: +                    table_cols = model.TABLE_COLS          query_table_cols = []          for cols in table_cols:              if type(cols) not in (list, tuple): diff --git a/ishtar_common/widgets.py b/ishtar_common/widgets.py index 405b5d69e..fc8926364 100644 --- a/ishtar_common/widgets.py +++ b/ishtar_common/widgets.py @@ -945,9 +945,19 @@ class DataTable(Select2Media, forms.RadioSelect):      def get_cols(self, python=False):          jq_col_names, extra_cols = [], []          col_labels = {} +        slug = getattr(self.associated_model, 'SLUG', None)          if hasattr(self.associated_model, 'COL_LABELS'):              col_labels = self.associated_model.COL_LABELS -        for col_names in getattr(self.associated_model, self.table_cols): +        if slug in settings.TABLE_COLS: +            col_labels.update(settings.TABLE_COLS[slug]) + +        tb_key = (slug, self.table_cols) +        if tb_key in settings.TABLE_COLS: +            table_cols = settings.TABLE_COLS[tb_key] +        else: +            table_cols = getattr(self.associated_model, self.table_cols) + +        for col_names in table_cols:              field_verbose_names = []              field_verbose_name, field_name = "", ""              if type(col_names) not in (list, tuple): @@ -978,7 +988,10 @@ class DataTable(Select2Media, forms.RadioSelect):              if not field_name:                  field_name = "__".join(col_names)              if field_name in col_labels: -                jq_col_names.append(unicode(col_labels[field_name])) +                lbl = col_labels[field_name] +                if callable(lbl): +                    lbl = lbl() +                jq_col_names.append(unicode(lbl))              elif col_names and col_names[0] in col_labels:                  jq_col_names.append(unicode(col_labels[col_names[0]]))              else: | 
