Skip to content

EC status change events #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions csfunctions/events/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
from .dummy import DummyEvent, DummyEventData
from .engineering_change_release_check import EngineeringChangeReleaseCheckData, EngineeringChangeReleaseCheckEvent
from .engineering_change_released import EngineeringChangeReleasedData, EngineeringChangeReleasedEvent
from .engineering_change_status_change_check import (
EngineeringChangeStatusChangeCheckData,
EngineeringChangeStatusChangeCheckEvent,
)
from .engineering_change_status_changed import EngineeringChangeStatusChangedData, EngineeringChangeStatusChangedEvent
from .field_value_calculation import FieldValueCalculationData, FieldValueCalculationEvent
from .part_create_check import PartCreateCheckData, PartCreateCheckEvent
from .part_field_calculation import PartFieldCalculationData, PartFieldCalculationEvent
Expand All @@ -31,6 +36,8 @@
DummyEvent,
EngineeringChangeReleasedEvent,
EngineeringChangeReleaseCheckEvent,
EngineeringChangeStatusChangedEvent,
EngineeringChangeStatusChangeCheckEvent,
WorkflowTaskTriggerEvent,
DocumentCreateCheckEvent,
DocumentModifyCheckEvent,
Expand All @@ -50,6 +57,8 @@
DummyEventData,
EngineeringChangeReleasedData,
EngineeringChangeReleaseCheckData,
EngineeringChangeStatusChangedData,
EngineeringChangeStatusChangeCheckData,
WorkflowTaskTriggerEventData,
DocumentCreateCheckData,
DocumentModifyCheckData,
Expand Down Expand Up @@ -78,6 +87,8 @@
"DummyEventData",
"EngineeringChangeReleasedData",
"EngineeringChangeReleaseCheckData",
"EngineeringChangeStatusChangedData",
"EngineeringChangeStatusChangeCheckData",
"WorkflowTaskTriggerEventData",
"DocumentReleasedDialogData",
"PartReleasedDialogData",
Expand Down
2 changes: 2 additions & 0 deletions csfunctions/events/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class EventNames(str, Enum):
DOCUMENT_MODIFY_CHECK = "document_modify_check"
PART_CREATE_CHECK = "part_create_check"
PART_MODIFY_CHECK = "part_modify_check"
ENGINEERING_CHANGE_STATUS_CHANGED = "engineering_change_status_changed"
ENGINEERING_CHANGE_STATUS_CHANGE_CHECK = "engineering_change_status_change_check"


class BaseEvent(BaseModel):
Expand Down
21 changes: 21 additions & 0 deletions csfunctions/events/engineering_change_status_change_check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from typing import Literal

from pydantic import BaseModel, Field

from csfunctions.objects import Document, EngineeringChange, Part

from .base import BaseEvent, EventNames


class EngineeringChangeStatusChangeCheckData(BaseModel):
engineering_change: EngineeringChange = Field(
..., description="The engineering change that will have its status modified"
)
target_status: int = Field(..., description="The target status of the engineering change")
documents: list[Document] = Field(..., description="List of documents attached to the engineering change")
parts: list[Part] = Field(..., description="List of parts attached to the engineering change")


class EngineeringChangeStatusChangeCheckEvent(BaseEvent):
name: Literal[EventNames.ENGINEERING_CHANGE_STATUS_CHANGE_CHECK] = EventNames.ENGINEERING_CHANGE_STATUS_CHANGE_CHECK
data: EngineeringChangeStatusChangeCheckData
21 changes: 21 additions & 0 deletions csfunctions/events/engineering_change_status_changed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from typing import Literal

from pydantic import BaseModel, Field

from csfunctions.objects import Document, EngineeringChange, Part

from .base import BaseEvent, EventNames


class EngineeringChangeStatusChangedData(BaseModel):
engineering_change: EngineeringChange = Field(
..., description="The engineering change that had its status modified"
)
prev_status: int = Field(..., description="The previous status of the engineering change")
documents: list[Document] = Field(..., description="List of documents attached to the engineering change")
parts: list[Part] = Field(..., description="List of parts attached to the engineering change")


class EngineeringChangeStatusChangedEvent(BaseEvent):
name: Literal[EventNames.ENGINEERING_CHANGE_STATUS_CHANGED] = EventNames.ENGINEERING_CHANGE_STATUS_CHANGED
data: EngineeringChangeStatusChangedData
36 changes: 36 additions & 0 deletions docs/reference/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,39 @@ This event is fired by the workflow task "Trigger Webhook".
|documents| list[[Document](objects.md#document)]|List of documents attached to the workflow.|
|engineering_changes| list[[EngineeringChange](objects.md#engineeringchange)]|List of engineering changes attached to the workflow.|
|briefcases| list[[Briefcase](objects.md#briefcase)]|List of briefcases attached to the workflow.|

## EngineeringChangeStatusChanged
`csfunctions.events.EngineeringChangeStatusChanged`

This event is fired **after** an engineering change's status has been modified. Raising an exception cannot prevent the status change.

**EngineeringChangeStatusChanged.name:** engineering_change_status_changed

**EngineeringChangeStatusChanged.data:**

|Attribute|Type|Description|
|-|-|-|
|engineering_change|[EngineeringChange](objects.md#engineeringchange)|The engineering change that had its status modified|
|prev_status|str|The previous status of the engineering change|
|documents|list[[Document](objects.md#document)]|List of documents attached to the engineering change|
|parts|list[[Part](objects.md#part)]|List of parts attached to the engineering change|

## EngineeringChangeStatusChangeCheck
`csfunctions.events.EngineeringChangeStatusChangeCheck`

This event is fired when a user tries to modify an engineering change's status. Raising an exception will prevent the status change.

**Supported actions:**

- [AbortAndShowErrorAction](actions.md#AbortAndShowErrorAction)

**EngineeringChangeStatusChangeCheck.name:** engineering_change_status_change_check

**EngineeringChangeStatusChangeCheck.data:**

|Attribute|Type|Description|
|-|-|-|
|engineering_change|[EngineeringChange](objects.md#engineeringchange)|The engineering change that will have its status modified|
|target_status|int|The status the engineering change will be set to|
|documents|list[[Document](objects.md#document)]|List of documents attached to the engineering change|
|parts|list[[Part](objects.md#part)]|List of parts attached to the engineering change|
130 changes: 130 additions & 0 deletions json_schemas/request.json
Original file line number Diff line number Diff line change
Expand Up @@ -1511,6 +1511,128 @@
"title": "EngineeringChangeReleasedEvent",
"type": "object"
},
"EngineeringChangeStatusChangeCheckData": {
"properties": {
"engineering_change": {
"$ref": "#/$defs/EngineeringChange",
"description": "The engineering change that will have its status modified"
},
"target_status": {
"description": "The target status of the engineering change",
"title": "Target Status",
"type": "integer"
},
"documents": {
"description": "List of documents attached to the engineering change",
"items": {
"$ref": "#/$defs/Document"
},
"title": "Documents",
"type": "array"
},
"parts": {
"description": "List of parts attached to the engineering change",
"items": {
"$ref": "#/$defs/Part"
},
"title": "Parts",
"type": "array"
}
},
"required": [
"engineering_change",
"target_status",
"documents",
"parts"
],
"title": "EngineeringChangeStatusChangeCheckData",
"type": "object"
},
"EngineeringChangeStatusChangeCheckEvent": {
"properties": {
"name": {
"const": "engineering_change_status_change_check",
"default": "engineering_change_status_change_check",
"title": "Name",
"type": "string"
},
"event_id": {
"description": "unique identifier",
"title": "Event Id",
"type": "string"
},
"data": {
"$ref": "#/$defs/EngineeringChangeStatusChangeCheckData"
}
},
"required": [
"event_id",
"data"
],
"title": "EngineeringChangeStatusChangeCheckEvent",
"type": "object"
},
"EngineeringChangeStatusChangedData": {
"properties": {
"engineering_change": {
"$ref": "#/$defs/EngineeringChange",
"description": "The engineering change that had its status modified"
},
"prev_status": {
"description": "The previous status of the engineering change",
"title": "Prev Status",
"type": "integer"
},
"documents": {
"description": "List of documents attached to the engineering change",
"items": {
"$ref": "#/$defs/Document"
},
"title": "Documents",
"type": "array"
},
"parts": {
"description": "List of parts attached to the engineering change",
"items": {
"$ref": "#/$defs/Part"
},
"title": "Parts",
"type": "array"
}
},
"required": [
"engineering_change",
"prev_status",
"documents",
"parts"
],
"title": "EngineeringChangeStatusChangedData",
"type": "object"
},
"EngineeringChangeStatusChangedEvent": {
"properties": {
"name": {
"const": "engineering_change_status_changed",
"default": "engineering_change_status_changed",
"title": "Name",
"type": "string"
},
"event_id": {
"description": "unique identifier",
"title": "Event Id",
"type": "string"
},
"data": {
"$ref": "#/$defs/EngineeringChangeStatusChangedData"
}
},
"required": [
"event_id",
"data"
],
"title": "EngineeringChangeStatusChangedEvent",
"type": "object"
},
"FieldValueCalculationData": {
"properties": {
"scheme_updates": {
Expand Down Expand Up @@ -3076,6 +3198,8 @@
"dummy": "#/$defs/DummyEvent",
"engineering_change_release_check": "#/$defs/EngineeringChangeReleaseCheckEvent",
"engineering_change_released": "#/$defs/EngineeringChangeReleasedEvent",
"engineering_change_status_change_check": "#/$defs/EngineeringChangeStatusChangeCheckEvent",
"engineering_change_status_changed": "#/$defs/EngineeringChangeStatusChangedEvent",
"field_value_calculation": "#/$defs/FieldValueCalculationEvent",
"part_create_check": "#/$defs/PartCreateCheckEvent",
"part_field_calculation": "#/$defs/PartFieldCalculationEvent",
Expand Down Expand Up @@ -3117,6 +3241,12 @@
{
"$ref": "#/$defs/EngineeringChangeReleaseCheckEvent"
},
{
"$ref": "#/$defs/EngineeringChangeStatusChangedEvent"
},
{
"$ref": "#/$defs/EngineeringChangeStatusChangeCheckEvent"
},
{
"$ref": "#/$defs/WorkflowTaskTriggerEvent"
},
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "contactsoftware-functions"
version = "0.12.0"
version = "0.11.0.dev4"
readme = "README.md"

license = "MIT"
Expand Down
Loading