Skip to content
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
20 changes: 20 additions & 0 deletions csfunctions/events/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
from pydantic import Field

from .dialog_data import DocumentReleaseDialogData, PartReleaseDialogData
from .document_create_check import DocumentCreateCheckData, DocumentCreateCheckEvent
from .document_modify_check import DocumentModifyCheckData, DocumentModifyCheckEvent
from .document_release import DocumentReleaseData, DocumentReleaseEvent
from .document_release_check import DocumentReleaseCheckData, DocumentReleaseCheckEvent
from .dummy import DummyEvent, DummyEventData
from .engineering_change_release import EngineeringChangeRelease, EngineeringChangeReleaseData
from .engineering_change_release_check import EngineeringChangeReleaseCheck, EngineeringChangeReleaseCheckData
from .field_value_calculation import FieldValueCalculationData, FieldValueCalculationEvent
from .part_create_check import PartCreateCheckData, PartCreateCheckEvent
from .part_modify_check import PartModifyCheckData, PartModifyCheckEvent
from .part_release import PartReleaseData, PartReleaseEvent
from .part_release_check import PartReleaseCheckData, PartReleaseCheckEvent
from .workflow_task_trigger import WorkflowTaskTriggerEvent, WorkflowTaskTriggerEventData
Expand All @@ -24,6 +28,10 @@
EngineeringChangeRelease,
EngineeringChangeReleaseCheck,
WorkflowTaskTriggerEvent,
DocumentCreateCheckEvent,
DocumentModifyCheckEvent,
PartCreateCheckEvent,
PartModifyCheckEvent,
],
Field(discriminator="name"),
]
Expand All @@ -37,6 +45,10 @@
EngineeringChangeReleaseData,
EngineeringChangeReleaseCheckData,
WorkflowTaskTriggerEventData,
DocumentCreateCheckData,
DocumentModifyCheckData,
PartCreateCheckData,
PartModifyCheckData,
]

__all__ = [
Expand All @@ -60,4 +72,12 @@
"WorkflowTaskTriggerEventData",
"DocumentReleaseDialogData",
"PartReleaseDialogData",
"DocumentCreateCheckData",
"DocumentCreateCheckEvent",
"DocumentModifyCheckData",
"DocumentModifyCheckEvent",
"PartCreateCheckData",
"PartCreateCheckEvent",
"PartModifyCheckData",
"PartModifyCheckEvent",
]
4 changes: 4 additions & 0 deletions csfunctions/events/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ class EventNames(str, Enum):
ENGINEERING_CHANGE_RELEASE_CHECK = "engineering_change_release_check"
FIELD_VALUE_CALCULATION = "field_value_calculation"
WORKFLOW_TASK_TRIGGER = "workflow_task_trigger"
DOCUMENT_CREATE_CHECK = "document_create_check"
DOCUMENT_MODIFY_CHECK = "document_modify_check"
PART_CREATE_CHECK = "part_create_check"
PART_MODIFY_CHECK = "part_modify_check"


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

from pydantic import BaseModel, Field

from csfunctions.objects import Document, Part

from .base import BaseEvent, EventNames


class DocumentCreateCheckData(BaseModel):
documents: list[Document] = Field(..., description="List of documents that are about to be created")
linked_parts: list[Part] = Field(..., description="List of parts that belong to the documents")


class DocumentCreateCheckEvent(BaseEvent):
name: Literal[EventNames.DOCUMENT_CREATE_CHECK] = EventNames.DOCUMENT_CREATE_CHECK
data: DocumentCreateCheckData
17 changes: 17 additions & 0 deletions csfunctions/events/document_modify_check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from typing import Literal

from pydantic import BaseModel, Field

from csfunctions.objects import Document, Part

from .base import BaseEvent, EventNames


class DocumentModifyCheckData(BaseModel):
documents: list[Document] = Field(..., description="List of documents that are about to be modified")
linked_parts: list[Part] = Field(..., description="List of parts that belong to the documents")


class DocumentModifyCheckEvent(BaseEvent):
name: Literal[EventNames.DOCUMENT_MODIFY_CHECK] = EventNames.DOCUMENT_MODIFY_CHECK
data: DocumentModifyCheckData
17 changes: 17 additions & 0 deletions csfunctions/events/part_create_check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from typing import Literal

from pydantic import BaseModel, Field

from csfunctions.objects import Document, Part

