getting default display_order working correctly

This commit is contained in:
Dan 2022-02-08 14:10:56 -05:00
parent 25ecc1593a
commit f1a75ca6bf
2 changed files with 8 additions and 1 deletions

View File

@ -45,6 +45,13 @@ class FileSystemService(object):
category_path = FileSystemService.category_path(spec.category_id)
return os.path.join(category_path, spec.display_name)
def next_display_order(self, spec):
path = self.category_path(spec.category_id)
if os.path.exists(path):
return len(next(os.walk(path))[1])
else:
return 0
@staticmethod
def write_file_data_to_system(file_path, file_data):
os.makedirs(os.path.dirname(file_path), exist_ok=True)

View File

@ -29,7 +29,7 @@ class WorkflowSpecService(FileSystemService):
self.scan_file_system()
def add_spec(self, spec: WorkflowSpecInfo):
display_order = len(self.categories[spec.category_id].len)
display_order = self.next_display_order(spec)
spec.display_order = display_order
self.update_spec(spec)