diff options
Diffstat (limited to 'ishtar_common')
-rw-r--r-- | ishtar_common/views_item.py | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/ishtar_common/views_item.py b/ishtar_common/views_item.py index 032d3e2c2..65695f067 100644 --- a/ishtar_common/views_item.py +++ b/ishtar_common/views_item.py @@ -1843,27 +1843,31 @@ def get_item(model, func_name, default_name, extra_request_keys=None, lnk = '' res["link"] = lnk for idx, value in enumerate(data[1:]): - if value: - table_col = table_cols[idx] - if type(table_col) not in (list, tuple): - table_col = [table_col] - tab_cols = [] - # foreign key may be divided by "." or "__" - for tc in table_col: - if '.' in tc: - tab_cols += tc.split('.') - elif '__' in tc: - tab_cols += tc.split('__') - else: - tab_cols.append(tc) - k = "__".join(tab_cols) - if hasattr(model, 'COL_LINK') and k in model.COL_LINK: - value = link_ext_template.format(value, value) - if isinstance(value, datetime.date): - value = value.strftime('%Y-%m-%d') - if isinstance(value, datetime.datetime): - value = value.strftime('%Y-%m-%d %H:%M:%S') - res[k] = value + if not value: + continue + table_col = table_cols[idx] + if type(table_col) not in (list, tuple): + table_col = [table_col] + tab_cols = [] + # foreign key may be divided by "." or "__" + for tc in table_col: + if '.' in tc: + tab_cols += tc.split('.') + elif '__' in tc: + tab_cols += tc.split('__') + else: + tab_cols.append(tc) + k = "__".join(tab_cols) + if k.endswith("__image") or k.endswith("__thumbnail"): + if not value.startswith(settings.MEDIA_ROOT): + value = settings.MEDIA_URL + value + if hasattr(model, 'COL_LINK') and k in model.COL_LINK: + value = link_ext_template.format(value, value) + if isinstance(value, datetime.date): + value = value.strftime('%Y-%m-%d') + if isinstance(value, datetime.datetime): + value = value.strftime('%Y-%m-%d %H:%M:%S') + res[k] = value if full == 'shortcut': if 'cached_label' in res: res['value'] = res.pop('cached_label') |