sort space geometries in editor
This commit is contained in:
parent
9618d7304f
commit
1a4ef5caa0
1 changed files with 8 additions and 1 deletions
|
@ -67,6 +67,13 @@ class EditorViewSet(EditorViewSetMixin, ViewSet):
|
|||
lookup_field = 'path'
|
||||
lookup_value_regex = r'.+'
|
||||
|
||||
@staticmethod
|
||||
def space_sorting_func(space):
|
||||
groups = tuple(space.groups.all())
|
||||
if not groups:
|
||||
return (0, 0, 0)
|
||||
return (1, groups[0].category.priority, groups[0].hierarchy, groups[0].priority)
|
||||
|
||||
@staticmethod
|
||||
def _get_level_geometries(level):
|
||||
buildings = level.buildings.all()
|
||||
|
@ -101,7 +108,7 @@ class EditorViewSet(EditorViewSetMixin, ViewSet):
|
|||
for door in level.doors.all():
|
||||
results.append(door)
|
||||
|
||||
results.extend(spaces.values())
|
||||
results.extend(sorted(spaces.values(), key=EditorViewSet.space_sorting_func))
|
||||
return results
|
||||
|
||||
@staticmethod
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue