shortwaytypeschema needs no explicit serialization

This commit is contained in:
Laura Klünder 2024-12-09 15:43:07 +01:00
parent 3fc1bfa5ed
commit 26ea7c7152

View file

@ -1,13 +1,10 @@
# flake8: noqa # flake8: noqa
import copy
from collections import OrderedDict, deque from collections import OrderedDict, deque
import numpy as np import numpy as np
from django.utils.functional import cached_property from django.utils.functional import cached_property
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from c3nav.routing.api.routing import ShortWayTypeSchema
def describe_location(location, locations): def describe_location(location, locations):
if location.can_describe: if location.can_describe:
@ -242,8 +239,7 @@ class RouteItem:
result = OrderedDict(( result = OrderedDict((
('id', self.node.pk), ('id', self.node.pk),
('coordinates', (self.node.x, self.node.y, self.node.altitude)), ('coordinates', (self.node.x, self.node.y, self.node.altitude)),
('waytype', (ShortWayTypeSchema.model_validate(self.route.router.waytypes[self.edge.waytype]).model_dump() ('waytype', (self.route.router.waytypes[self.edge.waytype] if self.edge and self.edge.waytype else None)),
if self.edge and self.edge.waytype else None)),
)) ))
if self.waytype: if self.waytype:
result['waytype'] = self.waytype.serialize(detailed=False) result['waytype'] = self.waytype.serialize(detailed=False)