fixed file upload and do not allow submitting task data to a suspended process instance w/ burnettk
This commit is contained in:
parent
0d69029292
commit
3495b11f58
|
@ -34,36 +34,6 @@ class ProcessInstanceCannotBeDeletedError(Exception):
|
||||||
"""ProcessInstanceCannotBeDeletedError."""
|
"""ProcessInstanceCannotBeDeletedError."""
|
||||||
|
|
||||||
|
|
||||||
class NavigationItemSchema(Schema):
|
|
||||||
"""NavigationItemSchema."""
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
"""Meta."""
|
|
||||||
|
|
||||||
fields = [
|
|
||||||
"spec_id",
|
|
||||||
"name",
|
|
||||||
"spec_type",
|
|
||||||
"task_id",
|
|
||||||
"description",
|
|
||||||
"backtracks",
|
|
||||||
"indent",
|
|
||||||
"lane",
|
|
||||||
"state",
|
|
||||||
"children",
|
|
||||||
]
|
|
||||||
unknown = INCLUDE
|
|
||||||
|
|
||||||
state = marshmallow.fields.String(required=False, allow_none=True)
|
|
||||||
description = marshmallow.fields.String(required=False, allow_none=True)
|
|
||||||
backtracks = marshmallow.fields.String(required=False, allow_none=True)
|
|
||||||
lane = marshmallow.fields.String(required=False, allow_none=True)
|
|
||||||
task_id = marshmallow.fields.String(required=False, allow_none=True)
|
|
||||||
children = marshmallow.fields.List(
|
|
||||||
marshmallow.fields.Nested(lambda: NavigationItemSchema())
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class ProcessInstanceStatus(SpiffEnum):
|
class ProcessInstanceStatus(SpiffEnum):
|
||||||
"""ProcessInstanceStatus."""
|
"""ProcessInstanceStatus."""
|
||||||
|
|
||||||
|
@ -139,6 +109,10 @@ class ProcessInstanceModel(SpiffworkflowBaseDBModel):
|
||||||
"""Validate_status."""
|
"""Validate_status."""
|
||||||
return self.validate_enum_field(key, value, ProcessInstanceStatus)
|
return self.validate_enum_field(key, value, ProcessInstanceStatus)
|
||||||
|
|
||||||
|
def can_submit_task(self) -> bool:
|
||||||
|
"""Can_submit_task."""
|
||||||
|
return not self.has_terminal_status() and self.status != "suspended"
|
||||||
|
|
||||||
def has_terminal_status(self) -> bool:
|
def has_terminal_status(self) -> bool:
|
||||||
"""Has_terminal_status."""
|
"""Has_terminal_status."""
|
||||||
return self.status in self.terminal_statuses()
|
return self.status in self.terminal_statuses()
|
||||||
|
|
|
@ -1670,6 +1670,13 @@ def task_submit(
|
||||||
"""Task_submit_user_data."""
|
"""Task_submit_user_data."""
|
||||||
principal = find_principal_or_raise()
|
principal = find_principal_or_raise()
|
||||||
process_instance = find_process_instance_by_id_or_raise(process_instance_id)
|
process_instance = find_process_instance_by_id_or_raise(process_instance_id)
|
||||||
|
if not process_instance.can_submit_task():
|
||||||
|
raise ApiError(
|
||||||
|
error_code="process_instance_not_runnable",
|
||||||
|
message=f"Process Instance ({process_instance.id}) has status "
|
||||||
|
f"{process_instance.status} which does not allow tasks to be submitted.",
|
||||||
|
status_code=400,
|
||||||
|
)
|
||||||
|
|
||||||
processor = ProcessInstanceProcessor(process_instance)
|
processor = ProcessInstanceProcessor(process_instance)
|
||||||
spiff_task = get_spiff_task_from_process_instance(
|
spiff_task = get_spiff_task_from_process_instance(
|
||||||
|
|
|
@ -417,13 +417,15 @@ export default function ProcessModelShow() {
|
||||||
};
|
};
|
||||||
|
|
||||||
const checkDuplicateFile = (event: any) => {
|
const checkDuplicateFile = (event: any) => {
|
||||||
if (processModel && processModel.files.length > 0) {
|
if (processModel) {
|
||||||
let foundExistingFile = false;
|
let foundExistingFile = false;
|
||||||
processModel.files.forEach((file) => {
|
if (processModel.files.length > 0) {
|
||||||
if (file.name === filesToUpload[0].name) {
|
processModel.files.forEach((file) => {
|
||||||
foundExistingFile = true;
|
if (file.name === filesToUpload[0].name) {
|
||||||
}
|
foundExistingFile = true;
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
if (foundExistingFile) {
|
if (foundExistingFile) {
|
||||||
displayOverwriteConfirmation(filesToUpload[0].name);
|
displayOverwriteConfirmation(filesToUpload[0].name);
|
||||||
setFileUploadEvent(event);
|
setFileUploadEvent(event);
|
||||||
|
@ -431,12 +433,11 @@ export default function ProcessModelShow() {
|
||||||
doFileUpload(event);
|
doFileUpload(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleFileUpload = (event: any) => {
|
const handleFileUpload = (event: any) => {
|
||||||
if (processModel) {
|
checkDuplicateFile(event);
|
||||||
checkDuplicateFile(event);
|
|
||||||
}
|
|
||||||
setShowFileUploadModal(false);
|
setShowFileUploadModal(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -473,9 +474,6 @@ export default function ProcessModelShow() {
|
||||||
};
|
};
|
||||||
|
|
||||||
const processModelFilesSection = () => {
|
const processModelFilesSection = () => {
|
||||||
if (!processModel) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return (
|
return (
|
||||||
<Grid
|
<Grid
|
||||||
condensed
|
condensed
|
||||||
|
|
Loading…
Reference in New Issue