added sorting to process model w/ burnettk
This commit is contained in:
parent
9777750adf
commit
34248324c0
|
@ -18,4 +18,4 @@ fi
|
|||
|
||||
export FLASK_SESSION_SECRET_KEY=super_secret_key
|
||||
|
||||
FLASK_APP=src/spiffworkflow_backend poetry run flask run -p 5010
|
||||
FLASK_APP=src/spiffworkflow_backend poetry run flask run -p 7000
|
||||
|
|
|
@ -3,46 +3,34 @@ import marshmallow
|
|||
from marshmallow import post_load
|
||||
from marshmallow import Schema
|
||||
|
||||
from dataclasses import dataclass
|
||||
from dataclasses import field
|
||||
from typing import Optional
|
||||
|
||||
|
||||
@dataclass(order=True)
|
||||
class ProcessModelInfo:
|
||||
"""ProcessModelInfo."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
id,
|
||||
display_name,
|
||||
description,
|
||||
is_master_spec=False,
|
||||
standalone=False,
|
||||
library=False,
|
||||
primary_file_name="",
|
||||
primary_process_id="",
|
||||
libraries=None,
|
||||
process_group_id="",
|
||||
display_order=0,
|
||||
is_review=False,
|
||||
files=None,
|
||||
):
|
||||
"""__init__."""
|
||||
self.id = id # Sting unique id
|
||||
self.display_name = display_name
|
||||
self.description = description
|
||||
self.display_order = display_order
|
||||
self.is_master_spec = is_master_spec
|
||||
self.standalone = standalone
|
||||
self.library = library
|
||||
self.primary_file_name = primary_file_name
|
||||
self.primary_process_id = primary_process_id
|
||||
self.is_review = is_review
|
||||
self.process_group_id = process_group_id
|
||||
sort_index: str = field(init=False)
|
||||
|
||||
if libraries is None:
|
||||
libraries = []
|
||||
self.libraries = libraries
|
||||
id: str
|
||||
display_name: str
|
||||
description: str
|
||||
is_master_spec: Optional[bool] = False
|
||||
standalone: Optional[bool] = False
|
||||
library: Optional[bool] = False
|
||||
primary_file_name: Optional[str] = ""
|
||||
primary_process_id: Optional[str] = ""
|
||||
libraries: Optional[list[str]] = field(default_factory=list)
|
||||
process_group_id: Optional[str] = ""
|
||||
display_order: Optional[int] = 0
|
||||
is_review: Optional[bool] = False
|
||||
files: Optional[list[str]] = field(default_factory=list)
|
||||
|
||||
if files is None:
|
||||
files = []
|
||||
self.files = files
|
||||
def __post_init__(self):
|
||||
"""__post_init__."""
|
||||
self.sort_index = f"{self.process_group_id}:{self.id}"
|
||||
|
||||
def __eq__(self, other):
|
||||
"""__eq__."""
|
||||
|
|
|
@ -138,7 +138,7 @@ def process_model_show(process_group_id, process_model_id):
|
|||
|
||||
def process_model_list(process_group_id, page=1, per_page=100):
|
||||
"""Process model list!"""
|
||||
process_models = ProcessModelService().get_process_models(process_group_id)
|
||||
process_models = sorted(ProcessModelService().get_process_models(process_group_id))
|
||||
batch = ProcessModelService().get_batch(
|
||||
process_models, page=page, per_page=per_page
|
||||
)
|
||||
|
|
|
@ -49,7 +49,6 @@ class Script:
|
|||
We may be able to remove the task for each of these calls if we are not using it other than potentially
|
||||
updating the task data.
|
||||
"""
|
||||
|
||||
def make_closure(subclass, task, workflow_id):
|
||||
"""Yes - this is black magic.
|
||||
|
||||
|
@ -85,7 +84,6 @@ class Script:
|
|||
We may be able to remove the task for each of these calls if we are not using it other than potentially
|
||||
updating the task data.
|
||||
"""
|
||||
|
||||
def make_closure_validate(subclass, task, workflow_id):
|
||||
"""Make_closure_validate."""
|
||||
instance = subclass()
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
"""Process Model."""
|
||||
from spiffworkflow_backend.models.process_model import ProcessModelInfo
|
||||
|
||||
|
||||
def test_initializes_files_as_empty_array() -> None:
|
||||
"""Test_initializes_files_as_empty_array."""
|
||||
process_model_one = create_test_process_model(id="model_one", display_name="Model One")
|
||||
assert process_model_one.files == []
|
||||
assert process_model_one.libraries == []
|
||||
|
||||
|
||||
def create_test_process_model(id: str, display_name: str):
|
||||
"""Create_test_process_model."""
|
||||
return ProcessModelInfo(
|
||||
id=id,
|
||||
display_name=display_name,
|
||||
description=display_name,
|
||||
)
|
Loading…
Reference in New Issue