mirror of
https://github.com/status-im/spiff-arena.git
synced 2025-02-22 14:38:11 +00:00
0e61be85 Merge pull request #289 from sartography/improvement/execution-and-serialization-cleanup 527684da fix some typos in the class & method docs 0dff44a4 Merge branch 'main' into improvement/execution-and-serialization-cleanup 64737498 Allow for other PythonScriptEngine environments besides task data (#288) dd63e916 remove some unused tests & diagrams 24aae519 clean up various small stuff 3b2dc35d use context when opening files for parsing 69eec3eb update class/method docs 24528dfb move all spec conversion classes to top level 5af33b11 remove some unused methods related to old serializer 931b90fb reorganize serializer 4e81ed29 consolidate pointless serializer classes d62acf02 change task_spec._update_hook to return a boolean indicating whether the task is ready git-subtree-dir: SpiffWorkflow git-subtree-split: 0e61be85c47474a33037e6f398e64c96e02f13ad
35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
from ...bpmn.serializer.helpers.spec import TaskSpecConverter
|
|
|
|
from ..specs.UserTask import UserTask, Form
|
|
|
|
class UserTaskConverter(TaskSpecConverter):
|
|
|
|
def __init__(self, registry):
|
|
super().__init__(UserTask, registry)
|
|
|
|
def to_dict(self, spec):
|
|
dct = self.get_default_attributes(spec)
|
|
dct.update(self.get_bpmn_attributes(spec))
|
|
dct['form'] = self.form_to_dict(spec.form)
|
|
return dct
|
|
|
|
def from_dict(self, dct):
|
|
dct['form'] = Form(init=dct['form'])
|
|
return self.task_spec_from_dict(dct)
|
|
|
|
def form_to_dict(self, form):
|
|
dct = {'key': form.key, 'fields': []}
|
|
for field in form.fields:
|
|
new = {
|
|
'id': field.id,
|
|
'default_value': field.default_value,
|
|
'label': field.label,
|
|
'type': field.type,
|
|
'properties': [ prop.__dict__ for prop in field.properties ],
|
|
'validation': [ val.__dict__ for val in field.validation ],
|
|
}
|
|
if field.type == "enum":
|
|
new['options'] = [ opt.__dict__ for opt in field.options ]
|
|
dct['fields'].append(new)
|
|
return dct
|