summaryrefslogtreecommitdiff
path: root/ishtar_common/views_item.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2019-05-28 12:33:16 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2019-06-17 13:21:28 +0200
commit7c217d2580ff9decf7563f675c8d822c70d9f397 (patch)
tree41dd98718789fc6e1989729c85574925f972c4b7 /ishtar_common/views_item.py
parent779db09e8589e2ce58c0d1b7c34877f4ff0f9988 (diff)
downloadIshtar-7c217d2580ff9decf7563f675c8d822c70d9f397.tar.bz2
Ishtar-7c217d2580ff9decf7563f675c8d822c70d9f397.zip
Data: provide MEDIA URL path for images
Diffstat (limited to 'ishtar_common/views_item.py')
-rw-r--r--ishtar_common/views_item.py46
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')