consider access restrictions when describing a custom location
This commit is contained in:
parent
dba04b4179
commit
eae73071c1
2 changed files with 6 additions and 3 deletions
|
@ -224,7 +224,7 @@ def get_custom_location_for_request(slug: str, request):
|
|||
level = levels_by_short_label_for_request(request).get(match.group('level'))
|
||||
if not isinstance(level, Level):
|
||||
return None
|
||||
return CustomLocation(level, float(match.group('x')), float(match.group('y')))
|
||||
return CustomLocation(request, level, float(match.group('x')), float(match.group('y')))
|
||||
|
||||
|
||||
class CustomLocation:
|
||||
|
@ -232,10 +232,11 @@ class CustomLocation:
|
|||
can_describe = True
|
||||
access_restriction_id = None
|
||||
|
||||
def __init__(self, level, x, y):
|
||||
def __init__(self, request, level, x, y):
|
||||
x = round(x, 2)
|
||||
y = round(y, 2)
|
||||
self.pk = 'c:%s:%s:%s' % (level.short_label, x, y)
|
||||
self.request = request
|
||||
self.level = level
|
||||
self.x = x
|
||||
self.y = y
|
||||
|
|
|
@ -16,6 +16,7 @@ from shapely.geometry import LineString, Point
|
|||
from shapely.ops import unary_union
|
||||
|
||||
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.utils.geometry import assert_multipolygon, get_rings, good_representative_point
|
||||
from c3nav.mapdata.utils.locations import CustomLocation
|
||||
|
@ -293,7 +294,8 @@ class Router:
|
|||
def describe_custom_location(self, location):
|
||||
# todo: location.request
|
||||
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)))
|
||||
)
|
||||
|
||||
def shortest_path(self, restrictions):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue