consider access restrictions when describing a custom location

This commit is contained in:
Laura Klünder 2017-12-11 00:53:21 +01:00
parent dba04b4179
commit eae73071c1
2 changed files with 6 additions and 3 deletions

View file

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