fixed file upload and do not allow submitting task data to a suspended process instance w/ burnettk

This commit is contained in:
jasquat 2022-12-19 14:28:54 -05:00
parent f152195335
commit d9e0c8cda7
3 changed files with 21 additions and 42 deletions

View File

@ -34,36 +34,6 @@ class ProcessInstanceCannotBeDeletedError(Exception):
"""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):
"""ProcessInstanceStatus."""
@ -139,6 +109,10 @@ class ProcessInstanceModel(SpiffworkflowBaseDBModel):
"""Validate_status."""
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:
"""Has_terminal_status."""
return self.status in self.terminal_statuses()

View File

@ -1670,6 +1670,13 @@ def task_submit(
"""Task_submit_user_data."""
principal = find_principal_or_raise()
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)
spiff_task = get_spiff_task_from_process_instance(

View File

@ -417,13 +417,15 @@ export default function ProcessModelShow() {
};
const checkDuplicateFile = (event: any) => {
if (processModel && processModel.files.length > 0) {
if (processModel) {
let foundExistingFile = false;
processModel.files.forEach((file) => {
if (file.name === filesToUpload[0].name) {
foundExistingFile = true;
}
});
if (processModel.files.length > 0) {
processModel.files.forEach((file) => {
if (file.name === filesToUpload[0].name) {
foundExistingFile = true;
}
});
}
if (foundExistingFile) {
displayOverwriteConfirmation(filesToUpload[0].name);
setFileUploadEvent(event);
@ -431,12 +433,11 @@ export default function ProcessModelShow() {
doFileUpload(event);
}
}
return null;
};
const handleFileUpload = (event: any) => {
if (processModel) {
checkDuplicateFile(event);
}
checkDuplicateFile(event);
setShowFileUploadModal(false);
};
@ -473,9 +474,6 @@ export default function ProcessModelShow() {
};
const processModelFilesSection = () => {
if (!processModel) {
return null;
}
return (
<Grid
condensed