removed some unused code from task and fixed the logs table a bit w/ burnettk

This commit is contained in:
jasquat 2023-02-24 16:18:49 -05:00
parent 425cf3f8c1
commit b71419616d
5 changed files with 89 additions and 149 deletions

View File

@ -22,78 +22,7 @@ class MultiInstanceType(enum.Enum):
class Task: class Task:
"""Task.""" """Task."""
########################################################################## HUMAN_TASK_TYPES = ["User Task", "Manual Task"]
# Custom properties and validations defined in Camunda form fields #
##########################################################################
# Custom task title
PROP_EXTENSIONS_TITLE = "display_name"
PROP_EXTENSIONS_CLEAR_DATA = "clear_data"
# Field Types
FIELD_TYPE_STRING = "string"
FIELD_TYPE_LONG = "long"
FIELD_TYPE_BOOLEAN = "boolean"
FIELD_TYPE_DATE = "date"
FIELD_TYPE_ENUM = "enum"
FIELD_TYPE_TEXTAREA = "textarea" # textarea: Multiple lines of text
FIELD_TYPE_AUTO_COMPLETE = "autocomplete"
FIELD_TYPE_FILE = "file"
FIELD_TYPE_FILES = "files" # files: Multiple files
FIELD_TYPE_TEL = "tel" # tel: Phone number
FIELD_TYPE_EMAIL = "email" # email: Email address
FIELD_TYPE_URL = "url" # url: Website address
FIELD_PROP_AUTO_COMPLETE_MAX = ( # Not used directly, passed in from the front end.
"autocomplete_num"
)
# Required field
FIELD_CONSTRAINT_REQUIRED = "required"
# Field properties and expressions Expressions
FIELD_PROP_REPEAT = "repeat"
FIELD_PROP_READ_ONLY = "read_only"
FIELD_PROP_LDAP_LOOKUP = "ldap.lookup"
FIELD_PROP_READ_ONLY_EXPRESSION = "read_only_expression"
FIELD_PROP_HIDE_EXPRESSION = "hide_expression"
FIELD_PROP_REQUIRED_EXPRESSION = "required_expression"
FIELD_PROP_LABEL_EXPRESSION = "label_expression"
FIELD_PROP_REPEAT_HIDE_EXPRESSION = "repeat_hide_expression"
FIELD_PROP_VALUE_EXPRESSION = "value_expression"
# Enum field options
FIELD_PROP_SPREADSHEET_NAME = "spreadsheet.name"
FIELD_PROP_DATA_NAME = "data.name"
FIELD_PROP_VALUE_COLUMN = "value.column"
FIELD_PROP_LABEL_COLUMN = "label.column"
# Enum field options values pulled from task data
# Group and Repeat functions
FIELD_PROP_GROUP = "group"
FIELD_PROP_REPLEAT = "repeat"
FIELD_PROP_REPLEAT_TITLE = "repeat_title"
FIELD_PROP_REPLEAT_BUTTON = "repeat_button_label"
# File specific field properties
FIELD_PROP_DOC_CODE = "doc_code" # to associate a file upload field with a doc code
FIELD_PROP_FILE_DATA = ( # to associate a bit of data with a specific file upload file.
"file_data"
)
# Additional properties
FIELD_PROP_ENUM_TYPE = "enum_type"
FIELD_PROP_BOOLEAN_TYPE = "boolean_type"
FIELD_PROP_TEXT_AREA_ROWS = "rows"
FIELD_PROP_TEXT_AREA_COLS = "cols"
FIELD_PROP_TEXT_AREA_AUTO = "autosize"
FIELD_PROP_PLACEHOLDER = "placeholder"
FIELD_PROP_DESCRIPTION = "description"
FIELD_PROP_MARKDOWN_DESCRIPTION = "markdown_description"
FIELD_PROP_HELP = "help"
##########################################################################
def __init__( def __init__(
self, self,
@ -202,20 +131,6 @@ class Task:
"task_spiff_step": self.task_spiff_step, "task_spiff_step": self.task_spiff_step,
} }
@classmethod
def valid_property_names(cls) -> list[str]:
"""Valid_property_names."""
return [
value for name, value in vars(cls).items() if name.startswith("FIELD_PROP")
]
@classmethod
def valid_field_types(cls) -> list[str]:
"""Valid_field_types."""
return [
value for name, value in vars(cls).items() if name.startswith("FIELD_TYPE")
]
@classmethod @classmethod
def task_state_name_to_int(cls, task_state_name: str) -> int: def task_state_name_to_int(cls, task_state_name: str) -> int:
task_state_integers = {v: k for k, v in TaskStateNames.items()} task_state_integers = {v: k for k, v in TaskStateNames.items()}

