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

API apteki custom

parent 3584918e
...@@ -15,14 +15,20 @@ class API(BaseAPI): ...@@ -15,14 +15,20 @@ class API(BaseAPI):
def object(self): def object(self):
data = self.GET(parameters=self.request.GET.dict()) data = self.GET(parameters=self.request.GET.dict())
results = [] results = []
for obj in data['results']: try:
result = {} for obj in data['results']:
for property in obj['properties']: results.append(self.unpack(obj))
if property['key'] == 'APTEKI': except TypeError as e:
result['name'] = property['value'] results.append(self.unpack(data['results']))
elif property['key'] == 'OADR_GPS_S':
result['latitude'] = property['value']
elif property['key'] == 'OADR_GPS_D':
result['longitude'] = property['value']
results.append(result)
return json.dumps(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