fixed customlocation pk to use level_index

This commit is contained in:
Laura Klünder 2024-12-19 11:03:11 +01:00
parent fe98f5e618
commit 9590344be6
2 changed files with 2 additions and 2 deletions

View file

@ -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"
)]

View file

@ -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):