replace request with permissions in CustomLocation so it can be serialized
This commit is contained in:
parent
eae73071c1
commit
48e1ecda36
2 changed files with 5 additions and 5 deletions
|
@ -224,7 +224,8 @@ def get_custom_location_for_request(slug: str, request):
|
||||||
level = levels_by_short_label_for_request(request).get(match.group('level'))
|
level = levels_by_short_label_for_request(request).get(match.group('level'))
|
||||||
if not isinstance(level, Level):
|
if not isinstance(level, Level):
|
||||||
return None
|
return None
|
||||||
return CustomLocation(request, level, float(match.group('x')), float(match.group('y')))
|
return CustomLocation(level, float(match.group('x')), float(match.group('y')),
|
||||||
|
AccessPermission.get_for_request(request))
|
||||||
|
|
||||||
|
|
||||||
class CustomLocation:
|
class CustomLocation:
|
||||||
|
@ -232,11 +233,11 @@ class CustomLocation:
|
||||||
can_describe = True
|
can_describe = True
|
||||||
access_restriction_id = None
|
access_restriction_id = None
|
||||||
|
|
||||||
def __init__(self, request, level, x, y):
|
def __init__(self, level, x, y, permissions):
|
||||||
x = round(x, 2)
|
x = round(x, 2)
|
||||||
y = round(y, 2)
|
y = round(y, 2)
|
||||||
self.pk = 'c:%s:%s:%s' % (level.short_label, x, y)
|
self.pk = 'c:%s:%s:%s' % (level.short_label, x, y)
|
||||||
self.request = request
|
self.permissions = permissions
|
||||||
self.level = level
|
self.level = level
|
||||||
self.x = x
|
self.x = x
|
||||||
self.y = y
|
self.y = y
|
||||||
|
|
|
@ -16,7 +16,6 @@ from shapely.geometry import LineString, Point
|
||||||
from shapely.ops import unary_union
|
from shapely.ops import unary_union
|
||||||
|
|
||||||
from c3nav.mapdata.models import AltitudeArea, Area, GraphEdge, Level, LocationGroup, MapUpdate, Space, WayType
|
from c3nav.mapdata.models import AltitudeArea, Area, GraphEdge, Level, LocationGroup, MapUpdate, Space, WayType
|
||||||
from c3nav.mapdata.models.access import AccessPermission
|
|
||||||
from c3nav.mapdata.models.geometry.space import POI
|
from c3nav.mapdata.models.geometry.space import POI
|
||||||
from c3nav.mapdata.utils.geometry import assert_multipolygon, get_rings, good_representative_point
|
from c3nav.mapdata.utils.geometry import assert_multipolygon, get_rings, good_representative_point
|
||||||
from c3nav.mapdata.utils.locations import CustomLocation
|
from c3nav.mapdata.utils.locations import CustomLocation
|
||||||
|
@ -295,7 +294,7 @@ class Router:
|
||||||
# todo: location.request
|
# todo: location.request
|
||||||
return CustomLocationDescription(
|
return CustomLocationDescription(
|
||||||
space=self.space_for_point(location.level.pk, location,
|
space=self.space_for_point(location.level.pk, location,
|
||||||
self.get_restrictions(AccessPermission.get_for_request(location.request)))
|
self.get_restrictions(location.permissions))
|
||||||
)
|
)
|
||||||
|
|
||||||
def shortest_path(self, restrictions):
|
def shortest_path(self, restrictions):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue