fix discojuice geo strange format

geo can be a list of dict, or a dict.
This commit is contained in:
Thomas NOËL 2014-08-07 15:25:31 +00:00
parent 19495535ab
commit baba3c00e0
1 changed files with 5 additions and 2 deletions

View File

@ -66,8 +66,11 @@ n = 0
idps = [] idps = []
for provider in LibertyProvider.objects.all(): for provider in LibertyProvider.objects.all():
n += 1 n += 1
geo = geo_idps.get(provider.entity_id, {}).get('geo', geo = geo_idps.get(provider.entity_id, {}).get('geo')
{'lat': 47.0+2.0*math.sin(n), 'lon': 2.5+3.0*math.cos(n)}) if isinstance(geo, list) and geo:
geo = geo[0]
if not geo:
geo = {'lat': 47.0+2.0*math.sin(n), 'lon': 2.5+3.0*math.cos(n)}
idps.append({ idps.append({
'entityid': provider.entity_id, 'entityid': provider.entity_id,
'name': get_ui_displayname(provider), 'name': get_ui_displayname(provider),