diff options
Diffstat (limited to 'ishtar_common/views_item.py')
| -rw-r--r-- | ishtar_common/views_item.py | 31 | 
1 files changed, 12 insertions, 19 deletions
| diff --git a/ishtar_common/views_item.py b/ishtar_common/views_item.py index b8307c457..e720a0437 100644 --- a/ishtar_common/views_item.py +++ b/ishtar_common/views_item.py @@ -1363,8 +1363,10 @@ def get_item(model, func_name, default_name, extra_request_keys=None,                  else:                      table_cols = model.TABLE_COLS          table_cols = list(table_cols) +        if data_type == "json-map": +            table_cols = []  # only pk for map          query_table_cols = [] -        for cols in table_cols: +        for idx, cols in enumerate(table_cols):              if type(cols) not in (list, tuple):                  cols = [cols]              for col in cols: @@ -1378,31 +1380,20 @@ def get_item(model, func_name, default_name, extra_request_keys=None,                  if col in model.CONTEXTUAL_TABLE_COLS[contxt]:                      query_table_cols[idx] = \                          model.CONTEXTUAL_TABLE_COLS[contxt][col] -        if full == 'shortcut': -            if model.SLUG == "warehouse": -                query_table_cols = ['name'] -                table_cols = ['name'] -            else: -                query_table_cols = ['cached_label'] -                table_cols = ['cached_label'] -        if data_type == 'json-image': + +        if data_type in ('json-image', 'json-map') or full == 'shortcut':              if model.SLUG == "warehouse":                  query_table_cols.append('name')                  table_cols.append('name')              else:                  query_table_cols.append('cached_label')                  table_cols.append('cached_label') -            query_table_cols.append('main_image__image') +        if data_type == 'json-image':              query_table_cols.append('main_image__thumbnail') -            table_cols.append('main_image__image')              table_cols.append('main_image__thumbnail') +            query_table_cols.append('main_image__image') +            table_cols.append('main_image__image')          elif data_type == 'json-map': -            if model.SLUG == "warehouse": -                query_table_cols.append('name') -                table_cols.append('name') -            else: -                query_table_cols.append('cached_label') -                table_cols.append('cached_label')              if model.SLUG == "find":                  query_table_cols.append('base_finds__point_2d')                  table_cols.append('base_finds__point_2d') @@ -1590,7 +1581,9 @@ def get_item(model, func_name, default_name, extra_request_keys=None,                          '**WARN "show-' + default_name + '" args ('                          + unicode(data[0]) + ") url not available")                      lnk = '' -                res = {'id': data[0], 'link': lnk} +                res = {'id': data[0]} +                if data_type != 'json-map': +                    res['link'] = lnk                  for idx, value in enumerate(data[1:]):                      if value:                          table_col = table_cols[idx] @@ -1627,7 +1620,7 @@ def get_item(model, func_name, default_name, extra_request_keys=None,                      "page": page_nb,                      "total": (items_nb / row_nb + 1) if row_nb else items_nb,                  }) -            return HttpResponse(data, content_type='text/plain') +            return HttpResponse(data, content_type='application/json')          elif data_type == "csv":              response = HttpResponse(content_type='text/csv')              n = datetime.datetime.now() | 
