move holes from sections to spaces
This commit is contained in:
parent
129be97a59
commit
98501dbf3a
9 changed files with 99 additions and 21 deletions
|
@ -24,11 +24,11 @@ class EditorViewSet(ViewSet):
|
|||
if space is not None:
|
||||
raise ValidationError('Only section or space can be specified.')
|
||||
section = get_object_or_404(Section, pk=section)
|
||||
holes = section.holes.all()
|
||||
holes_geom = cascaded_union([hole.geometry for hole in holes])
|
||||
buildings = section.buildings.all()
|
||||
buildings_geom = cascaded_union([building.geometry for building in buildings])
|
||||
spaces = {space.id: space for space in section.spaces.all().prefetch_related('groups')}
|
||||
spaces = {space.id: space for space in section.spaces.all().prefetch_related('groups', 'holes')}
|
||||
holes = sum((list(space.holes.all()) for space in spaces.values()), [])
|
||||
holes_geom = cascaded_union([hole.geometry for hole in holes])
|
||||
for space in spaces.values():
|
||||
if space.outside:
|
||||
space.geometry = space.geometry.difference(buildings_geom)
|
||||
|
@ -79,6 +79,7 @@ class EditorViewSet(ViewSet):
|
|||
spaces,
|
||||
[space],
|
||||
space.areas.all().prefetch_related('groups'),
|
||||
space.holes.all(),
|
||||
space.stairs.all(),
|
||||
space.obstacles.all(),
|
||||
space.lineobstacles.all(),
|
||||
|
|
|
@ -39,7 +39,7 @@ urlpatterns.extend(add_editor_urls('Source'))
|
|||
urlpatterns.extend(add_editor_urls('Building', 'Section'))
|
||||
urlpatterns.extend(add_editor_urls('Space', 'Section', explicit_edit=True))
|
||||
urlpatterns.extend(add_editor_urls('Door', 'Section'))
|
||||
urlpatterns.extend(add_editor_urls('Hole', 'Section'))
|
||||
urlpatterns.extend(add_editor_urls('Hole', 'Space'))
|
||||
urlpatterns.extend(add_editor_urls('Area', 'Space'))
|
||||
urlpatterns.extend(add_editor_urls('Stair', 'Space'))
|
||||
urlpatterns.extend(add_editor_urls('Obstacle', 'Space'))
|
||||
|
|
|
@ -58,7 +58,7 @@ def section_detail(request, pk):
|
|||
'section_as_pk': True,
|
||||
|
||||
'child_models': [child_model(model_name, kwargs={'section': pk}, parent=section)
|
||||
for model_name in ('Building', 'Space', 'Door', 'Hole')],
|
||||
for model_name in ('Building', 'Space', 'Door')],
|
||||
'geometry_url': '/api/editor/geometries/?section='+pk,
|
||||
})
|
||||
|
||||
|
@ -72,7 +72,7 @@ def space_detail(request, section, pk):
|
|||
'space': space,
|
||||
|
||||
'child_models': [child_model(model_name, kwargs={'space': pk}, parent=space)
|
||||
for model_name in ('Area', 'Stair', 'Obstacle', 'LineObstacle', 'Point')],
|
||||
for model_name in ('Hole', 'Area', 'Stair', 'Obstacle', 'LineObstacle', 'Point')],
|
||||
'geometry_url': '/api/editor/geometries/?space='+pk,
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue