Skip to content

Instantly share code, notes, and snippets.

@raprasad
Last active May 1, 2017 15:04
Show Gist options
  • Select an option

  • Save raprasad/312623429945e08f980c90e14dc8dcb3 to your computer and use it in GitHub Desktop.

Select an option

Save raprasad/312623429945e08f980c90e14dc8dcb3 to your computer and use it in GitHub Desktop.
worldmap work - layer_link missing full url for lat/lng

notes, tracing issue

import json
from geonode.contrib.datatables.views_dataverse import *

# Lat/Lng layer
lat_lng_pk = 31
l = Layer.objects.get(pk=lat_lng_pk)
d = get_layer_and_join_metadata(l)
print json.dumps(d, indent=4)
d['layer_link']  #  "layer_link": "/data/geonode:starbucks_u_x6", 


# Shapefile
shp_pk = 25
l = Layer.objects.get(pk=shp_pk)
d = get_layer_and_join_metadata(l)
print json.dumps(d, indent=4)
d['layer_link']  #  "layer_link": "http://localhost:8000/data/geonode:transport_f8t",

where is layer_link created for LatLngTableMappingRecord?

ll = LatLngTableMappingRecord.objects.get(pk=4)
ll.as_json()
'''{'datatable': u'starbucks_u_x6',
 'datatable_id': 25,
 'lat_attribute': {'attribute': u'latitude', 'type': u'float'},
 'lat_lng_record_id': 4,
 'layer_id': 31,
 'layer_link': u'/data/geonode:starbucks_u_x6',
 'layer_name': u'starbucks_u_x6',
 'layer_typename': u'geonode:starbucks_u_x6',
 'lng_attribute': {'attribute': u'longitude', 'type': u'float'},
 'mapped_record_count': 6444,
 'unmapped_record_count': 0}
'''
  • LatLngTableMappingRecord -> as_json()
data_dict['layer_link'] = self.layer.get_absolute_url()
  • Fix is to remove line above b/c it's overwriting the existing layer_link in the dict that already as the server name--and is used by the TableJoin records
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment