Watch
1
0
Fork
You've already forked arc
0
forked from hesabix/arc
arc/hesabixAPI/app/services/workflow/triggers/person_triggers.py
2026-04-23 03:43:48 +00:00

71 lines
2.5 KiB
Python
Executable file
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
Triggerهای مربوط به اشخاص
"""
from typing import Any, Dict
from app.services.workflow.triggers.base_trigger import BaseTrigger
class PersonCreatedTrigger(BaseTrigger):
"""Trigger برای ایجاد شخص"""
def get_metadata(self) -> Dict[str, Any]:
return {
"name": "ایجاد شخص",
"description": "زمانی که یک شخص (مشتری/تامین‌کننده) ایجاد می‌شود",
"config_schema": {
"person_type": {
"type": "string",
"description": "نوع شخص",
"enum": ["customer", "supplier", "employee", "other"],
"ui_config": {
"labels": {
"customer": "مشتری",
"supplier": "تامین‌کننده",
"employee": "کارمند",
"other": "سایر"
}
},
"required": False
}
}
}
def execute(self, context: Dict[str, Any], config: Dict[str, Any]) -> Dict[str, Any]:
data = super().execute(context, config)
# فیلتر بر اساس نوع شخص
person_type = config.get("person_type")
if person_type:
person_types = data.get("person_types", [])
if person_type not in person_types:
return {}
return data
class PersonUpdatedTrigger(PersonCreatedTrigger):
"""به‌روزرسانی اطلاعات شخص"""
def get_metadata(self) -> Dict[str, Any]:
return {
"name": "ویرایش شخص",
"description": "زمانی که اطلاعات یک شخص ویرایش می‌شود",
"config_schema": {
"person_type": {
"type": "string",
"description": "نوع شخص",
"enum": ["customer", "supplier", "employee", "other"],
"ui_config": {
"labels": {
"customer": "مشتری",
"supplier": "تامین‌کننده",
"employee": "کارمند",
"other": "سایر"
}
},
"required": False
}
}
}