View File

@ -10,6 +10,7 @@ from flask.app import Flask
from spiffworkflow_backend.models.db import db from spiffworkflow_backend.models.db import db
from spiffworkflow_backend.models.spiff_logging import SpiffLoggingModel from spiffworkflow_backend.models.spiff_logging import SpiffLoggingModel
from spiffworkflow_backend.models.task import Task
# flask logging formats: # flask logging formats:
@ -218,9 +219,13 @@ class DBHandler(logging.Handler):
bpmn_task_type = record.task_type if hasattr(record, "task_type") else None # type: ignore bpmn_task_type = record.task_type if hasattr(record, "task_type") else None # type: ignore
timestamp = record.created timestamp = record.created
message = record.msg if hasattr(record, "msg") else None message = record.msg if hasattr(record, "msg") else None
current_user_id = (
record.current_user_id if hasattr(record, "current_user_id") else None # type: ignore current_user_id = None
) if bpmn_task_type in Task.HUMAN_TASK_TYPES and hasattr(
record, "current_user_id"
):
current_user_id = record.current_user_id # type: ignore
spiff_step = ( spiff_step = (
record.spiff_step # type: ignore record.spiff_step # type: ignore
if hasattr(record, "spiff_step") and record.spiff_step is not None # type: ignore if hasattr(record, "spiff_step") and record.spiff_step is not None # type: ignore

View File

@ -234,23 +234,6 @@ class ProcessInstanceService:
# maybe move this out once we have the interstitial page since this is here just so we can get the next human task # maybe move this out once we have the interstitial page since this is here just so we can get the next human task
processor.do_engine_steps(save=True) processor.do_engine_steps(save=True)
@staticmethod
def extract_form_data(latest_data: dict, task: SpiffTask) -> dict:
"""Extracts data from the latest_data that is directly related to the form that is being submitted."""
data = {}
if hasattr(task.task_spec, "form"):
for field in task.task_spec.form.fields:
if field.has_property(Task.FIELD_PROP_REPEAT):
group = field.get_property(Task.FIELD_PROP_REPEAT)
if group in latest_data:
data[group] = latest_data[group]
else:
value = ProcessInstanceService.get_dot_value(field.id, latest_data)
if value is not None:
ProcessInstanceService.set_dot_value(field.id, value, data)
return data
@staticmethod @staticmethod
def create_dot_dict(data: dict) -> dict[str, Any]: def create_dot_dict(data: dict) -> dict[str, Any]:
"""Create_dot_dict.""" """Create_dot_dict."""

View File

@ -2352,7 +2352,7 @@ class TestProcessApi(BaseTest):
assert len(response.json["results"]) == 2 assert len(response.json["results"]) == 2
@pytest.mark.skipif( @pytest.mark.skipif(
os.environ.get("SPIFFWORKFLOW_BACKEND_DATABASE_TYPE") == 'postgres', os.environ.get("SPIFFWORKFLOW_BACKEND_DATABASE_TYPE") == "postgres",
reason="look at comment in tasks_controller method task_list_my_tasks", reason="look at comment in tasks_controller method task_list_my_tasks",
) )
def test_correct_user_can_get_and_update_a_task( def test_correct_user_can_get_and_update_a_task(

View File

@ -10,6 +10,7 @@ import {
} from '../helpers'; } from '../helpers';
import HttpService from '../services/HttpService'; import HttpService from '../services/HttpService';
import { useUriListForPermissions } from '../hooks/UriListForPermissions'; import { useUriListForPermissions } from '../hooks/UriListForPermissions';
import UserService from '../services/UserService';
type OwnProps = { type OwnProps = {
variant: string; variant: string;
@ -28,6 +29,8 @@ export default function ProcessInstanceLogList({ variant }: OwnProps) {
processInstanceShowPageBaseUrl = `/admin/process-instances/${params.process_model_id}`; processInstanceShowPageBaseUrl = `/admin/process-instances/${params.process_model_id}`;
} }
const userEmail = UserService.getUserEmail();
useEffect(() => { useEffect(() => {
const setProcessInstanceLogListFromResult = (result: any) => { const setProcessInstanceLogListFromResult = (result: any) => {
setProcessInstanceLogs(result.results); setProcessInstanceLogs(result.results);
@ -48,9 +51,8 @@ export default function ProcessInstanceLogList({ variant }: OwnProps) {
const buildTable = () => { const buildTable = () => {
const rows = processInstanceLogs.map((row) => { const rows = processInstanceLogs.map((row) => {
const rowToUse = row as any; const rowToUse = row as any;
return ( const tableRow = [];
<tr key={rowToUse.id}> const taskNameCell = (
<td data-qa="paginated-entity-id">{rowToUse.id}</td>
<td> <td>
{rowToUse.bpmn_task_name || {rowToUse.bpmn_task_name ||
(rowToUse.bpmn_task_type === 'Default Start Event' (rowToUse.bpmn_task_type === 'Default Start Event'
@ -58,15 +60,35 @@ export default function ProcessInstanceLogList({ variant }: OwnProps) {
: '') || : '') ||
(rowToUse.bpmn_task_type === 'End Event' ? 'Process Ended' : '')} (rowToUse.bpmn_task_type === 'End Event' ? 'Process Ended' : '')}
</td> </td>
{isDetailedView && ( );
if (isDetailedView) {
tableRow.push(
<> <>
<td>{rowToUse.message}</td> <td data-qa="paginated-entity-id">{rowToUse.id}</td>
<td>{rowToUse.bpmn_task_identifier}</td>
<td>{rowToUse.bpmn_task_type}</td>
</>
)}
<td>{rowToUse.bpmn_process_identifier}</td> <td>{rowToUse.bpmn_process_identifier}</td>
<td>{rowToUse.username}</td> {taskNameCell}
</>
);
} else {
tableRow.push(
<>
{taskNameCell}
<td>{rowToUse.bpmn_process_identifier}</td>
</>
);
}
if (isDetailedView) {
tableRow.push(
<>
<td>{rowToUse.bpmn_task_type}</td>
<td>{rowToUse.message}</td>
<td>
{rowToUse.username === userEmail ? 'me 🔥' : rowToUse.username}
</td>
</>
);
}
tableRow.push(
<td> <td>
<Link <Link
data-qa="process-instance-show-link" data-qa="process-instance-show-link"
@ -75,26 +97,41 @@ export default function ProcessInstanceLogList({ variant }: OwnProps) {
{convertSecondsToFormattedDateTime(rowToUse.timestamp)} {convertSecondsToFormattedDateTime(rowToUse.timestamp)}
</Link> </Link>
</td> </td>
</tr>
); );
return <tr key={rowToUse.id}>{tableRow}</tr>;
}); });
const tableHeaders = [];
if (isDetailedView) {
tableHeaders.push(
<>
<th>Id</th>
<th>Bpmn Process</th>
<th>Task Name</th>
</>
);
} else {
tableHeaders.push(
<>
<th>Event</th>
<th>Bpmn Process</th>
</>
);
}
if (isDetailedView) {
tableHeaders.push(
<>
<th>Task Type</th>
<th>Message</th>
<th>User</th>
</>
);
}
tableHeaders.push(<th>Timestamp</th>);
return ( return (
<Table size="lg"> <Table size="lg">
<thead> <thead>
<tr> <tr>{tableHeaders}</tr>
<th>Id</th>
<th>Task Name</th>
{isDetailedView && (
<>
<th>Message</th>
<th>Task Identifier</th>
<th>Task Type</th>
</>
)}
<th>Bpmn Process Identifier</th>
<th>User</th>
<th>Timestamp</th>
</tr>
</thead> </thead>
<tbody>{rows}</tbody> <tbody>{rows}</tbody>
</Table> </Table>