Skip to content

Commit

Permalink
single location strict support
Browse files Browse the repository at this point in the history
  • Loading branch information
the-infinity committed Jan 25, 2025
1 parent b7624e3 commit dffa749
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
7 changes: 5 additions & 2 deletions webapp/models/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,15 @@ def to_dict(self, *args, strict: bool = False, ignore: List[str] | None = None,
result['opening_times'] = {'twentyfourseven': self.twentyfourseven}

result['coordinates'] = {
'lat': self.lat, # TODO: remove this after migration period
'lon': self.lon, # TODO: remove this after migration period
'latitude': self.lat,
'longitude': self.lon,
}

# TODO: remove this after migration period
if not strict:
result['coordinates']['lat'] = self.lat
result['coordinates']['lon'] = self.lon

return result


Expand Down
14 changes: 13 additions & 1 deletion webapp/public_api/location_api/location_rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,13 @@ class LocationItemMethodView(LocationBaseMethodView):
description='Get single Location',
path=[Parameter('location_id', schema=IntegerField(minimum=1))],
response=[Response(ResponseData(SchemaReference('Location'), ExampleReference('Location')))],
query=[
Parameter(
'strict',
schema=BooleanField(),
description='If set to true, all additional fields will be omitted for full OCPI compatibility.',
),
],
components=[
Schema('AdditionalGeoLocation', additional_geo_location_schema, additional_geo_location_example),
Schema('BusinessDetails', business_details_schema, business_details_example),
Expand All @@ -202,4 +209,9 @@ class LocationItemMethodView(LocationBaseMethodView):
)
@cross_origin()
def get(self, location_id: int):
return jsonify(self.location_handler.get_location(location_id))
location = self.location_handler.get_location(
location_id,
strict=self.request_helper.get_query_args().get('strict') == 'true',
)

return jsonify(location)

0 comments on commit dffa749

Please # to comment.