Commit 17c4ede1 authored by Dominik Rosiek's avatar Dominik Rosiek

API apteki custom

parent 3584918e
......@@ -15,14 +15,20 @@ class API(BaseAPI):
def object(self):
data = self.GET(parameters=self.request.GET.dict())
results = []
for obj in data['results']:
result = {}
for property in obj['properties']:
if property['key'] == 'APTEKI':
result['name'] = property['value']
elif property['key'] == 'OADR_GPS_S':
result['latitude'] = property['value']
elif property['key'] == 'OADR_GPS_D':
result['longitude'] = property['value']
results.append(result)
try:
for obj in data['results']:
results.append(self.unpack(obj))
except TypeError as e:
results.append(self.unpack(data['results']))
return json.dumps(results)
def unpack(self, obj):
result = {}
for property in obj['properties']:
if property['key'] == 'APTEKI':
result['name'] = property['value']
elif property['key'] == 'OADR_GPS_S':
result['latitude'] = property['value']
elif property['key'] == 'OADR_GPS_D':
result['longitude'] = property['value']
return result
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment