Procházet zdrojové kódy

feat(oa): allow dept and ownerDept in condition publish whitelist

Co-authored-by: Cursor <cursoragent@cursor.com>
zlwu před 2 měsíci
rodič
revize
d2de132853

+ 2 - 0
backend/app/services/oa_publish.py

@@ -88,6 +88,8 @@ CONDITION_ELIGIBLE_TYPES = frozenset(
         "person",
         "ownerPerson",
         "post",
+        "dept",
+        "ownerDept",
     }
 )
 

+ 41 - 0
backend/tests/test_oa_publish.py

@@ -357,6 +357,47 @@ class TestConditionPublish(unittest.TestCase):
         )
         self.assertTrue(any("发起人" in e and "包含" in e for e in errs))
 
+    def test_dept_condition_field_allowed(self):
+        errs = validate_condition_rules_against_form(
+            {
+                "rule": [
+                    {
+                        "type": "dept",
+                        "field": "Fdept",
+                        "title": "部门",
+                        "useInCondition": True,
+                        "$required": True,
+                        "props": {"multiple": True},
+                    }
+                ]
+            },
+            _condition_flow(
+                rules=[
+                    {"field": "Fdept", "op": "contains", "value": ["d1", "d2"]}
+                ]
+            ),
+        )
+        self.assertEqual(errs, [])
+
+    def test_owner_dept_condition_field_allowed(self):
+        errs = validate_condition_rules_against_form(
+            {
+                "rule": [
+                    {
+                        "type": "ownerDept",
+                        "field": "Fod",
+                        "title": "归属部门",
+                        "useInCondition": True,
+                        "$required": True,
+                    }
+                ]
+            },
+            _condition_flow(
+                rules=[{"field": "Fod", "op": "contains", "value": ["d1"]}]
+            ),
+        )
+        self.assertEqual(errs, [])
+
 
 if __name__ == "__main__":
     unittest.main()