Skip to content

Conversation

jens-kuerten
Copy link
Collaborator

@jens-kuerten jens-kuerten commented Jul 12, 2024

ReleaseCheck Events:

Adds new ReleaseCheck Events, which are triggered before an object is released and allow the release to be aborted with an Action.

  • DocumentReleaseCheck
  • PartReleaseCheck
  • EngineeringChangeCheck

AbortAndShowErrorAction:

Adds AbortAndShowErrorAction (already existed in csfunctions, but wasn't usable)
Actions can be returned directly from Functions. (csfunctions will automatically wrap them in a WorkloadResponse)

Example:

def prevent_doc_release(metadata, event: DocumentReleaseCheckEvent, service):
    # prevent release if a document doesn't contain any files
    for doc in event.data.documents:
        if not doc.files:        
            return AbortAndShowErrorAction(
                message=f"Can't release because document {doc.z_nummer} doesn't contain a file."
            )

Misc:

  • Removed the custom constructors on events, because they were causing typing issues and are not required.

@jens-kuerten jens-kuerten merged commit 49c7955 into main Aug 7, 2024
4 checks passed
@jens-kuerten jens-kuerten deleted the basic_actions branch August 7, 2024 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants