pyl is passing w/ burnettk

This commit is contained in:
jasquat 2022-11-04 11:03:40 -04:00
parent d46ac958a2
commit edfa95124a
6 changed files with 43 additions and 26 deletions

View File

@ -1,7 +1,7 @@
"""Process_group."""
from __future__ import annotations
import dataclasses
import dataclasses
from dataclasses import dataclass
from dataclasses import field
from typing import Any
@ -42,6 +42,7 @@ class ProcessGroup:
@property
def serialized(self) -> dict:
"""Serialized."""
original_dict = dataclasses.asdict(self)
return {x: original_dict[x] for x in original_dict if x not in ["sort_index"]}

View File

@ -30,7 +30,6 @@ class ProcessModelInfo:
display_name: str
description: str
process_group_id: str = ""
process_group: Any | None = None
primary_file_name: str | None = None
primary_process_id: str | None = None
display_order: int | None = 0

View File

@ -43,7 +43,8 @@ from spiffworkflow_backend.models.message_triggerable_process_model import (
MessageTriggerableProcessModel,
)
from spiffworkflow_backend.models.principal import PrincipalModel
from spiffworkflow_backend.models.process_group import ProcessGroup, ProcessGroupSchema
from spiffworkflow_backend.models.process_group import ProcessGroup
from spiffworkflow_backend.models.process_group import ProcessGroupSchema
from spiffworkflow_backend.models.process_instance import ProcessInstanceApiSchema
from spiffworkflow_backend.models.process_instance import ProcessInstanceModel
from spiffworkflow_backend.models.process_instance import ProcessInstanceModelSchema
@ -134,9 +135,7 @@ def permissions_check(body: Dict[str, Dict[str, list[str]]]) -> flask.wrappers.R
return make_response(jsonify({"results": response_dict}), 200)
def process_group_add(
body: dict
) -> flask.wrappers.Response:
def process_group_add(body: dict) -> flask.wrappers.Response:
"""Add_process_group."""
process_model_service = ProcessModelService()
process_group = ProcessGroup(**body)
@ -150,11 +149,16 @@ def process_group_delete(process_group_id: str) -> flask.wrappers.Response:
return Response(json.dumps({"ok": True}), status=200, mimetype="application/json")
def process_group_update(
process_group_id: str, body: dict
) -> flask.wrappers.Response:
def process_group_update(process_group_id: str, body: dict) -> flask.wrappers.Response:
"""Process Group Update."""
process_group = ProcessGroup(id=process_group_id, **body)
body_include_list = ["display_name", "description"]
body_filtered = {
include_item: body[include_item]
for include_item in body_include_list
if include_item in body
}
process_group = ProcessGroup(id=process_group_id, **body_filtered)
ProcessModelService().update_process_group(process_group)
return make_response(jsonify(process_group), 200)
@ -221,7 +225,6 @@ def process_model_add(
status_code=400,
)
process_model_info.process_group = process_group
process_model_service.add_spec(process_model_info)
return Response(
json.dumps(ProcessModelInfoSchema().dump(process_model_info)),

View File

@ -1,5 +1,4 @@
"""Process_model_service."""
import dataclasses
import json
import os
import shutil
@ -275,6 +274,5 @@ class ProcessModelService(FileSystemService):
with open(spec_path, "w") as wf_json:
json.dump(self.WF_SCHEMA.dump(spec), wf_json, indent=4)
if process_group:
spec.process_group = process_group
spec.process_group_id = process_group.id
return spec

View File

@ -1,5 +1,4 @@
"""Test Process Api Blueprint."""
import dataclasses
import io
import json
import time
@ -9,7 +8,6 @@ import pytest
from flask.app import Flask
from flask.testing import FlaskClient
from flask_bpmn.models.db import db
from spiffworkflow_backend import MyJSONEncoder
from tests.spiffworkflow_backend.helpers.base_test import BaseTest
from tests.spiffworkflow_backend.helpers.test_data import load_test_spec
@ -19,7 +17,6 @@ from spiffworkflow_backend.exceptions.process_entity_not_found_error import (
from spiffworkflow_backend.models.active_task import ActiveTaskModel
from spiffworkflow_backend.models.group import GroupModel
from spiffworkflow_backend.models.process_group import ProcessGroup
# from spiffworkflow_backend.models.process_group import ProcessGroupSchema
from spiffworkflow_backend.models.process_instance import ProcessInstanceModel
from spiffworkflow_backend.models.process_instance import ProcessInstanceStatus
from spiffworkflow_backend.models.process_instance_report import (
@ -390,14 +387,13 @@ class TestProcessApi(BaseTest):
display_name="Another Test Category",
display_order=0,
admin=False,
description="Test Description"
description="Test Description",
)
response = client.post(
"/v1.0/process-groups",
headers=self.logged_in_headers(with_super_admin_user),
content_type="application/json",
data=json.dumps(process_group.serialized),
)
assert response.status_code == 201
assert response.json
@ -468,7 +464,7 @@ class TestProcessApi(BaseTest):
f"/v1.0/process-groups/{group_id}",
headers=self.logged_in_headers(with_super_admin_user),
content_type="application/json",
data=json.dumps(ProcessGroupSchema().dump(process_group)),
data=json.dumps(process_group.serialized),
)
assert response.status_code == 200
@ -795,6 +791,7 @@ class TestProcessApi(BaseTest):
f"/v1.0/process-groups/{test_process_group_id}",
headers=self.logged_in_headers(with_super_admin_user),
)
assert response.status_code == 200
assert response.json is not None
assert response.json["id"] == test_process_group_id
@ -1304,7 +1301,7 @@ class TestProcessApi(BaseTest):
# start > 2000, end < 5000 - this should eliminate the first 2 and the last
response = client.get(
"/v1.0/process-instances?start_from=2001&end_till=5999",
"/v1.0/process-instances?start_from=2001&end_to=5999",
headers=self.logged_in_headers(with_super_admin_user),
)
assert response.json is not None
@ -1315,7 +1312,7 @@ class TestProcessApi(BaseTest):
# start > 1000, start < 4000 - this should eliminate the first and the last 2
response = client.get(
"/v1.0/process-instances?start_from=1001&start_till=3999",
"/v1.0/process-instances?start_from=1001&start_to=3999",
headers=self.logged_in_headers(with_super_admin_user),
)
assert response.json is not None
@ -1326,7 +1323,7 @@ class TestProcessApi(BaseTest):
# end > 2000, end < 6000 - this should eliminate the first and the last
response = client.get(
"/v1.0/process-instances?end_from=2001&end_till=5999",
"/v1.0/process-instances?end_from=2001&end_to=5999",
headers=self.logged_in_headers(with_super_admin_user),
)
assert response.json is not None

View File

@ -1,12 +1,20 @@
import { useEffect, useState } from 'react';
import { Link, useNavigate, useSearchParams } from 'react-router-dom';
// @ts-ignore
import { Button, Table } from '@carbon/react';
import {
Button,
Table,
ExpandableTile,
TileAboveTheFoldContent,
TileBelowTheFoldContent,
TextInput,
ClickableTile,
// @ts-ignore
} from '@carbon/react';
import ProcessBreadcrumb from '../components/ProcessBreadcrumb';
import PaginationForTable from '../components/PaginationForTable';
import HttpService from '../services/HttpService';
import { getPageInfoFromSearchParams } from '../helpers';
import { CarbonComboBoxSelection } from '../interfaces';
import { CarbonComboBoxSelection, ProcessGroup } from '../interfaces';
import ProcessModelSearch from '../components/ProcessModelSearch';
// Example process group json
@ -49,7 +57,7 @@ export default function ProcessGroupList() {
}, [searchParams]);
const buildTable = () => {
const rows = processGroups.map((row) => {
const rows = processGroups.map((row: ProcessGroup) => {
return (
<tr key={(row as any).id}>
<td>
@ -73,6 +81,17 @@ export default function ProcessGroupList() {
<tbody>{rows}</tbody>
</Table>
);
// const rows = processGroups.map((row: ProcessGroup) => {
// return (
// <span>
// <ClickableTile href={`/admin/process-groups/${row.id}`}>
// {row.display_name}
// </ClickableTile>
// </span>
// );
// });
//
// return <div style={{ width: '400px' }}>{rows}</div>;
};
const processGroupsDisplayArea = () => {