From 9590344be699e784782bbf59c6055e339f0e0f3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laura=20Kl=C3=BCnder?= Date: Thu, 19 Dec 2024 11:03:11 +0100 Subject: [PATCH] fixed customlocation pk to use level_index --- src/c3nav/mapdata/schemas/model_base.py | 2 +- src/c3nav/mapdata/utils/locations.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/c3nav/mapdata/schemas/model_base.py b/src/c3nav/mapdata/schemas/model_base.py index c26cac2a..4039cb44 100644 --- a/src/c3nav/mapdata/schemas/model_base.py +++ b/src/c3nav/mapdata/schemas/model_base.py @@ -340,7 +340,7 @@ class SimpleGeometryLocationsSchema(BaseSchema): CustomLocationID = Annotated[NonEmptyStr, APIField( title="custom location ID", - pattern=r"c:[a-z0-9-_]+:(-?\d+(\.\d+)?):(-?\d+(\.\d+)?)$", + pattern=r"c:[a-z0-9-_.]+:(-?\d+(\.\d+)?):(-?\d+(\.\d+)?)$", example="c:0:-7.23:12.34", description="level short_name and x/y coordinates form the ID of a custom location" )] diff --git a/src/c3nav/mapdata/utils/locations.py b/src/c3nav/mapdata/utils/locations.py index bea34a56..ed8c013d 100644 --- a/src/c3nav/mapdata/utils/locations.py +++ b/src/c3nav/mapdata/utils/locations.py @@ -291,7 +291,7 @@ class CustomLocation: def __post_init__(self): x = round(self.x, 2) y = round(self.y, 2) - self.pk = 'c:%s:%s:%s' % (self.level.short_label, x, y) + self.pk = 'c:%s:%s:%s' % (self.level.level_index, x, y) @property def serialized_geometry(self):