from .base import BaseEvent, EventNames


class PartCreateCheckData(BaseModel):
parts: list[Part] = Field(..., description="List of parts that are about to be created")
linked_documents: list[Document] = Field(..., description="List of documents that are referenced by the parts.")


class PartCreateCheckEvent(BaseEvent):
name: Literal[EventNames.PART_CREATE_CHECK] = EventNames.PART_CREATE_CHECK
data: PartCreateCheckData
17 changes: 17 additions & 0 deletions csfunctions/events/part_modify_check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from typing import Literal

from pydantic import BaseModel, Field

from csfunctions.objects import Document, Part

from .base import BaseEvent, EventNames


class PartModifyCheckData(BaseModel):
parts: list[Part] = Field(..., description="List of parts that are about to be modified")
linked_documents: list[Document] = Field(..., description="List of documents that are referenced by the parts.")


class PartModifyCheckEvent(BaseEvent):
name: Literal[EventNames.PART_MODIFY_CHECK] = EventNames.PART_MODIFY_CHECK
data: PartModifyCheckData
77 changes: 77 additions & 0 deletions docs/reference/events.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,45 @@
Events always have a `name` and a `data` attribute. The contents of those attributes depend on the type of the event.


## DocumentCreateCheckEvent
`csfunctions.events.DocumentCreateCheckEvent`

This event is fired when a user tries to create or copy a document. Raising an exception will prevent the creation.
The event is triggered before any field calculations are performed.

**Supported actions:**

- [AbortAndShowErrorAction](actions.md#AbortAndShowErrorAction)

**DocumentCreateCheckEvent.name:** document_create_check

**DocumentCreateCheckEvent.data:**

|Attribute|Type|Description|
|-|-|-|
|documents| list[[Document](objects.md#document)]|List of documents that are about to be created.|
|linked_parts| list[[Part](objects.md#part)]|List of parts that belong to the documents.|

## DocumentModifyCheckEvent
`csfunctions.events.DocumentModifyCheckEvent`

This event is fired when a user tries to modify a document. Raising an exception will prevent the modification.
The event is triggered before any field calculations are performed.

**Supported actions:**

- [AbortAndShowErrorAction](actions.md#AbortAndShowErrorAction)

**DocumentModifyCheckEvent.name:** document_modify_check

**DocumentModifyCheckEvent.data:**

|Attribute|Type|Description|
|-|-|-|
|documents| list[[Document](objects.md#document)]|List of documents that are about to be modified.|
|linked_parts| list[[Part](objects.md#part)]|List of parts that belong to the documents.|


## DocumentReleaseCheckEvent
`csfunctions.events.DocumentReleaseCheckEvent`

Expand Down Expand Up @@ -86,6 +126,43 @@ This event is fired **after** an engineering change has been released. Raising a
|documents| list[[Document](objects.md#document)]|List of included documents.|
|parts| list[[Part](objects.md#part)]|List of included parts.|

## PartCreateCheckEvent
`csfunctions.events.PartCreateCheckEvent`

This event is fired when a user tries to create or copy a part. Raising an exception will prevent the creation.
The event is triggered before any field calculations are performed.

**Supported actions:**

- [AbortAndShowErrorAction](actions.md#AbortAndShowErrorAction)

**PartCreateCheckEvent.name:** part_create_check

**PartCreateCheckEvent.data:**

|Attribute|Type|Description|
|-|-|-|
|parts| list[[Part](objects.md#part)]|List of parts that are about to be created.|
|linked_documents| list[[Document](objects.md#document)]|List of documents that are referenced by the parts.|

## PartModifyCheckEvent
`csfunctions.events.PartModifyCheckEvent`

This event is fired when a user tries to modify a part. Raising an exception will prevent the modification.
The event is triggered before any field calculations are performed.

**Supported actions:**

- [AbortAndShowErrorAction](actions.md#AbortAndShowErrorAction)

**PartModifyCheckEvent.name:** part_modify_check

**PartModifyCheckEvent.data:**

|Attribute|Type|Description|
|-|-|-|
|parts| list[[Part](objects.md#part)]|List of parts that are about to be modified.|
|linked_documents| list[[Document](objects.md#document)]|List of documents that are referenced by the parts.|

## PartReleaseCheckEvent
`csfunctions.events.PartReleaseCheckEvent`
Expand Down
Loading
Loading